File tree Expand file tree Collapse file tree 3 files changed +35
-3
lines changed
OMCompiler/Compiler/NFFrontEnd Expand file tree Collapse file tree 3 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -234,8 +234,10 @@ algorithm
234234 Dimension . toStringList(Type . arrayDims(Expression . typeOf(fb)), brackets = false )}, info);
235235 fail();
236236 end if ;
237+
238+ outExp := evaluateExpTraverser(if cond. value then tb else fb, info);
237239 then
238- evaluateExpTraverser( if cond . value then tb else fb, info );
240+ (outExp, true );
239241
240242 else
241243 algorithm
@@ -252,7 +254,10 @@ algorithm
252254 // Only evaluate constants in and return one of the branches if the
253255 // condition is a literal boolean value.
254256 case Expression . BOOLEAN ()
255- then evaluateExpTraverser(if cond. value then tb else fb, info);
257+ algorithm
258+ outExp := evaluateExpTraverser(if cond. value then tb else fb, info);
259+ then
260+ (outExp, true );
256261
257262 // Otherwise evaluate constants in both branches and return the whole
258263 // if-expression.
Original file line number Diff line number Diff line change @@ -4340,6 +4340,7 @@ public
43404340 () := match exp
43414341 local
43424342 list< Dimension > dims;
4343+ Type ty;
43434344
43444345 case RANGE ()
43454346 algorithm
@@ -4354,7 +4355,17 @@ public
43544355 then
43554356 ();
43564357
4357- else ();
4358+ else
4359+ algorithm
4360+ ty := typeOf(exp);
4361+
4362+ if Type . isConditionalArray(ty) then
4363+ ty := Type . simplifyConditionalArray(ty);
4364+ exp := setType(ty, exp);
4365+ end if ;
4366+ then
4367+ ();
4368+
43584369 end match;
43594370 end retype;
43604371
Original file line number Diff line number Diff line change @@ -345,6 +345,22 @@ public
345345 end if ;
346346 end isMatchedBranch;
347347
348+ function simplifyConditionalArray
349+ input Type ty;
350+ output Type outType;
351+ algorithm
352+ outType := match ty
353+ case CONDITIONAL_ARRAY ()
354+ then match ty. matchedBranch
355+ case Branch . TRUE then ty. trueType;
356+ case Branch . FALSE then ty. falseType;
357+ else ty;
358+ end match;
359+
360+ else ty;
361+ end match;
362+ end simplifyConditionalArray;
363+
348364 function isVector
349365 "Return whether the type is a vector type or not, i.e. a 1-dimensional array."
350366 input Type ty;
You can’t perform that action at this time.
0 commit comments