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

Commit 5c68648

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Retype array constructors after ceval.
- Retype array constructors in EvalConstants.evalExp when necessary, to avoid the scalarization failing due to non-constant dimensions. - Handle 'each' in Variable.toString. Belonging to [master]: - #2855
1 parent 15e62b7 commit 5c68648

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

Compiler/NFFrontEnd/NFCall.mo

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -810,6 +810,30 @@ uniontype Call
810810
end match;
811811
end isVectorizeable;
812812

813+
function retype
814+
input output Call call;
815+
algorithm
816+
() := match call
817+
local
818+
Type ty;
819+
list<Dimension> dims;
820+
821+
case TYPED_ARRAY_CONSTRUCTOR()
822+
algorithm
823+
dims := {};
824+
825+
for i in listReverse(call.iters) loop
826+
dims := listAppend(Type.arrayDims(Expression.typeOf(Util.tuple22(i))), dims);
827+
end for;
828+
829+
call.ty := Type.liftArrayLeftList(Type.arrayElementType(call.ty), dims);
830+
then
831+
();
832+
833+
else ();
834+
end match;
835+
end retype;
836+
813837
protected
814838
function instNormalCall
815839
input Absyn.ComponentRef functionName;

Compiler/NFFrontEnd/NFEvalConstants.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ algorithm
168168
(outExp, outChanged) := Expression.mapFoldShallow(exp,
169169
function evaluateExpTraverser(isExternalArg = Call.isExternal(exp.call)), false);
170170
then
171-
outExp;
171+
if outChanged then Expression.retype(outExp) else outExp;
172172

173173
else
174174
algorithm

Compiler/NFFrontEnd/NFExpression.mo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4701,6 +4701,12 @@ public
47014701
then
47024702
();
47034703

4704+
case CALL(call = Call.TYPED_ARRAY_CONSTRUCTOR())
4705+
algorithm
4706+
exp.call := Call.retype(exp.call);
4707+
then
4708+
();
4709+
47044710
else ();
47054711
end match;
47064712
end retype;

Compiler/NFFrontEnd/NFVariable.mo

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ public
9797
protected
9898
IOStream.IOStream s;
9999
Boolean first;
100+
Binding b;
100101
algorithm
101102
s := IOStream.create(getInstanceName(), IOStream.IOStreamType.LIST());
102103

@@ -122,9 +123,15 @@ public
122123
s := IOStream.append(s, ", ");
123124
end if;
124125

126+
b := Util.tuple22(a);
127+
128+
if Binding.isEach(b) then
129+
s := IOStream.append(s, "each ");
130+
end if;
131+
125132
s := IOStream.append(s, Util.tuple21(a));
126133
s := IOStream.append(s, " = ");
127-
s := IOStream.append(s, Binding.toString(Util.tuple22(a)));
134+
s := IOStream.append(s, Binding.toString(b));
128135
end for;
129136

130137
s := IOStream.append(s, ")");

0 commit comments

Comments
 (0)