Changeset 4d0d14f in OpenModelica


Ignore:
Timestamp:
2017-03-14T14:59:47+01:00 (7 years ago)
Author:
hudson <openmodelica@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
cfa55d7
Parents:
4124ebe8
git-author:
Per Östlund <per.ostlund@…> (03/14/17 14:59:47)
git-committer:
hudson <openmodelica@…> (03/14/17 14:59:47)
Message:

Initial support for for loops in NFInst

  • Implemented for loop statements with explicit range.
  • Partially implemented for loop equations with explicit range (unrolling missing).
  • Implemented initial typing of subscripts.
Location:
Compiler/NFFrontEnd
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • Compiler/NFFrontEnd/NFBinding.mo

    r4c362d1e r4d0d14f  
    122122  end typedExp;
    123123
     124  function variability
     125    input Binding binding;
     126    output DAE.Const var;
     127  algorithm
     128    var := match binding
     129      case TYPED_BINDING() then binding.variability;
     130      else DAE.Const.C_UNKNOWN();
     131    end match;
     132  end variability;
     133
    124134  function getInfo
    125135    input Binding binding;
     
    133143    end match;
    134144  end getInfo;
     145
     146  function getType
     147    input Binding binding;
     148    output Type ty;
     149  algorithm
     150    TYPED_BINDING(bindingType = ty) := binding;
     151  end getType;
    135152
    136153  function isEach
  • Compiler/NFFrontEnd/NFCeval.mo

    r4c362d1e r4d0d14f  
    6464      list<Expression> expl = {};
    6565      Call call;
     66      Component comp;
    6667
    6768    case Expression.CREF(cref=ComponentRef.CREF(node=c as InstNode.COMPONENT_NODE()))
  • Compiler/NFFrontEnd/NFComponent.mo

    r4c362d1e r4d0d14f  
    113113  end TYPED_COMPONENT;
    114114
     115  record ITERATOR
     116    Type ty;
     117    Binding binding;
     118  end ITERATOR;
     119
    115120  function classInstance
    116121    input Component component;
     
    176181      case TYPED_COMPONENT() then component.ty;
    177182      case UNTYPED_COMPONENT() then Class.getType(InstNode.getClass(component.classInst));
     183      case ITERATOR() then component.ty;
    178184      else Type.UNKNOWN();
    179185    end match;
     
    193199        then
    194200          component;
     201
     202      case ITERATOR()
     203        algorithm
     204          component.ty := ty;
     205        then
     206          component;
     207
    195208    end match;
    196209  end setType;
     
    202215    isTyped := match component
    203216      case TYPED_COMPONENT() then true;
     217      case ITERATOR(ty = Type.UNKNOWN()) then false;
     218      case ITERATOR() then true;
    204219      else false;
    205220    end match;
     
    219234          ();
    220235
     236      case ITERATOR(ty = Type.ARRAY(elementType = ty))
     237        algorithm
     238          component.ty := ty;
     239        then
     240          ();
     241
    221242      else ();
    222243    end match;
     
    240261      case UNTYPED_COMPONENT() then component.binding;
    241262      case TYPED_COMPONENT() then component.binding;
     263      case ITERATOR() then component.binding;
    242264    end match;
    243265  end getBinding;
     
    307329      case TYPED_COMPONENT(attributes = Attributes.ATTRIBUTES(variability = variability)) then variability;
    308330      case UNTYPED_COMPONENT(attributes = Attributes.ATTRIBUTES(variability = variability)) then variability;
     331      case ITERATOR() then DAE.VarKind.CONST();
    309332      else fail();
    310333    end match;
  • Compiler/NFFrontEnd/NFComponentRef.mo

    r64ce9d9 r4d0d14f  
    8484    input ComponentRef cref;
    8585    output DAE.Const var;
    86   protected
    87     DAE.VarKind var_kind;
    8886  algorithm
    8987    var := match cref
    9088      case CREF()
    91         algorithm
    92           Component.Attributes.ATTRIBUTES(variability = var_kind) :=
    93             Component.getAttributes(InstNode.component(cref.node));
    94         then
    95           match var_kind
     89        then
     90          match Component.variability(InstNode.component(cref.node))
    9691            case DAE.VarKind.VARIABLE() then DAE.Const.C_VAR();
    9792            case DAE.VarKind.DISCRETE() then DAE.Const.C_VAR();
  • Compiler/NFFrontEnd/NFEquation.mo

    r4c362d1e r4d0d14f  
    3535import Expression = NFExpression;
    3636import Type = NFType;
     37import NFInstNode.InstNode;
    3738
    3839public uniontype Equation
     
    5657
    5758  record FOR
    58     String name           "The name of the iterator variable.";
    59     Integer index         "The index of the iterator variable.";
    60     Type indexType    "The type of the index/iterator variable.";
    61     Option<Expression> range "The range expression to loop over.";
     59    InstNode iterator;
    6260    list<Equation> body   "The body of the for loop.";
    6361    SourceInfo info;
  • Compiler/NFFrontEnd/NFFlatten.mo

    r4c362d1e r4d0d14f  
    531531        el :: elements;
    532532
    533     case Equation.FOR()
    534       algorithm
    535         // flatten the equations
    536         (els1, funcs) := flattenEquations(eq.body, prefix, {}, funcs);
    537 
    538         // deal with the range
    539         if isSome(eq.range) then
    540           SOME(e) := eq.range;
    541           SOME(de) := DAEUtil.evaluateExp(Expression.toDAE(e), elements);
    542           range := match (de)
    543                     case DAE.ARRAY(array = range) then range;
    544                     case DAE.RANGE(_, DAE.ICONST(is), SOME(DAE.ICONST(step)), DAE.ICONST(ie))
    545                       then List.map(ExpressionSimplify.simplifyRange(is, step, ie), DAEExpression.makeIntegerExp);
    546                     case DAE.RANGE(_, DAE.ICONST(is), _, DAE.ICONST(ie))
    547                       then if is <= ie
    548                            then List.map(ExpressionSimplify.simplifyRange(is, 1, ie), DAEExpression.makeIntegerExp)
    549                            else List.map(ExpressionSimplify.simplifyRange(is, -1, ie), DAEExpression.makeIntegerExp);
    550                   end match;
    551           // replace index in elements
    552           for i in range loop
    553             els := DAEUtil.replaceCrefInDAEElements(els1, DAE.CREF_IDENT(eq.name, Type.toDAE(eq.indexType), {}), i);
    554             elements := listAppend(els, elements);
    555           end for;
    556         end if;
    557       then
    558         elements;
     533//    case Equation.FOR()
     534//      algorithm
     535//        // flatten the equations
     536//        (els1, funcs) := flattenEquations(eq.body, prefix, {}, funcs);
     537//
     538//        // deal with the range
     539//        if isSome(eq.range) then
     540//          SOME(e) := eq.range;
     541//          SOME(de) := DAEUtil.evaluateExp(Expression.toDAE(e), elements);
     542//          range := match (de)
     543//                    case DAE.ARRAY(array = range) then range;
     544//                    case DAE.RANGE(_, DAE.ICONST(is), SOME(DAE.ICONST(step)), DAE.ICONST(ie))
     545//                      then List.map(ExpressionSimplify.simplifyRange(is, step, ie), DAEExpression.makeIntegerExp);
     546//                    case DAE.RANGE(_, DAE.ICONST(is), _, DAE.ICONST(ie))
     547//                      then if is <= ie
     548//                           then List.map(ExpressionSimplify.simplifyRange(is, 1, ie), DAEExpression.makeIntegerExp)
     549//                           else List.map(ExpressionSimplify.simplifyRange(is, -1, ie), DAEExpression.makeIntegerExp);
     550//                  end match;
     551//          // replace index in elements
     552//          for i in range loop
     553//            els := DAEUtil.replaceCrefInDAEElements(els1, DAE.CREF_IDENT(eq.name, Type.toDAE(eq.indexType), {}), i);
     554//            elements := listAppend(els, elements);
     555//          end for;
     556//        end if;
     557//      then
     558//        elements;
    559559
    560560    case Equation.WHEN()
     
    748748    case Statement.FOR()
    749749      algorithm
    750         // flatten the list of statements
    751         (sts, funcs) := flattenStatements(alg.body, {}, funcs);
    752         if isSome(alg.range) then
    753           SOME(e) := alg.range;
    754           de := Expression.toDAE(e);
    755         else
    756           de := DAE.SCONST("NO RANGE GIVEN TODO FIXME");
    757         end if;
    758       then
    759         DAE.STMT_FOR(Type.toDAE(alg.indexType), false, alg.name, alg.index, de, sts, ElementSource.createElementSource(alg.info)) :: stmts;
     750        (stmt, funcs) := flattenForStatement(alg, funcs);
     751      then
     752        stmt :: stmts;
    760753
    761754    case Statement.IF()
     
    919912  Option<DAE.Statement> owhenStatement = NONE();
    920913algorithm
    921 
    922914  head :: rest := whenBranches;
    923915  cond1 := Expression.toDAE(Util.tuple21(head));
     
    926918
    927919  for b in rest loop
    928   cond2 := Expression.toDAE(Util.tuple21(b));
     920    cond2 := Expression.toDAE(Util.tuple21(b));
    929921    (stmts2, funcs) := flattenStatements(Util.tuple22(b), {}, funcs);
    930922    whenStatement := DAE.STMT_WHEN(cond2, {}, false, stmts2, owhenStatement, ElementSource.createElementSource(info));
     
    934926  whenStatement := DAE.STMT_WHEN(cond1, {}, false, stmts1, owhenStatement, ElementSource.createElementSource(info));
    935927end flattenWhenStatement;
     928
     929function flattenForStatement
     930  input Statement forStmt;
     931        output DAE.Statement forDAE;
     932  input output DAE.FunctionTree funcs;
     933protected
     934  InstNode iterator;
     935  Type ty;
     936  Binding binding;
     937  Expression range;
     938  list<Statement> body;
     939  list<DAE.Statement> dbody;
     940  SourceInfo info;
     941algorithm
     942  Statement.FOR(iterator = iterator, body = body, info = info) := forStmt;
     943
     944  (dbody, funcs) := flattenStatements(body, {}, funcs);
     945
     946  Component.ITERATOR(ty = ty, binding = binding) := InstNode.component(iterator);
     947  SOME(range) := Binding.typedExp(binding);
     948
     949  forDAE := DAE.STMT_FOR(Type.toDAE(ty), Type.isArray(ty),
     950    InstNode.name(iterator), 0, Expression.toDAE(range), dbody,
     951    ElementSource.createElementSource(info));
     952end flattenForStatement;
    936953
    937954function applyExpPrefix
  • Compiler/NFFrontEnd/NFInst.mo

    r4c362d1e r4d0d14f  
    108108  // instantiation to make sure that lookup is able to find the correct nodes.
    109109  instExpressions(inst_cls);
    110   execStat("NFInst.instBindings("+ name +")");
     110  execStat("NFInst.instExpressions("+ name +")");
    111111
    112112  // Type the class.
     
    13741374      list<tuple<Expression, list<Equation>>> branches;
    13751375      SourceInfo info;
     1376      Binding binding;
     1377      InstNode for_scope, iter;
    13761378
    13771379    case SCode.EEquation.EQ_EQUALS(info = info)
     
    13911393    case SCode.EEquation.EQ_FOR(info = info)
    13921394      algorithm
    1393         oexp := instExpOpt(scodeEq.range, scope, info);
    1394         eql := instEEquations(scodeEq.eEquationLst, scope);
    1395       then
    1396         Equation.FOR(scodeEq.index, 0, Type.UNKNOWN(), oexp, eql, info);
     1395        binding := Binding.fromAbsyn(scodeEq.range, SCode.NOT_EACH(), 0, scope, info);
     1396        binding := instBinding(binding);
     1397
     1398        (for_scope, iter) := addIteratorToScope(scodeEq.index, binding, info, scope);
     1399        eql := instEEquations(scodeEq.eEquationLst, for_scope);
     1400      then
     1401        Equation.FOR(iter, eql, info);
    13971402
    13981403    case SCode.EEquation.EQ_IF(info = info)
     
    15041509      list<tuple<Expression, list<Statement>>> branches;
    15051510      SourceInfo info;
     1511      Binding binding;
     1512      InstNode for_scope, iter;
    15061513
    15071514    case SCode.Statement.ALG_ASSIGN(info = info)
     
    15141521    case SCode.Statement.ALG_FOR(info = info)
    15151522      algorithm
    1516         oexp := instExpOpt(scodeStmt.range, scope, info);
    1517         stmtl := instStatements(scodeStmt.forBody, scope);
    1518       then
    1519         Statement.FOR(scodeStmt.index, 0, Type.UNKNOWN(), oexp, stmtl, info);
     1523        binding := Binding.fromAbsyn(scodeStmt.range, SCode.NOT_EACH(), 0, scope, info);
     1524        binding := instBinding(binding);
     1525
     1526        (for_scope, iter) := addIteratorToScope(scodeStmt.index, binding, info, scope);
     1527        stmtl := instStatements(scodeStmt.forBody, for_scope);
     1528      then
     1529        Statement.FOR(iter, stmtl, info);
    15201530
    15211531    case SCode.Statement.ALG_IF(info = info)
     
    15961606end instStatement;
    15971607
     1608function addIteratorToScope
     1609  input String name;
     1610  input Binding binding;
     1611  input SourceInfo info;
     1612  input output InstNode scope;
     1613        output InstNode iterator;
     1614protected
     1615  Component iter_comp;
     1616  SCode.Element elem;
     1617algorithm
     1618  scope := InstNode.openImplicitScope(scope);
     1619  elem := SCode.Element.COMPONENT(name, SCode.defaultPrefixes,
     1620    SCode.defaultVarAttr, Absyn.TypeSpec.TPATH(Absyn.Path.IDENT("$dummy"), NONE()),
     1621    SCode.NOMOD(), SCode.noComment, NONE(), info);
     1622  iter_comp := Component.ITERATOR(Type.UNKNOWN(), binding);
     1623  iterator := InstNode.fromComponent(name, iter_comp, elem, scope);
     1624  scope := InstNode.addIterator(iterator, scope);
     1625end addIteratorToScope;
     1626
    15981627annotation(__OpenModelica_Interface="frontend");
    15991628end NFInst;
  • Compiler/NFFrontEnd/NFInstNode.mo

    r64ce9d9 r4d0d14f  
    109109  end REF_NODE;
    110110
     111  record IMPLICIT_SCOPE
     112    InstNode parentScope;
     113    list<InstNode> locals;
     114  end IMPLICIT_SCOPE;
     115
    111116  record EMPTY_NODE end EMPTY_NODE;
    112117
     
    240245  end isEmpty;
    241246
     247  function isImplicit
     248    input InstNode node;
     249    output Boolean isImplicit;
     250  algorithm
     251    isImplicit := match node
     252      case IMPLICIT_SCOPE() then true;
     253      else false;
     254    end match;
     255  end isImplicit;
     256
    242257  function name
    243258    input InstNode node;
     
    247262      case CLASS_NODE() then node.name;
    248263      case COMPONENT_NODE() then node.name;
     264      // For bug catching, these names should never be used.
     265      case REF_NODE() then "$ref" + String(node.index);
     266      case IMPLICIT_SCOPE() then "$implicit";
     267      case EMPTY_NODE() then "$empty";
    249268    end match;
    250269  end name;
     
    276295      case CLASS_NODE() then node.parentScope;
    277296      case COMPONENT_NODE() then node.parent;
     297      case IMPLICIT_SCOPE() then node.parentScope;
    278298    end match;
    279299  end parent;
     
    323343        algorithm
    324344          node.parent := parent;
     345        then
     346          ();
     347
     348      case IMPLICIT_SCOPE()
     349        algorithm
     350          node.parentScope := parent;
    325351        then
    326352          ();
     
    577603
    578604      case COMPONENT_NODE(parent = EMPTY_NODE()) then accumScopes;
    579 
    580605      case COMPONENT_NODE() then scopeList(node.parent, node :: accumScopes);
     606      case IMPLICIT_SCOPE() then scopeList(node.parentScope, accumScopes);
    581607    end match;
    582608  end scopeList;
     
    660686    end match;
    661687  end cacheAddFunc;
     688
     689  function openImplicitScope
     690    input output InstNode scope;
     691  algorithm
     692    scope := match scope
     693      case IMPLICIT_SCOPE() then scope;
     694      else IMPLICIT_SCOPE(scope, {});
     695    end match;
     696  end openImplicitScope;
     697
     698  function addIterator
     699    input InstNode iterator;
     700    input output InstNode scope;
     701  algorithm
     702    scope := match scope
     703      case IMPLICIT_SCOPE() then IMPLICIT_SCOPE(scope, iterator :: scope.locals);
     704    end match;
     705  end addIterator;
    662706end InstNode;
    663707
  • Compiler/NFFrontEnd/NFLookup.mo

    r3532cb45 r4d0d14f  
    432432  for i in 1:Global.recursionDepthLimit loop
    433433    try
     434      node := match foundScope
     435        case InstNode.IMPLICIT_SCOPE()
     436          then lookupIterator(name, foundScope.locals);
     437        case InstNode.CLASS_NODE()
     438          then Class.lookupElement(name, InstNode.getClass(foundScope));
     439        case InstNode.COMPONENT_NODE()
     440          then Class.lookupElement(name, InstNode.getClass(foundScope));
     441      end match;
     442
    434443      // Check if the cref can be found in the current scope.
    435       cls := InstNode.getClass(foundScope);
    436       node := Class.lookupElement(name, cls);
     444      //cls := InstNode.getClass(foundScope);
     445      //node := Class.lookupElement(name, cls);
    437446
    438447      // We found a node, return it.
     
    449458end lookupSimpleCref;
    450459
     460function lookupIterator
     461  input String name;
     462  input list<InstNode> iterators;
     463  output InstNode iterator;
     464algorithm
     465  for i in iterators loop
     466    if name == InstNode.name(i) then
     467      iterator := i;
     468      return;
     469    end if;
     470  end for;
     471
     472  fail();
     473end lookupIterator;
     474
    451475function lookupCrefInNode
    452476  input Absyn.ComponentRef cref;
  • Compiler/NFFrontEnd/NFStatement.mo

    r4c362d1e r4d0d14f  
    3535import Type = NFType;
    3636import Expression = NFExpression;
     37import NFInstNode.InstNode;
    3738
    3839public uniontype Statement
     
    5051
    5152  record FOR
    52     String name "The name of the iterator variable.";
    53     Integer index "The index of the scope of the iterator variable.";
    54     Type indexType "The type of the index/iterator variable.";
    55     Option<Expression> range "The range expression to loop over.";
     53    InstNode iterator;
    5654    list<Statement> body "The body of the for loop.";
    5755    SourceInfo info;
  • Compiler/NFFrontEnd/NFType.mo

    r4c362d1e r4d0d14f  
    171171    end match;
    172172  end isArray;
     173
     174  function isVector
     175    "Return whether the type is a vector type or not, i.e. a 1-dimensional array."
     176    input Type ty;
     177    output Boolean isVector;
     178  algorithm
     179    isVector := match ty
     180      case ARRAY(dimensions = {_}) then true;
     181      else false;
     182    end match;
     183  end isVector;
    173184
    174185  function isEnumeration
  • Compiler/NFFrontEnd/NFTyping.mo

    r4c362d1e r4d0d14f  
    6363import Ceval = NFCeval;
    6464import SimplifyExp = NFSimplifyExp;
     65import Subscript = NFSubscript;
    6566
    6667public
     
    149150end typeComponent;
    150151
     152function typeIterator
     153  input InstNode iterator;
     154  input InstNode scope;
     155  input Boolean structural = false "If the iteration range must be a parameter expression or not.";
     156protected
     157  Component c = InstNode.component(iterator);
     158  Binding binding;
     159  Type ty;
     160algorithm
     161  () := match c
     162    case Component.ITERATOR(binding = Binding.UNTYPED_BINDING())
     163      algorithm
     164        binding := typeBinding(c.binding, scope);
     165
     166        // If the iteration range is structural, it must be a parameter expression.
     167        if structural and not Types.isParameterOrConstant(Binding.variability(binding)) then
     168          Error.addSourceMessageAndFail(Error.NON_PARAMETER_ITERATOR_RANGE,
     169            {Binding.toString(binding)}, InstNode.info(iterator));
     170        end if;
     171
     172        ty := Binding.getType(binding);
     173
     174        // The iteration range must be a vector expression.
     175        if not Type.isVector(ty) then
     176          Error.addSourceMessageAndFail(Error.FOR_EXPRESSION_TYPE_ERROR,
     177            {Binding.toString(binding), Type.toString(ty)}, InstNode.info(iterator));
     178        end if;
     179
     180        // The type of the iterator is the element type of the range expression.
     181        ty := Type.arrayElementType(ty);
     182        c := Component.ITERATOR(ty, binding);
     183        InstNode.updateComponent(c, iterator);
     184      then
     185        ();
     186
     187    case Component.ITERATOR(binding = Binding.UNBOUND())
     188      algorithm
     189        assert(false, getInstanceName() + ": Implicit iteration ranges not yet implement");
     190      then
     191        fail();
     192
     193    else
     194      algorithm
     195        assert(false, getInstanceName() + " got non-iterator " + InstNode.name(iterator));
     196      then
     197        fail();
     198
     199  end match;
     200end typeIterator;
     201
    151202function typeDimensions
    152203  input output array<Dimension> dimensions;
     
    484535        ty := Component.getType(comp);
    485536        variability := ComponentRef.getVariability(cref);
    486         exp := Expression.CREF(ComponentRef.setType(ty, cref));
    487       then
    488         (exp, ty, variability);
     537        cref.ty := ty;
     538        cref.subscripts := typeSubscripts(cref.subscripts, scope, info);
     539      then
     540        (Expression.CREF(cref), ty, variability);
    489541
    490542    // A typename, e.g. Boolean or an enumeration type.
     
    503555  end match;
    504556end typeCref;
     557
     558function typeSubscripts
     559  input list<Subscript> subscripts;
     560  input InstNode scope;
     561  input SourceInfo info;
     562  output list<Subscript> typedSubs;
     563algorithm
     564  typedSubs := list(typeSubscript(s, scope, info) for s in subscripts);
     565end typeSubscripts;
     566
     567function typeSubscript
     568  input output Subscript subscript;
     569  input InstNode scope;
     570  input SourceInfo info;
     571algorithm
     572  subscript := match subscript
     573    local
     574      Expression e;
     575      Type ty;
     576
     577    case Subscript.UNTYPED()
     578      algorithm
     579        (e, ty, _) := typeExp(subscript.exp, scope, info);
     580      then
     581        if Type.isArray(ty) then Subscript.SLICE(e) else Subscript.INDEX(e);
     582
     583    else subscript;
     584  end match;
     585end typeSubscript;
    505586
    506587function typeArray
     
    619700  eq := match eq
    620701    local
    621       Option<Expression> ope1;
    622702      Expression cond, e1, e2, e3;
    623       Option<Type> opty1;
    624703      Type ty1, ty2;
    625704      list<Equation> eqs1, body;
    626705      list<tuple<Expression, list<Equation>>> tybrs;
    627       InstNode fakeComponent;
    628       array<InstNode> components;
    629       Class cls;
    630       Integer index;
    631       ClassTree.Tree elements;
     706      InstNode iterator;
    632707
    633708    case Equation.EQUALITY()
     
    645720        Equation.CONNECT(e1, ty1, e2, ty2, eq.info);
    646721
    647     case Equation.FOR() then eq;
    648     //case Equation.FOR()
    649     //  algorithm
    650     //    ope1 := NONE();
    651     //    if (isSome(eq.range)) then
    652     //      (e1, ty1) := typeExp(Util.getOption(eq.range), scope, eq.info);
    653     //      ty1 := Type.arrayElementType(ty1);
    654     //      ope1 := SOME(e1);
    655     //    end if;
    656     //    // we need to add the iterator to the component scope!
    657     //    fakeComponent := InstNode.newComponent(
    658     //       SCode.COMPONENT(
    659     //          eq.name,
    660     //          SCode.defaultPrefixes,
    661     //          SCode.defaultVarAttr,
    662     //          Absyn.TPATH(Absyn.IDENT("Integer"), NONE()),
    663     //          SCode.NOMOD(),
    664     //          SCode.COMMENT(NONE(), NONE()),
    665     //          NONE(),
    666     //          eq.info), scope);
    667     //    fakeComponent := Inst.instComponent(fakeComponent, scope, scope);
    668     //    fakeComponent := typeComponent(fakeComponent, scope);
    669     //    cls := InstNode.getClass(scope);
    670     //    components := Class.components(cls);
    671     //    index := arrayLength(components) + 1;
    672     //    components := listArray(listAppend(arrayList(components), {fakeComponent}));
    673     //    cls := Class.setComponents(components, cls);
    674     //    elements := Class.elements(cls);
    675     //    elements :=  ClassTree.add(elements, eq.name,
    676     //          ClassTree.Entry.COMPONENT(0, index), ClassTree.addConflictReplace);
    677     //    cls := Class.setElements(elements, cls);
    678     //    fakeComponent := InstNode.updateClass(cls, scope);
    679     //    eqs1 := list(typeEquation(beq, fakeComponent) for beq in eq.body);
    680     //  then
    681     //    Equation.FOR(eq.name, 1, ty1, ope1, eqs1, eq.info);
     722    case Equation.FOR()
     723      algorithm
     724        typeIterator(eq.iterator, scope, true);
     725        body := typeEquations(eq.body, scope);
     726      then
     727        Equation.FOR(eq.iterator, body, eq.info);
    682728
    683729    case Equation.IF()
     
    758804  st := match st
    759805    local
    760       Option<Expression> ope1;
    761806      Expression cond, e1, e2, e3;
    762       Option<Type> opty1;
    763807      Type ty1, ty2, ty3;
    764808      list<Statement> sts1, body;
    765809      list<tuple<Expression, list<Statement>>> tybrs;
     810      InstNode iterator;
    766811
    767812    case Statement.ASSIGNMENT()
     
    771816      then
    772817        Statement.ASSIGNMENT(e1, e2, st.info);
     818
     819    case Statement.FOR()
     820      algorithm
     821        typeIterator(st.iterator, scope);
     822        body := typeAlgorithm(st.body, scope);
     823      then
     824        Statement.FOR(st.iterator, body, st.info);
    773825
    774826    case Statement.IF()
Note: See TracChangeset for help on using the changeset viewer.