Changeset 8066773 in OpenModelica


Ignore:
Timestamp:
2020-06-17T21:21:23+02:00 (4 years ago)
Author:
Adrian Pop <adrian.pop@…>
Branches:
maintenance/v1.16
Children:
302444f
Parents:
ed49d5f
git-author:
Per Östlund <perost86@…> (06/02/20 12:59:40)
git-committer:
Adrian Pop <adrian.pop@…> (06/17/20 21:21:23)
Message:

[NF] Retype conditional array expressions.

  • When doing branch selection on if-expressions where the branches have different dimensions, also do branch selection on the type of the if-expression.
Location:
OMCompiler/Compiler/NFFrontEnd
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • OMCompiler/Compiler/NFFrontEnd/NFEvalConstants.mo

    re84fce5 r8066773  
    235235            fail();
    236236          end if;
     237
     238          outExp := evaluateExpTraverser(if cond.value then tb else fb, info);
    237239        then
    238           evaluateExpTraverser(if cond.value then tb else fb, info);
     240          (outExp, true);
    239241
    240242      else
     
    253255      // condition is a literal boolean value.
    254256      case Expression.BOOLEAN()
    255         then evaluateExpTraverser(if cond.value then tb else fb, info);
     257        algorithm
     258          outExp := evaluateExpTraverser(if cond.value then tb else fb, info);
     259        then
     260          (outExp, true);
    256261
    257262      // Otherwise evaluate constants in both branches and return the whole
  • OMCompiler/Compiler/NFFrontEnd/NFExpression.mo

    ra87a6a00 r8066773  
    43414341      local
    43424342        list<Dimension> dims;
     4343        Type ty;
    43434344
    43444345      case RANGE()
     
    43554356          ();
    43564357
    4357       else ();
     4358      else
     4359        algorithm
     4360          ty := typeOf(exp);
     4361
     4362          if Type.isConditionalArray(ty) then
     4363            ty := Type.simplifyConditionalArray(ty);
     4364            exp := setType(ty, exp);
     4365          end if;
     4366        then
     4367          ();
     4368
    43584369    end match;
    43594370  end retype;
  • OMCompiler/Compiler/NFFrontEnd/NFType.mo

    re293f5a r8066773  
    345345    end if;
    346346  end isMatchedBranch;
     347
     348  function simplifyConditionalArray
     349    input Type ty;
     350    output Type outType;
     351  algorithm
     352    outType := match ty
     353      case CONDITIONAL_ARRAY()
     354        then match ty.matchedBranch
     355            case Branch.TRUE then ty.trueType;
     356            case Branch.FALSE then ty.falseType;
     357            else ty;
     358          end match;
     359
     360      else ty;
     361    end match;
     362  end simplifyConditionalArray;
    347363
    348364  function isVector
Note: See TracChangeset for help on using the changeset viewer.