Skip to content

Commit

Permalink
NFInst improvements.
Browse files Browse the repository at this point in the history
- Fixed type of array cast expressions.
- Added internal error when Scalarize fails to expand equation.

Belonging to [master]:
  - OpenModelica/OMCompiler#2029
  - OpenModelica/OpenModelica-testsuite#785
  • Loading branch information
perost authored and OpenModelica-Hudson committed Nov 16, 2017
1 parent 2fe6fb8 commit 16e800b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Compiler/NFFrontEnd/NFExpression.mo
Expand Up @@ -529,7 +529,13 @@ public
case (UNARY(), _)
then UNARY(exp.operator, typeCastElements(exp.exp, ty));

else CAST(ty, exp);
else
algorithm
t := typeOf(exp);
t := Type.setArrayElementType(t, ty);
then
CAST(t, exp);

end match;
end typeCastElements;

Expand Down
5 changes: 5 additions & 0 deletions Compiler/NFFrontEnd/NFScalarize.mo
Expand Up @@ -137,6 +137,11 @@ algorithm
ty := Type.arrayElementType(ty);

while ExpressionIterator.hasNext(lhs_iter) loop
if not ExpressionIterator.hasNext(rhs_iter) then
Error.addInternalError(getInstanceName() + " could not expand rhs " +
Expression.toString(eq.rhs), eq.info);
end if;

(lhs_iter, lhs) := ExpressionIterator.next(lhs_iter);
(rhs_iter, rhs) := ExpressionIterator.next(rhs_iter);
equations := Equation.EQUALITY(lhs, rhs, ty, info) :: equations;
Expand Down

0 comments on commit 16e800b

Please sign in to comment.