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

Commit e2290c9

Browse files
perostOpenModelica-Hudson
authored andcommitted
Fix ComponentReference.expandCref.
- Pad the subscript list of partially subscripted crefs in expandCref with : to fill up all dimensions, to make if actually expand the crefs instead of only saying it did. The backend sometimes creates such crefs when using the NF, since it doesn't expand as much. Belonging to [master]: - #2472
1 parent a185205 commit e2290c9

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

Compiler/FrontEnd/ComponentReference.mo

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,6 +3157,7 @@ algorithm
31573157
DAE.ComponentRef cref;
31583158
list<DAE.ComponentRef> crefs, crefs2;
31593159
list<DAE.Var> varLst;
3160+
Integer missing_subs;
31603161

31613162
// A scalar record ident cref. Expand record true
31623163
case (DAE.CREF_IDENT(_, DAE.T_COMPLEX(varLst=varLst,complexClassType=ClassInf.RECORD(_)), {}),true)
@@ -3196,6 +3197,13 @@ algorithm
31963197
// Flatten T_ARRAY(T_ARRAY(T_COMPLEX(), dim2,src), dim1,src) types to one level T_ARRAY(simpletype, alldims, src)
31973198
(basety as DAE.T_COMPLEX(varLst=varLst,complexClassType=ClassInf.RECORD()), dims) = Types.flattenArrayType(ty);
31983199
correctTy = DAE.T_ARRAY(basety,dims);
3200+
3201+
// Pad the list of subscripts with : if necessary to fill out all dimensions.
3202+
missing_subs = listLength(dims) - listLength(subs);
3203+
if missing_subs > 0 then
3204+
subs = listAppend(subs, List.fill(DAE.WHOLEDIM(), missing_subs));
3205+
end if;
3206+
31993207
// Use the subscripts to generate only the wanted elements.
32003208
crefs = expandCref2(id, correctTy, subs, dims);
32013209
then
@@ -3207,6 +3215,12 @@ algorithm
32073215
// Flatten T_ARRAY(T_ARRAY(T_..., dim2,src), dim1,src) types to one level T_ARRAY(simpletype, alldims, src)
32083216
(basety, dims) = Types.flattenArrayType(ty);
32093217
correctTy = DAE.T_ARRAY(basety,dims);
3218+
3219+
// Pad the list of subscripts with : if necessary to fill out all dimensions.
3220+
missing_subs = listLength(dims) - listLength(subs);
3221+
if missing_subs > 0 then
3222+
subs = listAppend(subs, List.fill(DAE.WHOLEDIM(), missing_subs));
3223+
end if;
32103224
// Use the subscripts to generate only the wanted elements.
32113225
then
32123226
expandCref2(id, correctTy, subs, dims);

Compiler/NFFrontEnd/NFTyping.mo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,11 @@ protected
13231323
Subscript sub;
13241324
Variability var;
13251325
algorithm
1326+
if listEmpty(subscripts) then
1327+
typedSubs := subscripts;
1328+
return;
1329+
end if;
1330+
13261331
dims := Type.arrayDims(crefType);
13271332
typedSubs := {};
13281333
next_origin := intBitOr(origin, ExpOrigin.SUBSCRIPT);

0 commit comments

Comments
 (0)