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

Commit

Permalink
[NF] Fix Expression.typeOf for size(x).
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - #3033
  • Loading branch information
perost authored and OpenModelica-Hudson committed Apr 3, 2019
1 parent 8676697 commit 450104a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFExpression.mo
Expand Up @@ -784,7 +784,7 @@ public
case RECORD() then exp.ty;
case CALL() then Call.typeOf(exp.call);
case SIZE() then if isSome(exp.dimIndex) then
Type.INTEGER() else typeOf(exp.exp);
Type.INTEGER() else Type.sizeType(typeOf(exp.exp));
case END() then Type.INTEGER();
case BINARY() then Operator.typeOf(exp.operator);
case UNARY() then Operator.typeOf(exp.operator);
Expand Down
13 changes: 13 additions & 0 deletions Compiler/NFFrontEnd/NFType.mo
Expand Up @@ -892,5 +892,18 @@ public
end match;
end isBoxed;

function sizeType
input Type arrayTy;
output Type sizeTy;
algorithm
if Type.isUnknown(arrayTy) then
// Return unknown type if the type is unknown, to avoid returning Array[0]
// for untyped expressions.
sizeTy := Type.UNKNOWN();
else
sizeTy := Type.ARRAY(Type.INTEGER(), {Dimension.fromInteger(dimensionCount(arrayTy))});
end if;
end sizeType;

annotation(__OpenModelica_Interface="frontend");
end NFType;
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFTyping.mo
Expand Up @@ -1892,7 +1892,7 @@ algorithm
fail();
end if;

sizeType := Type.ARRAY(Type.INTEGER(), {Dimension.fromInteger(Type.dimensionCount(exp_ty))});
sizeType := Type.sizeType(exp_ty);
then
(Expression.SIZE(exp, NONE()), sizeType, Variability.PARAMETER);

Expand Down

0 comments on commit 450104a

Please sign in to comment.