@@ -161,6 +161,12 @@ public
161161 Type ty;
162162 end UNBOX ;
163163
164+ record SUBSCRIPTED_EXP
165+ Expression exp;
166+ list< Expression > subscripts;
167+ Type ty;
168+ end SUBSCRIPTED_EXP ;
169+
164170 record TUPLE_ELEMENT
165171 Expression tupleExp;
166172 Integer index;
@@ -393,6 +399,17 @@ public
393399 then
394400 compare(exp1. exp, e1);
395401
402+ case SUBSCRIPTED_EXP ()
403+ algorithm
404+ SUBSCRIPTED_EXP (exp = e1, subscripts = expl) := exp2;
405+ comp := compare(exp1. exp, e1);
406+
407+ if comp == 0 then
408+ comp := compareList(exp1. subscripts, expl);
409+ end if ;
410+ then
411+ comp;
412+
396413 case TUPLE_ELEMENT ()
397414 algorithm
398415 TUPLE_ELEMENT (tupleExp = e1, index = i) := exp2;
@@ -482,6 +499,7 @@ public
482499 case IF () then typeOf(exp. trueBranch);
483500 case CAST () then exp. ty;
484501 case UNBOX () then exp. ty;
502+ case SUBSCRIPTED_EXP () then exp. ty;
485503 case TUPLE_ELEMENT () then exp. ty;
486504 else Type . UNKNOWN ();
487505 end match;
@@ -564,6 +582,10 @@ public
564582 then
565583 CREF (Type . unliftArray(array. ty), cref);
566584
585+ case SUBSCRIPTED_EXP ()
586+ then SUBSCRIPTED_EXP (array. exp, listAppend(array. subscripts, {INTEGER (index)}), Type . unliftArray(array. ty));
587+
588+ else SUBSCRIPTED_EXP (array, {INTEGER (index)}, Type . unliftArray(typeOf(array)));
567589 end match;
568590 end arrayElement;
569591
@@ -689,6 +711,7 @@ public
689711
690712 case UNBOX () then "UNBOX(" + toString(exp. exp) + ")" ;
691713 case CAST () then "CAST(" + Type . toString(exp. ty) + ", " + toString(exp. exp) + ")" ;
714+ case SUBSCRIPTED_EXP () then toString(exp. exp) + "[" + stringDelimitList(list(toString(e) for e in exp. subscripts), ", " ) + "]" ;
692715 case TUPLE_ELEMENT () then toString(exp. tupleExp) + "[" + intString(exp. index) + "]" ;
693716
694717 else anyString(exp);
@@ -769,6 +792,9 @@ public
769792 case UNBOX ()
770793 then DAE . UNBOX (toDAE(exp. exp), Type . toDAE(exp. ty));
771794
795+ case SUBSCRIPTED_EXP ()
796+ then DAE . ASUB (toDAE(exp. exp), list(toDAE(s) for s in exp. subscripts));
797+
772798 case TUPLE_ELEMENT ()
773799 then DAE . TSUB (toDAE(exp. tupleExp), exp. index, Type . toDAE(exp. ty));
774800
@@ -792,6 +818,7 @@ public
792818 case RANGE () then Type . dimensionCount(exp. ty);
793819 case SIZE (dimIndex = NONE ()) then dimensionCount(exp. exp);
794820 case CAST () then dimensionCount(exp. exp);
821+ case SUBSCRIPTED_EXP () then Type . dimensionCount(exp. ty);
795822 case TUPLE_ELEMENT () then Type . dimensionCount(exp. ty);
796823 // TODO: Add more expressions.
797824 else 0 ;
@@ -908,6 +935,9 @@ public
908935 then
909936 if referenceEq(exp. exp, e1) then exp else UNBOX (e1, exp. ty);
910937
938+ case SUBSCRIPTED_EXP ()
939+ then SUBSCRIPTED_EXP (map(exp. exp, func ), list(map(e, func ) for e in exp. subscripts), exp. ty);
940+
911941 case TUPLE_ELEMENT ()
912942 algorithm
913943 e1 := map(exp. tupleExp, func );
@@ -995,6 +1025,18 @@ public
9951025 then
9961026 Call . TYPED_CALL (call. fn, args, call. attributes);
9971027
1028+ case Call . UNTYPED_MAP_CALL ()
1029+ algorithm
1030+ e := map(call. exp, func );
1031+ then
1032+ Call . UNTYPED_MAP_CALL (call. ref, e, call. iters);
1033+
1034+ case Call . TYPED_MAP_CALL ()
1035+ algorithm
1036+ e := map(call. exp, func );
1037+ then
1038+ Call . TYPED_MAP_CALL (call. fn, call. ty, e, call. iters);
1039+
9981040 end match;
9991041 end mapCall;
10001042
@@ -1114,6 +1156,13 @@ public
11141156
11151157 case CAST () then fold(exp. exp, func , arg);
11161158 case UNBOX () then fold(exp. exp, func , arg);
1159+
1160+ case SUBSCRIPTED_EXP ()
1161+ algorithm
1162+ result := fold(exp. exp, func , arg);
1163+ then
1164+ List . fold(exp. subscripts, func , result);
1165+
11171166 case TUPLE_ELEMENT () then fold(exp. tupleExp, func , arg);
11181167
11191168 else arg;
@@ -1167,6 +1216,18 @@ public
11671216 then
11681217 ();
11691218
1219+ case Call . UNTYPED_MAP_CALL ()
1220+ algorithm
1221+ arg := fold(call. exp, func , arg);
1222+ then
1223+ ();
1224+
1225+ case Call . TYPED_MAP_CALL ()
1226+ algorithm
1227+ arg := fold(call. exp, func , arg);
1228+ then
1229+ ();
1230+
11701231 end match;
11711232 end foldCall;
11721233
@@ -1345,6 +1406,13 @@ public
13451406 then
13461407 if referenceEq(exp. exp, e1) then exp else UNBOX (e1, exp. ty);
13471408
1409+ case SUBSCRIPTED_EXP ()
1410+ algorithm
1411+ (e1, arg) := mapFold(exp. exp, func , arg);
1412+ (expl, arg) := List . map1Fold(exp. subscripts, mapFold, func , arg);
1413+ then
1414+ SUBSCRIPTED_EXP (e1, expl, exp. ty);
1415+
13481416 case TUPLE_ELEMENT ()
13491417 algorithm
13501418 (e1, arg) := mapFold(exp. tupleExp, func , arg);
@@ -1437,6 +1505,18 @@ public
14371505 then
14381506 Call . TYPED_CALL (call. fn, args, call. attributes);
14391507
1508+ case Call . UNTYPED_MAP_CALL ()
1509+ algorithm
1510+ (e, foldArg) := mapFold(call. exp, func , foldArg);
1511+ then
1512+ Call . UNTYPED_MAP_CALL (call. ref, e, call. iters);
1513+
1514+ case Call . TYPED_MAP_CALL ()
1515+ algorithm
1516+ (e, foldArg) := mapFold(call. exp, func , foldArg);
1517+ then
1518+ Call . TYPED_MAP_CALL (call. fn, call. ty, e, call. iters);
1519+
14401520 end match;
14411521 end mapFoldCall;
14421522
0 commit comments