@@ -300,7 +300,7 @@ algorithm
300300
301301 // Fetch the needed information from the class definition and construct a DERIVED_CLASS.
302302 prefs := instClassPrefixes(def);
303- dims := list(Dimension . RAW_DIM (d) for d in cdef . attributes . arrayDims );
303+ dims := list(Dimension . RAW_DIM (d) for d in Absyn . typeSpecDimensions(ty) );
304304 mod := Class . getModifier(InstNode . getClass(node));
305305 c := Class . DERIVED_CLASS (ext_node, mod, dims, prefs, cdef. attributes. direction);
306306 node := InstNode . updateClass(c, node);
@@ -516,6 +516,7 @@ protected
516516 ClassTree cls_tree;
517517 Modifier cls_mod, mod;
518518 list< Modifier > type_attr;
519+ list< Dimension > dims;
519520algorithm
520521 cls := InstNode . getClass(node);
521522 cls_mod := Class . getModifier(cls);
@@ -568,7 +569,8 @@ algorithm
568569 algorithm
569570 mod := Modifier . fromElement(InstNode . definition(node), InstNode . parent(node));
570571 mod := Modifier . merge(cls_mod, mod);
571- node := instClass(cls. baseClass, mod, parent);
572+ cls. baseClass := instClass(cls. baseClass, mod, parent);
573+ node := InstNode . replaceClass(cls, node);
572574 then
573575 ();
574576
@@ -923,6 +925,18 @@ algorithm
923925 then
924926 ();
925927
928+ case Class . DERIVED_CLASS ()
929+ algorithm
930+ sections := instExpressions(cls. baseClass, scope, sections);
931+
932+ if not listEmpty(cls. dims) then
933+ cls. dims := list(instDimension(d, InstNode . parent(node), InstNode . info(node))
934+ for d in cls. dims);
935+ InstNode . updateClass(cls, node);
936+ end if ;
937+ then
938+ ();
939+
926940 case Class . INSTANCED_BUILTIN ()
927941 algorithm
928942 cls. attributes := list(instBuiltinAttribute(a) for a in cls. attributes);
@@ -958,18 +972,45 @@ function instComponentExpressions
958972 input InstNode scope;
959973protected
960974 Component c = InstNode . component(component);
961- array< Dimension > dims;
975+ array< Dimension > dims, all_dims;
976+ list< Dimension > cls_dims;
977+ Integer len;
962978algorithm
963979 () := match c
964980 case Component . UNTYPED_COMPONENT (dimensions = dims)
965981 algorithm
966982 c. binding := instBinding(c. binding);
983+ instExpressions(c. classInst, component);
967984
968- for i in 1 :arrayLength(dims) loop
969- dims[i] := instDimension(dims[i], scope, c. info);
970- end for ;
985+ cls_dims := Class . getDimensions(InstNode . getClass(c. classInst));
986+ len := arrayLength(dims);
987+
988+ if listEmpty(cls_dims) then
989+ // If we have no type dimensions, simply instantiate the component's dimensions.
990+ for i in 1 :len loop
991+ dims[i] := instDimension(dims[i], scope, c. info);
992+ end for ;
993+ else
994+ // If we have type dimensions, allocate space for them and add them to
995+ // the component's dimensions.
996+ all_dims := Dangerous . arrayCreateNoInit(len + listLength(cls_dims), Dimension . UNKNOWN ());
997+
998+ // Instantiate the component's dimensions.
999+ for i in 1 :len loop
1000+ all_dims[i] := instDimension(dims[i], scope, c. info);
1001+ end for ;
1002+
1003+ // Add the already instantiated dimensions from the type.
1004+ len := len + 1 ;
1005+ for e in cls_dims loop
1006+ all_dims[len] := e;
1007+ len := len + 1 ;
1008+ end for ;
1009+
1010+ // Update the dimensions in the component.
1011+ c. dimensions := all_dims;
1012+ end if ;
9711013
972- instExpressions(c. classInst, component);
9731014 InstNode . updateComponent(c, component);
9741015 then
9751016 ();
0 commit comments