Skip to content

Commit

Permalink
[NF] Subscripting fixes.
Browse files Browse the repository at this point in the history
- Fix type when subscripting enumerations.
- Only remove subscripts if all of them simplify to :.
  • Loading branch information
perost committed May 30, 2020
1 parent f0d7921 commit c007a39
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 4 additions & 1 deletion OMCompiler/Compiler/NFFrontEnd/NFExpression.mo
Expand Up @@ -1335,6 +1335,7 @@ public
Expression index_exp, start_exp, stop_exp;
Option<Expression> step_exp;
Type ty;
list<Subscript> subs;
algorithm
Subscript.INDEX(index = index_exp) := index;

Expand All @@ -1343,7 +1344,9 @@ public
outExp := applyIndexSubscriptRange2(start_exp, step_exp, stop_exp, toInteger(index_exp));
else
RANGE(ty = ty) := rangeExp;
outExp := SUBSCRIPTED_EXP(rangeExp, {index}, ty);
subs := {index};
ty := Type.subscript(ty, subs);
outExp := SUBSCRIPTED_EXP(rangeExp, subs, ty);
end if;
end applyIndexSubscriptRange;

Expand Down
8 changes: 3 additions & 5 deletions OMCompiler/Compiler/NFFrontEnd/NFSubscript.mo
Expand Up @@ -673,11 +673,9 @@ public
outSubscripts := simplify(s, d) :: outSubscripts;
end for;

while not listEmpty(outSubscripts) and isWhole(listHead(outSubscripts)) loop
outSubscripts := listRest(outSubscripts);
end while;

outSubscripts := listReverseInPlace(outSubscripts);
if not List.all(outSubscripts, isWhole) then
outSubscripts := listReverseInPlace(outSubscripts);
end if;
end if;
end simplifyList;

Expand Down

0 comments on commit c007a39

Please sign in to comment.