Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
More nfinst fixes for ScalableTestSuite.
Browse files Browse the repository at this point in the history
- Add preliminary support for end (just passing it through for now).
- Remember to actually increment the index when adding imports,
  so more than one import per scope works.
  • Loading branch information
perost authored and OpenModelica-Hudson committed Jun 19, 2017
1 parent 6e92692 commit 76d8750
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions Compiler/NFFrontEnd/NFClassTree.mo
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ public
i := 1;
for e in imported_elems loop
ltree := addImport(e, i, ltree);
i := i + 1;
end for;

tree := PARTIAL_TREE(ltree, clss, comps, exts, listArray(imported_elems));
Expand Down
15 changes: 12 additions & 3 deletions Compiler/NFFrontEnd/NFExpression.mo
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ public
Option<Expression> dimIndex;
end SIZE;

record END
end END;

record BINARY "Binary operations, e.g. a+4"
Expression exp1;
Operator operator;
Expand Down Expand Up @@ -272,6 +275,8 @@ public
then
if comp == 0 then compare(exp1.exp, e1) else comp;

case END() then 0;

case BINARY()
algorithm
BINARY(exp1 = e1, operator = op, exp2 = e2) := exp2;
Expand Down Expand Up @@ -421,6 +426,8 @@ public
algorithm
ty := if listMember(ty, {Type.INTEGER(), Type.REAL(), Type.STRING(), Type.BOOLEAN()}) then ty else Type.UNKNOWN();
then ty;
case SIZE(dimIndex = SOME(_)) then Type.INTEGER();
case END() then Type.INTEGER();
else Type.UNKNOWN();
end match;
end typeOf;
Expand Down Expand Up @@ -609,6 +616,7 @@ public
then ", " + toString(Util.getOption(exp.dimIndex))
else ""
) + ")";
case END() then "end";
case BINARY() then "(" + toString(exp.exp1) + Operator.symbol(exp.operator) + toString(exp.exp2) + ")";
case UNARY() then "(" + Operator.symbol(exp.operator) + " " + toString(exp.exp) + ")";
case LBINARY() then "(" + toString(exp.exp1) + Operator.symbol(exp.operator) + toString(exp.exp2) + ")";
Expand All @@ -621,8 +629,7 @@ public

case CAST() then "CAST(" + Type.toString(exp.ty) + ", " + toString(exp.exp) + ")";


else "NFExpression.toString: IMPLEMENT ME";
else anyString(exp);
end match;
end toString;

Expand Down Expand Up @@ -671,6 +678,8 @@ public
then SOME(toDAE(Util.getOption(exp.dimIndex)))
else NONE());

// END() doesn't have a DAE representation.

case BINARY()
then DAE.BINARY(toDAE(exp.exp1), Operator.toDAE(exp.operator), toDAE(exp.exp2));

Expand All @@ -696,7 +705,7 @@ public

else
algorithm
assert(false, getInstanceName() + " got unknown expression");
assert(false, getInstanceName() + " got unknown expression '" + toString(exp) + "'");
then
fail();

Expand Down
2 changes: 2 additions & 0 deletions Compiler/NFFrontEnd/NFInst.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,8 @@ algorithm
case Absyn.Exp.CALL()
then Call.instantiate(absynExp.function_, absynExp.functionArgs, scope, info);

case Absyn.Exp.END() then Expression.END();

else
algorithm
assert(false, getInstanceName() + " got unknown expression");
Expand Down
2 changes: 2 additions & 0 deletions Compiler/NFFrontEnd/NFTyping.mo
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,8 @@ algorithm
case Expression.ARRAY() then typeArray(exp.elements, info);
case Expression.RANGE() then typeRange(exp, info);

case Expression.END() then (exp, Type.INTEGER(), Const.C_CONST());

case Expression.BINARY()
algorithm
(e1, ty1, var1) := typeExp(exp.exp1, info);
Expand Down

0 comments on commit 76d8750

Please sign in to comment.