@@ -204,13 +204,20 @@ public
204204 output Integer hash = ComponentRef . hash(conn. name, mod);
205205 end hash;
206206
207+ type ScalarizeSetting = enumeration(
208+ NONE "a[2].b[2] => {a[2].b[2]}" ,
209+ PREFIX "a[2].b[2] => {a[1].b[2], a[2].b[2]}" ,
210+ ALL "a[2].b[2] => {a[1].b[1], a[1].b[2], a[2].b[1], a[2].b[2]}"
211+ );
212+
207213 function split
208214 "Splits a connector into its primitive components."
209215 input Connector conn;
210- input Boolean splitArrays = Flags . isSet(Flags . NF_SCALARIZE );
216+ input ScalarizeSetting scalarize = if Flags . isSet(Flags . NF_SCALARIZE ) then
217+ ScalarizeSetting . ALL else ScalarizeSetting . NONE ;
211218 output list< Connector > connl;
212219 algorithm
213- connl := splitImpl(conn. name, conn. ty, conn. face, conn. source, conn. cty, splitArrays );
220+ connl := splitImpl(conn. name, conn. ty, conn. face, conn. source, conn. cty, scalarize );
214221 end split;
215222
216223protected
@@ -236,21 +243,21 @@ protected
236243 input Face face;
237244 input DAE . ElementSource source;
238245 input ConnectorType . Type cty;
239- input Boolean splitArrays ;
246+ input ScalarizeSetting scalarize ;
240247 input output list< Connector > conns = {};
241248 input list< Dimension > dims = {} "accumulated dimensions if splitArrays = false" ;
242249 algorithm
243250 conns := match ty
244251 local
245- Type t ;
252+ Type ety ;
246253 ComplexType ct;
247254 ClassTree tree;
248255
249256 case Type . COMPLEX (complexTy = ct as ComplexType . CONNECTOR ())
250257 algorithm
251- conns := splitImpl2(name, face, source, ct. potentials, splitArrays , conns, dims);
252- conns := splitImpl2(name, face, source, ct. flows, splitArrays , conns, dims);
253- conns := splitImpl2(name, face, source, ct. streams, splitArrays , conns, dims);
258+ conns := splitImpl2(name, face, source, ct. potentials, scalarize , conns, dims);
259+ conns := splitImpl2(name, face, source, ct. flows, scalarize , conns, dims);
260+ conns := splitImpl2(name, face, source, ct. streams, scalarize , conns, dims);
254261 then
255262 conns;
256263
@@ -261,20 +268,28 @@ protected
261268 algorithm
262269 tree := Class . classTree(InstNode . getClass(ty. cls));
263270 conns := splitImpl2(name, face, source,
264- arrayList(ClassTree . getComponents(tree)), splitArrays, conns, dims);
271+ arrayList(ClassTree . getComponents(tree)), scalarize, conns, dims);
272+ then
273+ conns;
274+
275+ case Type . ARRAY (elementType = ety as Type . COMPLEX ())
276+ guard scalarize >= ScalarizeSetting . PREFIX
277+ algorithm
278+ for c in ComponentRef . scalarize(name) loop
279+ conns := splitImpl(c, ety, face, source, cty, scalarize, conns, dims);
280+ end for ;
265281 then
266282 conns;
267283
268- case Type . ARRAY ()
284+ case Type . ARRAY (elementType = ety )
269285 algorithm
270- t := Type . arrayElementType(ty);
271- if splitArrays then
286+ if scalarize == ScalarizeSetting . ALL then
272287 for c in ComponentRef . scalarize(name) loop
273- conns := splitImpl(c, t , face, source, cty, splitArrays , conns, dims);
288+ conns := splitImpl(c, ety , face, source, cty, scalarize , conns, dims);
274289 end for ;
275290 else
276291 if not Type . isEmptyArray(ty) then
277- conns := splitImpl(name, t , face, source, cty, splitArrays , conns,
292+ conns := splitImpl(name, ety , face, source, cty, scalarize , conns,
278293 listAppend(dims, ty. dimensions));
279294 end if ;
280295 end if ;
@@ -290,7 +305,7 @@ protected
290305 input Face face;
291306 input DAE . ElementSource source;
292307 input list< InstNode > comps;
293- input Boolean splitArrays ;
308+ input ScalarizeSetting scalarize ;
294309 input output list< Connector > conns;
295310 input list< Dimension > dims;
296311 protected
@@ -306,7 +321,7 @@ protected
306321
307322 if not ConnectorType . isPotentiallyPresent(cty) then
308323 cref := ComponentRef . append(ComponentRef . fromNode(comp, ty), name);
309- conns := splitImpl(cref, ty, face, source, cty, splitArrays , conns, dims);
324+ conns := splitImpl(cref, ty, face, source, cty, scalarize , conns, dims);
310325 end if ;
311326 end for ;
312327 end splitImpl2;
0 commit comments