@@ -215,7 +215,7 @@ algorithm
215215 (vars, sections) := match cls
216216 case Class . INSTANCED_BUILTIN ()
217217 then flattenSimpleComponent(comp_node, c, vis, cls. attributes, prefix, vars, sections);
218- else flattenComplexComponent(comp_node, cls, ty, vis, prefix, vars, sections);
218+ else flattenComplexComponent(comp_node, c, cls, ty, vis, prefix, vars, sections);
219219 end match;
220220 then
221221 ();
@@ -283,6 +283,7 @@ end flattenTypeAttribute;
283283
284284function flattenComplexComponent
285285 input InstNode node;
286+ input Component comp;
286287 input Class cls;
287288 input Type ty;
288289 input Visibility visibility;
@@ -292,12 +293,30 @@ function flattenComplexComponent
292293protected
293294 list< Dimension > dims;
294295 ComponentRef name;
296+ Binding binding;
297+ Expression binding_exp;
298+ Equation eq;
295299algorithm
296300 dims := Type . arrayDims(ty);
297301 name := ComponentRef . prefixCref(node, ty, {}, prefix);
298302
299303 // Flatten the class directly if the component is a scalar, otherwise scalarize it.
300304 if listEmpty(dims) then
305+ binding := Component . getBinding(comp);
306+
307+ if Binding . isBound(binding) then
308+ binding_exp := Binding . getTypedExp(binding);
309+
310+ if not Expression . isRecord(binding_exp) then
311+ eq := Equation . EQUALITY (Expression . CREF (ty, name), binding_exp, ty,
312+ ElementSource . createElementSource(InstNode . info(node)));
313+ sections := Sections . prependEquation(eq, sections);
314+ binding := Binding . UNBOUND ();
315+ else
316+ // TODO: Split record expressions and pass them to flattenClass.
317+ end if ;
318+ end if ;
319+
301320 (vars, sections) := flattenClass(cls, name, visibility, vars, sections);
302321 else
303322 (vars, sections) := flattenArray(cls, dims, name, visibility, vars, sections);
0 commit comments