@@ -931,23 +931,12 @@ algorithm
931931 ComponentRef cref;
932932 Integer next_origin;
933933
934- case Expression . INTEGER () then (exp, Type . INTEGER (), Variability . CONSTANT );
935- case Expression . REAL () then (exp, Type . REAL (), Variability . CONSTANT );
936- case Expression . STRING () then (exp, Type . STRING (), Variability . CONSTANT );
937- case Expression . BOOLEAN () then (exp, Type . BOOLEAN (), Variability . CONSTANT );
938- case Expression . ENUM_LITERAL () then (exp, exp. ty, Variability . CONSTANT );
939-
940- case Expression . CREF ()
941- algorithm
942- (cref, ty, variability) := typeCref(exp. cref, origin, info);
943- e1 := Expression . CREF (ty, cref);
944-
945- if replaceConstants and variability <= Variability . STRUCTURAL_PARAMETER and
946- not Expression . containsIterator(e1, origin) then
947- e1 := Ceval . evalExp(e1, Ceval . EvalTarget . GENERIC (info));
948- end if ;
949- then
950- (e1, ty, variability);
934+ case Expression . INTEGER () then (exp, Type . INTEGER (), Variability . CONSTANT );
935+ case Expression . REAL () then (exp, Type . REAL (), Variability . CONSTANT );
936+ case Expression . STRING () then (exp, Type . STRING (), Variability . CONSTANT );
937+ case Expression . BOOLEAN () then (exp, Type . BOOLEAN (), Variability . CONSTANT );
938+ case Expression . ENUM_LITERAL () then (exp, exp. ty, Variability . CONSTANT );
939+ case Expression . CREF () then typeCrefExp(exp. cref, origin, info, replaceConstants);
951940
952941 case Expression . TYPENAME ()
953942 algorithm
@@ -959,11 +948,11 @@ algorithm
959948 then
960949 (exp, exp. ty, Variability . CONSTANT );
961950
962- case Expression . ARRAY () then typeArray(exp. elements, origin, info);
951+ case Expression . ARRAY () then typeArray(exp. elements, origin, info);
963952 case Expression . MATRIX () then typeMatrix(exp. elements, origin, info);
964- case Expression . RANGE () then typeRange(exp, origin, info);
965- case Expression . TUPLE () then typeTuple(exp. elements, origin, info);
966- case Expression . SIZE () then typeSize(exp, origin, info);
953+ case Expression . RANGE () then typeRange(exp, origin, info);
954+ case Expression . TUPLE () then typeTuple(exp. elements, origin, info);
955+ case Expression . SIZE () then typeSize(exp, origin, info);
967956
968957 case Expression . END ()
969958 algorithm
@@ -1245,12 +1234,42 @@ algorithm
12451234 end if ;
12461235end nthDimensionBoundsChecked;
12471236
1237+ function typeCrefExp
1238+ input ComponentRef cref;
1239+ input ExpOrigin . Type origin;
1240+ input SourceInfo info;
1241+ input Boolean replaceConstants;
1242+ output Expression exp;
1243+ output Type ty;
1244+ output Variability variability;
1245+ protected
1246+ ComponentRef cr;
1247+ Variability node_var, subs_var;
1248+ Boolean eval;
1249+ algorithm
1250+ (cr, ty, node_var, subs_var) := typeCref(cref, origin, info);
1251+ exp := Expression . CREF (ty, cr);
1252+
1253+ if replaceConstants and node_var <= Variability . STRUCTURAL_PARAMETER and
1254+ not ComponentRef . isIterator(cr) then
1255+ (exp, eval) := Ceval . evalComponentBinding(ComponentRef . node(cr), exp,
1256+ Ceval . EvalTarget . IGNORE_ERRORS ());
1257+
1258+ if eval then
1259+ exp := Expression . applySubscripts(ComponentRef . getSubscripts(cr), exp);
1260+ end if ;
1261+ end if ;
1262+
1263+ variability := Prefixes . variabilityMax(node_var, subs_var);
1264+ end typeCrefExp;
1265+
12481266function typeCref
12491267 input output ComponentRef cref;
12501268 input ExpOrigin . Type origin;
12511269 input SourceInfo info;
12521270 output Type ty;
1253- output Variability variability;
1271+ output Variability nodeVariability;
1272+ output Variability subsVariability;
12541273protected
12551274 Variability subs_var;
12561275algorithm
@@ -1263,9 +1282,9 @@ algorithm
12631282 fail();
12641283 end if ;
12651284
1266- (cref, subs_var ) := typeCref2(cref, origin, info);
1285+ (cref, subsVariability ) := typeCref2(cref, origin, info);
12671286 ty := ComponentRef . getSubscriptedType(cref);
1268- variability := Prefixes . variabilityMax( ComponentRef . nodeVariability(cref), subs_var );
1287+ nodeVariability := ComponentRef . nodeVariability(cref);
12691288end typeCref;
12701289
12711290function typeCref2
0 commit comments