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

Commit c4e03c8

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix tuple calls in builtins and reductions.
- Fix the origin for arguments of special builtin calls and reductions/array constructors so that tuple calls are handled correctly. Belonging to [master]: - #2946
1 parent a44d71c commit c4e03c8

File tree

2 files changed

+48
-44
lines changed

2 files changed

+48
-44
lines changed

Compiler/NFFrontEnd/NFBuiltinCall.mo

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -99,53 +99,55 @@ public
9999
Expression first;
100100
list<Expression> rest;
101101
String name;
102+
ExpOrigin.Type next_origin;
102103
algorithm
103104
Call.UNTYPED_CALL(ref = cref) := call;
105+
next_origin := ExpOrigin.setFlag(origin, ExpOrigin.SUBEXPRESSION);
104106

105107
(callExp, ty, variability) := match ComponentRef.firstName(cref)
106-
case "String" then typeStringCall(call, origin, info);
107-
case "branch" then typeBranchCall(call, origin, info);
108-
case "cardinality" then typeCardinalityCall(call, origin, info);
109-
case "cat" then typeCatCall(call, origin, info);
110-
case "change" then typeChangeCall(call, origin, info);
111-
case "der" then typeDerCall(call, origin, info);
112-
case "diagonal" then typeDiagonalCall(call, origin, info);
113-
case "edge" then typeEdgeCall(call, origin, info);
114-
case "fill" then typeFillCall(call, origin, info);
108+
case "String" then typeStringCall(call, next_origin, info);
109+
case "branch" then typeBranchCall(call, next_origin, info);
110+
case "cardinality" then typeCardinalityCall(call, next_origin, info);
111+
case "cat" then typeCatCall(call, next_origin, info);
112+
case "change" then typeChangeCall(call, next_origin, info);
113+
case "der" then typeDerCall(call, next_origin, info);
114+
case "diagonal" then typeDiagonalCall(call, next_origin, info);
115+
case "edge" then typeEdgeCall(call, next_origin, info);
116+
case "fill" then typeFillCall(call, next_origin, info);
115117
case "getInstanceName" then typeGetInstanceName(call);
116-
case "initial" then typeDiscreteCall(call, origin, info);
117-
case "isRoot" then typeIsRootCall(call, origin, info);
118-
case "matrix" then typeMatrixCall(call, origin, info);
119-
case "max" then typeMinMaxCall("max", call, origin, info);
120-
case "min" then typeMinMaxCall("min", call, origin, info);
121-
case "ndims" then typeNdimsCall(call, origin, info);
122-
case "noEvent" then typeNoEventCall(call, origin, info);
123-
case "ones" then typeZerosOnesCall("ones", call, origin, info);
124-
case "potentialRoot" then typePotentialRootCall(call, origin, info);
125-
case "pre" then typePreCall(call, origin, info);
126-
case "product" then typeProductCall(call, origin, info);
127-
case "root" then typeRootCall(call, origin, info);
128-
case "rooted" then typeRootedCall(call, origin, info);
129-
case "scalar" then typeScalarCall(call, origin, info);
130-
case "smooth" then typeSmoothCall(call, origin, info);
131-
case "sum" then typeSumCall(call, origin, info);
132-
case "symmetric" then typeSymmetricCall(call, origin, info);
133-
case "terminal" then typeDiscreteCall(call, origin, info);
134-
case "transpose" then typeTransposeCall(call, origin, info);
135-
case "vector" then typeVectorCall(call, origin, info);
136-
case "zeros" then typeZerosOnesCall("zeros", call, origin, info);
137-
case "Clock" guard Config.synchronousFeaturesAllowed() then typeClockCall(call, origin, info);
138-
case "sample" then typeSampleCall(call, origin, info);
118+
case "initial" then typeDiscreteCall(call, next_origin, info);
119+
case "isRoot" then typeIsRootCall(call, next_origin, info);
120+
case "matrix" then typeMatrixCall(call, next_origin, info);
121+
case "max" then typeMinMaxCall("max", call, next_origin, info);
122+
case "min" then typeMinMaxCall("min", call, next_origin, info);
123+
case "ndims" then typeNdimsCall(call, next_origin, info);
124+
case "noEvent" then typeNoEventCall(call, next_origin, info);
125+
case "ones" then typeZerosOnesCall("ones", call, next_origin, info);
126+
case "potentialRoot" then typePotentialRootCall(call, next_origin, info);
127+
case "pre" then typePreCall(call, next_origin, info);
128+
case "product" then typeProductCall(call, next_origin, info);
129+
case "root" then typeRootCall(call, next_origin, info);
130+
case "rooted" then typeRootedCall(call, next_origin, info);
131+
case "scalar" then typeScalarCall(call, next_origin, info);
132+
case "smooth" then typeSmoothCall(call, next_origin, info);
133+
case "sum" then typeSumCall(call, next_origin, info);
134+
case "symmetric" then typeSymmetricCall(call, next_origin, info);
135+
case "terminal" then typeDiscreteCall(call, next_origin, info);
136+
case "transpose" then typeTransposeCall(call, next_origin, info);
137+
case "vector" then typeVectorCall(call, next_origin, info);
138+
case "zeros" then typeZerosOnesCall("zeros", call, next_origin, info);
139+
case "Clock" guard Config.synchronousFeaturesAllowed() then typeClockCall(call, next_origin, info);
140+
case "sample" then typeSampleCall(call, next_origin, info);
139141
/*
140-
case "hold" guard Config.synchronousFeaturesAllowed() then typeHoldCall(call, origin, info);
141-
case "shiftSample" guard Config.synchronousFeaturesAllowed() then typeShiftSampleCall(call, origin, info);
142-
case "backSample" guard Config.synchronousFeaturesAllowed() then typeBackSampleCall(call, origin, info);
143-
case "noClock" guard Config.synchronousFeaturesAllowed() then typeNoClockCall(call, origin, info);
144-
case "transition" guard Config.synchronousFeaturesAllowed() then typeTransitionCall(call, origin, info);
145-
case "initialState" guard Config.synchronousFeaturesAllowed() then typeInitialStateCall(call, origin, info);
146-
case "activeState" guard Config.synchronousFeaturesAllowed() then typeActiveStateCall(call, origin, info);
147-
case "ticksInState" guard Config.synchronousFeaturesAllowed() then typeTicksInStateCall(call, origin, info);
148-
case "timeInState" guard Config.synchronousFeaturesAllowed() then typeTimeInStateCall(call, origin, info);
142+
case "hold" guard Config.synchronousFeaturesAllowed() then typeHoldCall(call, next_origin, info);
143+
case "shiftSample" guard Config.synchronousFeaturesAllowed() then typeShiftSampleCall(call, next_origin, info);
144+
case "backSample" guard Config.synchronousFeaturesAllowed() then typeBackSampleCall(call, next_origin, info);
145+
case "noClock" guard Config.synchronousFeaturesAllowed() then typeNoClockCall(call, next_origin, info);
146+
case "transition" guard Config.synchronousFeaturesAllowed() then typeTransitionCall(call, next_origin, info);
147+
case "initialState" guard Config.synchronousFeaturesAllowed() then typeInitialStateCall(call, next_origin, info);
148+
case "activeState" guard Config.synchronousFeaturesAllowed() then typeActiveStateCall(call, next_origin, info);
149+
case "ticksInState" guard Config.synchronousFeaturesAllowed() then typeTicksInStateCall(call, next_origin, info);
150+
case "timeInState" guard Config.synchronousFeaturesAllowed() then typeTimeInStateCall(call, next_origin, info);
149151
*/
150152
else
151153
algorithm

Compiler/NFFrontEnd/NFCall.mo

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -990,10 +990,11 @@ protected
990990
variability := Variability.CONSTANT;
991991
// The size of the expression must be known unless we're in a function.
992992
is_structural := ExpOrigin.flagNotSet(origin, ExpOrigin.FUNCTION);
993+
next_origin := ExpOrigin.setFlag(origin, ExpOrigin.SUBEXPRESSION);
993994

994995
for i in call.iters loop
995996
(iter, range) := i;
996-
(range, iter_ty, iter_var) := Typing.typeIterator(iter, range, origin, is_structural);
997+
(range, iter_ty, iter_var) := Typing.typeIterator(iter, range, next_origin, is_structural);
997998

998999
if is_structural then
9991000
range := Ceval.evalExp(range, Ceval.EvalTarget.RANGE(info));
@@ -1007,7 +1008,7 @@ protected
10071008
iters := listReverseInPlace(iters);
10081009

10091010
// ExpOrigin.FOR is used here as a marker that this expression may contain iterators.
1010-
next_origin := intBitOr(origin, ExpOrigin.FOR);
1011+
next_origin := intBitOr(next_origin, ExpOrigin.FOR);
10111012
(arg, ty) := Typing.typeExp(call.exp, next_origin, info);
10121013
ty := Type.liftArrayLeftList(ty, dims);
10131014
then
@@ -1039,6 +1040,7 @@ protected
10391040
case UNTYPED_REDUCTION()
10401041
algorithm
10411042
variability := Variability.CONSTANT;
1043+
next_origin := ExpOrigin.setFlag(origin, ExpOrigin.SUBEXPRESSION);
10421044

10431045
for i in call.iters loop
10441046
(iter, range) := i;
@@ -1050,7 +1052,7 @@ protected
10501052
iters := listReverseInPlace(iters);
10511053

10521054
// ExpOrigin.FOR is used here as a marker that this expression may contain iterators.
1053-
next_origin := intBitOr(origin, ExpOrigin.FOR);
1055+
next_origin := intBitOr(next_origin, ExpOrigin.FOR);
10541056
(arg, ty) := Typing.typeExp(call.exp, next_origin, info);
10551057
{fn} := Function.typeRefCache(call.ref);
10561058
TypeCheck.checkReductionType(ty, Function.name(fn), call.exp, info);

0 commit comments

Comments
 (0)