@@ -1556,6 +1556,8 @@ protected
15561556 Integer var_arr_idx, var_start;
15571557 list< Integer > sizes;
15581558 list< Expression > subs;
1559+ Type ty;
1560+ Integer complex_size;
15591561 algorithm
15601562 // try to get array index, if it fails, strip the subscripts
15611563 (var_arr_idx, c) := match UnorderedMap . get(cref, map)
@@ -1567,7 +1569,17 @@ protected
15671569 (var_start, _) := mapping. var_AtS[var_arr_idx];
15681570 sizes := ComponentRef . sizes(c, false );
15691571 subs := ComponentRef . subscriptsToExpression(cref, true );
1570- scal_lst := listReverse(combineFrames2Indices(var_start, sizes, subs, frames, UnorderedMap . new< Expression > (ComponentRef . hash, ComponentRef . isEqual)));
1572+ ty := Type . arrayElementType(ComponentRef . getComponentType(cref));
1573+ if Type . isComplex(ty) then
1574+ // if the cref is complex, loop over each child and add it
1575+ scal_lst := {};
1576+ SOME (complex_size) := Type . complexSize(ty);
1577+ for i in complex_size:-1 :1 loop
1578+ scal_lst := listAppend(listReverse(combineFrames2Indices(var_start, complex_size :: sizes, Expression . INTEGER (i) :: subs, frames, UnorderedMap . new< Expression > (ComponentRef . hash, ComponentRef . isEqual))), scal_lst);
1579+ end for ;
1580+ else
1581+ scal_lst := listReverse(combineFrames2Indices(var_start, sizes, subs, frames, UnorderedMap . new< Expression > (ComponentRef . hash, ComponentRef . isEqual)));
1582+ end if ;
15711583 end getCrefInFrameIndices;
15721584
15731585 function resolveDimensionsSubscripts
0 commit comments