@@ -701,9 +701,11 @@ algorithm
701701 DAE . ElementSource src;
702702 DAE . Exp e1, e2;
703703 DAE . Dimensions dims;
704+ DAE . Type tp;
704705 BackendDAE . EquationAttributes attr;
705706 BackendDAE . Var var ;
706707 list< BackendDAE . Equation > assert_eqs;
708+ Option < Integer > recordSize;
707709
708710 // external object variables
709711 case DAE . VAR (ty = DAE . T_COMPLEX (complexClassType = ClassInf . EXTERNAL_OBJ ()))
@@ -719,11 +721,17 @@ algorithm
719721 outVars := lowerDynamicVar(inElement, inFunctions) :: outVars;
720722 e1 := Expression . crefExp(cr);
721723 attr := BackendDAE . EQ_ATTR_DEFAULT_BINDING ;
722- (_, dims) := ComponentReference . crefTypeFull2(cr);
724+ (tp, dims) := ComponentReference . crefTypeFull2(cr);
725+ tp := DAEUtil . expTypeElementType(tp);
726+ if DAEUtil . expTypeComplex(tp) then
727+ recordSize := SOME (Expression . sizeOf(tp));
728+ else
729+ recordSize := NONE ();
730+ end if ;
723731 if listEmpty(dims) then
724732 outEqns := BackendDAE . EQUATION (e1, e2, src, attr) :: outEqns;
725733 else
726- outEqns := BackendDAE . ARRAY_EQUATION (Expression . dimensionsSizes(dims), e1, e2, src, attr) :: outEqns;
734+ outEqns := BackendDAE . ARRAY_EQUATION (Expression . dimensionsSizes(dims), e1, e2, src, attr, recordSize ) :: outEqns;
727735 end if ;
728736 then
729737 ();
@@ -1840,40 +1848,26 @@ protected function lowerArrayEqn "author: Frenkel TUD 2012-06"
18401848 input BackendDAE . EquationAttributes inEqAttributes;
18411849 input list< BackendDAE . Equation > iAcc;
18421850 output list< BackendDAE . Equation > outEqsLst;
1843- algorithm
1844- outEqsLst := matchcontinue (dims, e1, e2, source, inEqAttributes, iAcc)
1845- local
1846- list< DAE . Exp > ea1, ea2;
1847- list< Integer > ds;
1848- DAE . Type tp;
1849- Integer i;
1850-
1851- // array type with record
1852- case (_, _, _, _, _, _)
1853- equation
1854- tp = Expression . typeof(e1);
1855- tp = DAEUtil . expTypeElementType(tp);
1856- true = DAEUtil . expTypeComplex(tp);
1857- i = Expression . sizeOf(tp);
1858- ds = Expression . dimensionsSizes(dims);
1859- ds = List . map1(ds, intMul, i);
1860- // For COMPLEX_EQUATION
1861- // i = List.fold(ds, intMul, 1);
1862- then BackendDAE . ARRAY_EQUATION (ds, e1, e2, source, inEqAttributes)::iAcc;
1863-
1864- case (_, _, _, _, _, _)
1865- equation
1866- true = Expression . isArray(e1) or Expression . isMatrix(e1);
1867- true = Expression . isArray(e2) or Expression . isMatrix(e2);
1868- ea1 = Expression . flattenArrayExpToList(e1);
1869- ea2 = Expression . flattenArrayExpToList(e2);
1870- then generateEquations(ea1, ea2, source, inEqAttributes, iAcc);
1871-
1872- case (_, _, _, _, _, _)
1873- equation
1874- ds = Expression . dimensionsSizes(dims);
1875- then BackendDAE . ARRAY_EQUATION (ds, e1, e2, source, inEqAttributes)::iAcc;
1876- end matchcontinue;
1851+ protected
1852+ list< Integer > dimensions;
1853+ list< DAE . Exp > ea1,ea2;
1854+ DAE . Type tp;
1855+ Integer recordSize;
1856+ algorithm
1857+ tp := Expression . typeof(e1);
1858+ tp := DAEUtil . expTypeElementType(tp);
1859+ if DAEUtil . expTypeComplex(tp) then
1860+ recordSize := Expression . sizeOf(tp);
1861+ dimensions := Expression . dimensionsSizes(dims);
1862+ outEqsLst := BackendDAE . ARRAY_EQUATION (dimensions, e1, e2, source, inEqAttributes,SOME (recordSize))::iAcc;
1863+ elseif (Expression . isArray(e1) or Expression . isMatrix(e1)) and (Expression . isArray(e2) or Expression . isMatrix(e2)) then
1864+ ea1 := Expression . flattenArrayExpToList(e1);
1865+ ea2 := Expression . flattenArrayExpToList(e2);
1866+ outEqsLst := generateEquations(ea1, ea2, source, inEqAttributes, iAcc);
1867+ else
1868+ dimensions := Expression . dimensionsSizes(dims);
1869+ outEqsLst := BackendDAE . ARRAY_EQUATION (dimensions, e1, e2, source, inEqAttributes, NONE ())::iAcc;
1870+ end if ;
18771871end lowerArrayEqn;
18781872
18791873protected function generateEquations "author: Frenkel TUD 2012-06"
0 commit comments