diff --git a/OMCompiler/Compiler/BackEnd/BackendDAE.mo b/OMCompiler/Compiler/BackEnd/BackendDAE.mo index d1dd850585a..bc2046a95a0 100644 --- a/OMCompiler/Compiler/BackEnd/BackendDAE.mo +++ b/OMCompiler/Compiler/BackEnd/BackendDAE.mo @@ -362,6 +362,7 @@ uniontype Equation .DAE.Exp right "rhs"; .DAE.ElementSource source "origin of equation"; EquationAttributes attr; + Option recordSize "NONE() if not a record"; end ARRAY_EQUATION; record SOLVED_EQUATION diff --git a/OMCompiler/Compiler/BackEnd/BackendDAECreate.mo b/OMCompiler/Compiler/BackEnd/BackendDAECreate.mo index cd494ff3218..2155236cbf9 100644 --- a/OMCompiler/Compiler/BackEnd/BackendDAECreate.mo +++ b/OMCompiler/Compiler/BackEnd/BackendDAECreate.mo @@ -701,9 +701,11 @@ algorithm DAE.ElementSource src; DAE.Exp e1, e2; DAE.Dimensions dims; + DAE.Type tp; BackendDAE.EquationAttributes attr; BackendDAE.Var var; list assert_eqs; + Option recordSize; // external object variables case DAE.VAR(ty = DAE.T_COMPLEX(complexClassType = ClassInf.EXTERNAL_OBJ())) @@ -719,11 +721,17 @@ algorithm outVars := lowerDynamicVar(inElement, inFunctions) :: outVars; e1 := Expression.crefExp(cr); attr := BackendDAE.EQ_ATTR_DEFAULT_BINDING; - (_, dims) := ComponentReference.crefTypeFull2(cr); + (tp, dims) := ComponentReference.crefTypeFull2(cr); + tp := DAEUtil.expTypeElementType(tp); + if DAEUtil.expTypeComplex(tp) then + recordSize := SOME(Expression.sizeOf(tp)); + else + recordSize := NONE(); + end if; if listEmpty(dims) then outEqns := BackendDAE.EQUATION(e1, e2, src, attr) :: outEqns; else - outEqns := BackendDAE.ARRAY_EQUATION(Expression.dimensionsSizes(dims), e1, e2, src, attr) :: outEqns; + outEqns := BackendDAE.ARRAY_EQUATION(Expression.dimensionsSizes(dims), e1, e2, src, attr, recordSize) :: outEqns; end if; then (); @@ -1840,40 +1848,26 @@ protected function lowerArrayEqn "author: Frenkel TUD 2012-06" input BackendDAE.EquationAttributes inEqAttributes; input list iAcc; output list outEqsLst; -algorithm - outEqsLst := matchcontinue (dims, e1, e2, source, inEqAttributes, iAcc) - local - list ea1, ea2; - list ds; - DAE.Type tp; - Integer i; - - // array type with record - case (_, _, _, _, _, _) - equation - tp = Expression.typeof(e1); - tp = DAEUtil.expTypeElementType(tp); - true = DAEUtil.expTypeComplex(tp); - i = Expression.sizeOf(tp); - ds = Expression.dimensionsSizes(dims); - ds = List.map1(ds, intMul, i); - //For COMPLEX_EQUATION - //i = List.fold(ds, intMul, 1); - then BackendDAE.ARRAY_EQUATION(ds, e1, e2, source, inEqAttributes)::iAcc; - - case (_, _, _, _, _, _) - equation - true = Expression.isArray(e1) or Expression.isMatrix(e1); - true = Expression.isArray(e2) or Expression.isMatrix(e2); - ea1 = Expression.flattenArrayExpToList(e1); - ea2 = Expression.flattenArrayExpToList(e2); - then generateEquations(ea1, ea2, source, inEqAttributes, iAcc); - - case (_, _, _, _, _, _) - equation - ds = Expression.dimensionsSizes(dims); - then BackendDAE.ARRAY_EQUATION(ds, e1, e2, source, inEqAttributes)::iAcc; - end matchcontinue; +protected + list dimensions; + list ea1,ea2; + DAE.Type tp; + Integer recordSize; +algorithm + tp := Expression.typeof(e1); + tp := DAEUtil.expTypeElementType(tp); + if DAEUtil.expTypeComplex(tp) then + recordSize := Expression.sizeOf(tp); + dimensions := Expression.dimensionsSizes(dims); + outEqsLst := BackendDAE.ARRAY_EQUATION(dimensions, e1, e2, source, inEqAttributes,SOME(recordSize))::iAcc; + elseif (Expression.isArray(e1) or Expression.isMatrix(e1)) and (Expression.isArray(e2) or Expression.isMatrix(e2)) then + ea1 := Expression.flattenArrayExpToList(e1); + ea2 := Expression.flattenArrayExpToList(e2); + outEqsLst := generateEquations(ea1, ea2, source, inEqAttributes, iAcc); + else + dimensions := Expression.dimensionsSizes(dims); + outEqsLst := BackendDAE.ARRAY_EQUATION(dimensions, e1, e2, source, inEqAttributes, NONE())::iAcc; + end if; end lowerArrayEqn; protected function generateEquations "author: Frenkel TUD 2012-06" diff --git a/OMCompiler/Compiler/BackEnd/BackendDAETransform.mo b/OMCompiler/Compiler/BackEnd/BackendDAETransform.mo index b13dcd2b1fb..cfffdbe4913 100644 --- a/OMCompiler/Compiler/BackEnd/BackendDAETransform.mo +++ b/OMCompiler/Compiler/BackEnd/BackendDAETransform.mo @@ -568,6 +568,7 @@ algorithm DAE.Exp iter, start, stop; DAE.ComponentRef cr, cr1; Integer size; + Option recordSize; list expl; BackendDAE.Equation eqn; BackendDAE.WhenEquation elsepartRes; @@ -591,11 +592,11 @@ algorithm then (BackendDAE.EQUATION(e1_1, e2_1, source, eqAttr), ext_arg_2); // Array equation - case BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left = e1, right = e2, source = source, attr=eqAttr) equation + case BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left = e1, right = e2, source = source, attr=eqAttr, recordSize=recordSize) equation (e1_1, (ops, ext_arg_1)) = func(e1, ({}, inTypeA)); (e2_1, (ops, ext_arg_2)) = func(e2, (ops, ext_arg_1)); source = List.foldr(ops, ElementSource.addSymbolicTransformation, source); - then (BackendDAE.ARRAY_EQUATION(dimSize, e1_1, e2_1, source, eqAttr), ext_arg_2); + then (BackendDAE.ARRAY_EQUATION(dimSize, e1_1, e2_1, source, eqAttr, recordSize), ext_arg_2); case BackendDAE.FOR_EQUATION(iter = iter, start = start, stop = stop, body = eqn, source = source, attr = eqAttr) equation (eqn, outTypeA) = traverseBackendDAEExpsEqnWithSymbolicOperation(eqn, func, inTypeA); diff --git a/OMCompiler/Compiler/BackEnd/BackendEquation.mo b/OMCompiler/Compiler/BackEnd/BackendEquation.mo index ee46af62bc4..ac94f07b01e 100644 --- a/OMCompiler/Compiler/BackEnd/BackendEquation.mo +++ b/OMCompiler/Compiler/BackEnd/BackendEquation.mo @@ -813,68 +813,76 @@ public function traverseExpsOfEquation "author: Frenkel TUD 2010-11 input output T inoutTypeA; end FuncExpType; algorithm - (outEquation, outTypeA) := match(inEquation) + (outEquation, outTypeA) := match inEquation local - DAE.Exp e1, e2, e_1, e_2, start, stop, iter; - list expl; - DAE.Type tp; + BackendDAE.Equation eqn, eqn1; + BackendDAE.WhenEquation whenEquation; + DAE.Exp e1; DAE.ComponentRef cr, cr1; - BackendDAE.Equation eqn; - BackendDAE.WhenEquation we, we_1; - DAE.ElementSource source; - Integer size; T extArg; - list dimSize; - DAE.Algorithm alg; - list stmts, stmts1; - list eqns; - list> eqnslst; - DAE.Expand crefExpand; - BackendDAE.EquationAttributes attr; + list stmts; + list conditions; + list> eqnstrue; + list eqnsfalse; - case BackendDAE.EQUATION(exp=e1, scalar=e2, source=source, attr=attr) equation - (e_1, extArg) = inFunc(e1, inTypeA); - (e_2, extArg) = inFunc(e2, extArg); - then (if referenceEq(e1,e_1) and referenceEq(e2,e_2) then inEquation else BackendDAE.EQUATION(e_1, e_2, source, attr), extArg); - case BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left=e1, right=e2, source=source, attr=attr) equation - (e_1, extArg) = inFunc(e1, inTypeA); - (e_2, extArg) = inFunc(e2, extArg); - then (if referenceEq(e1,e_1) and referenceEq(e2,e_2) then inEquation else BackendDAE.ARRAY_EQUATION(dimSize, e_1, e_2, source, attr), extArg); + case eqn as BackendDAE.EQUATION() algorithm + (e1, extArg) := inFunc(eqn.exp, inTypeA); + eqn.exp := e1; + (e1, extArg) := inFunc(eqn.scalar, extArg); + eqn.scalar := e1; + then (eqn, extArg); - case BackendDAE.SOLVED_EQUATION(componentRef=cr, exp=e2, source=source, attr=attr) equation - tp = Expression.typeof(e2); - e1 = Expression.makeCrefExp(cr, tp); + case eqn as BackendDAE.ARRAY_EQUATION() equation + (e1, extArg) = inFunc(eqn.left, inTypeA); + eqn.left = e1; + (e1, extArg) = inFunc(eqn.right, extArg); + eqn.right = e1; + then (eqn, extArg); + + case eqn as BackendDAE.SOLVED_EQUATION(componentRef = cr) equation + e1 = Expression.makeCrefExp(cr, Expression.typeof(eqn.exp)); (DAE.CREF(cr1, _), extArg) = inFunc(e1, inTypeA); - (e_2, extArg) = inFunc(e2, extArg); - then (if referenceEq(cr,cr1) and referenceEq(e2,e_2) then inEquation else BackendDAE.SOLVED_EQUATION(cr1, e_2, source, attr), extArg); - - case BackendDAE.RESIDUAL_EQUATION(exp=e1, source=source, attr=attr) equation - (e_1, extArg) = inFunc(e1, inTypeA); - then (if referenceEq(e1,e_1) then inEquation else BackendDAE.RESIDUAL_EQUATION(e_1, source, attr), extArg); - - case BackendDAE.WHEN_EQUATION(size=size, whenEquation= we, source=source, attr=attr) equation - (we_1, extArg) = traverseExpsOfWhenEquation(we, inFunc, inTypeA); - then (if referenceEq(we,we_1) then inEquation else BackendDAE.WHEN_EQUATION(size, we_1, source, attr), extArg); - - case BackendDAE.ALGORITHM(size=size, alg=DAE.ALGORITHM_STMTS(statementLst = stmts), source=source, expand=crefExpand, attr=attr) equation - (stmts1, extArg) = DAEUtil.traverseDAEEquationsStmts(stmts, inFunc, inTypeA); - then (if referenceEq(stmts,stmts1) then inEquation else BackendDAE.ALGORITHM(size, DAE.ALGORITHM_STMTS(stmts1), source, crefExpand, attr), extArg); - - case BackendDAE.COMPLEX_EQUATION(size=size, left=e1, right=e2, source=source, attr=attr) equation - (e_1, extArg) = inFunc(e1, inTypeA); - (e_2, extArg) = inFunc(e2, extArg); - then (if referenceEq(e1,e_1) and referenceEq(e2,e_2) then inEquation else BackendDAE.COMPLEX_EQUATION(size, e_1, e_2, source, attr), extArg); - - case BackendDAE.IF_EQUATION(conditions=expl, eqnstrue=eqnslst, eqnsfalse=eqns, source=source, attr=attr) equation - (expl, extArg) = traverseExpsOfExpList(expl, inFunc, inTypeA); - (eqnslst, extArg) = List.map1Fold(eqnslst, traverseExpsOfEquationList, inFunc, extArg); - (eqns, extArg) = List.map1Fold(eqns, traverseExpsOfEquation, inFunc, extArg); - then (BackendDAE.IF_EQUATION(expl, eqnslst, eqns, source, attr), extArg); - - case BackendDAE.FOR_EQUATION(iter = iter, start = start, stop = stop, source = source, attr = attr) equation - (eqn, extArg) = traverseExpsOfEquation(inEquation.body, inFunc, inTypeA); - then (BackendDAE.FOR_EQUATION(iter, start, stop, eqn, source, attr), extArg); + eqn.componentRef = cr1; + (e1, extArg) = inFunc(eqn.exp, extArg); + eqn.exp = e1; + then (eqn, extArg); + + case eqn as BackendDAE.RESIDUAL_EQUATION() equation + (e1, extArg) = inFunc(eqn.exp, inTypeA); + eqn.exp = e1; + then (eqn, extArg); + + case eqn as BackendDAE.WHEN_EQUATION() equation + (whenEquation, extArg) = traverseExpsOfWhenEquation(eqn.whenEquation, inFunc, inTypeA); + eqn.whenEquation = whenEquation; + then (eqn, extArg); + + case eqn as BackendDAE.ALGORITHM(alg=DAE.ALGORITHM_STMTS(statementLst = stmts)) equation + (stmts, extArg) = DAEUtil.traverseDAEEquationsStmts(stmts, inFunc, inTypeA); + eqn.alg = DAE.ALGORITHM_STMTS(stmts); + then (eqn, extArg); + + case eqn as BackendDAE.COMPLEX_EQUATION() equation + (e1, extArg) = inFunc(eqn.left, inTypeA); + eqn.left = e1; + (e1, extArg) = inFunc(eqn.right, extArg); + eqn.right = e1; + then (eqn, extArg); + + case eqn as BackendDAE.IF_EQUATION() equation + (conditions, extArg) = traverseExpsOfExpList(eqn.conditions, inFunc, inTypeA); + eqn.conditions = conditions; + (eqnstrue, extArg) = List.map1Fold(eqn.eqnstrue, traverseExpsOfEquationList, inFunc, extArg); + eqn.eqnstrue = eqnstrue; + (eqnsfalse, extArg) = List.map1Fold(eqn.eqnsfalse, traverseExpsOfEquation, inFunc, extArg); + eqn.eqnsfalse = eqnsfalse; + then (eqn, extArg); + + case eqn as BackendDAE.FOR_EQUATION() equation + (eqn1, extArg) = traverseExpsOfEquation(eqn.body, inFunc, inTypeA); + eqn.body = eqn1; + then (eqn, extArg); end match; end traverseExpsOfEquation; @@ -1727,13 +1735,17 @@ algorithm osize := match eq local list ds; - Integer size, start, stop; + Integer size, start, stop, recordSize; list eqnsfalse; case BackendDAE.EQUATION() then 1; - case BackendDAE.ARRAY_EQUATION(dimSize=ds) equation + case BackendDAE.ARRAY_EQUATION(dimSize=ds,recordSize=SOME(recordSize)) equation + size = List.fold(ds, intMul, 1) * recordSize; + then size; + + case BackendDAE.ARRAY_EQUATION(dimSize=ds,recordSize=NONE()) equation size = List.fold(ds, intMul, 1); then size; @@ -1959,12 +1971,13 @@ public function generateEquation "author Frenkel TUD 2012-12 input BackendDAE.EquationAttributes inEqAttr = BackendDAE.EQ_ATTR_DEFAULT_UNKNOWN; output BackendDAE.Equation outEqn; protected - DAE.Type ty; + DAE.Type ty,tp; algorithm ty := Expression.typeof(lhs); outEqn := match () local Integer size; + Option recordSize; DAE.Dimensions dims; list ds; Boolean b1, b2; @@ -1980,9 +1993,16 @@ algorithm case () guard DAEUtil.expTypeArray(ty) equation + tp = Expression.typeof(lhs); + tp = DAEUtil.expTypeElementType(tp); + if DAEUtil.expTypeComplex(tp) then + recordSize = SOME(Expression.sizeOf(tp)); + else + recordSize = NONE(); + end if; dims = Expression.arrayDimension(ty); ds = Expression.dimensionsSizes(dims); - then BackendDAE.ARRAY_EQUATION(ds, lhs, rhs, source, inEqAttr); + then BackendDAE.ARRAY_EQUATION(ds, lhs, rhs, source, inEqAttr, recordSize); // other types case () guard @@ -2046,6 +2066,7 @@ algorithm DAE.Exp rhs; DAE.ComponentRef componentRef; Integer size; + Option recordSize; DAE.Algorithm alg; DAE.Expand expand; BackendDAE.WhenEquation whenEquation; @@ -2056,8 +2077,8 @@ algorithm case (BackendDAE.EQUATION(exp=lhs, scalar=rhs, source=source), _) then BackendDAE.EQUATION(lhs, rhs, source, inAttr); - case (BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left=lhs, right=rhs, source=source), _) - then BackendDAE.ARRAY_EQUATION(dimSize, lhs, rhs, source, inAttr); + case (BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left=lhs, right=rhs, source=source, recordSize=recordSize), _) + then BackendDAE.ARRAY_EQUATION(dimSize, lhs, rhs, source, inAttr, recordSize); case (BackendDAE.FOR_EQUATION(), _) then BackendDAE.FOR_EQUATION(inEqn.iter, inEqn.start, inEqn.stop, inEqn.body, inEqn.source, inAttr); @@ -2096,67 +2117,49 @@ public function setEquationLHS algorithm outEqn := match inEqn local - DAE.ElementSource source; - list dimSize; - DAE.Exp rhs; - DAE.ComponentRef componentRef; - Integer size; - DAE.Algorithm alg; - DAE.Expand expand; - BackendDAE.WhenEquation whenEquation; - list< .DAE.Exp> conditions; - list> eqnstrue; - list eqnsfalse; - BackendDAE.EquationAttributes attr; + BackendDAE.Equation eqn; - case BackendDAE.EQUATION(scalar=rhs, source=source, attr=attr) - then BackendDAE.EQUATION(lhs, rhs, source, attr); + case eqn as BackendDAE.EQUATION() algorithm + eqn.exp := lhs; + then eqn; - case BackendDAE.ARRAY_EQUATION(dimSize=dimSize, right=rhs, source=source, attr=attr) - then BackendDAE.ARRAY_EQUATION(dimSize, lhs, rhs, source, attr); + case eqn as BackendDAE.ARRAY_EQUATION() algorithm + eqn.left := lhs; + then eqn; - else equation + else algorithm Error.addInternalError("function setEquationLHS failed", sourceInfo()); then fail(); end match; end setEquationLHS; public function setEquationRHS -" - sets the right hand side expression of an equation. -" +"sets the right hand side expression of an equation." input BackendDAE.Equation inEqn; input DAE.Exp rhs; output BackendDAE.Equation outEqn; algorithm outEqn := match inEqn local - DAE.ElementSource source; - list dimSize; - DAE.Exp lhs; - DAE.ComponentRef componentRef; - Integer size; - DAE.Algorithm alg; - DAE.Expand expand; - BackendDAE.WhenEquation whenEquation; - list< .DAE.Exp> conditions; - list> eqnstrue; - list eqnsfalse; - BackendDAE.EquationAttributes attr; + BackendDAE.Equation eqn; - case BackendDAE.EQUATION(exp=lhs, source=source, attr=attr) - then BackendDAE.EQUATION(lhs, rhs, source, attr); + case eqn as BackendDAE.EQUATION() algorithm + eqn.scalar := rhs; + then eqn; - case BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left=lhs, source=source, attr=attr) - then BackendDAE.ARRAY_EQUATION(dimSize, lhs, rhs, source, attr); + case eqn as BackendDAE.ARRAY_EQUATION() algorithm + eqn.right := rhs; + then eqn; - case BackendDAE.SOLVED_EQUATION(componentRef=componentRef, source=source, attr=attr) - then BackendDAE.SOLVED_EQUATION(componentRef, rhs, source, attr); + case eqn as BackendDAE.SOLVED_EQUATION() algorithm + eqn.exp := rhs; + then eqn; - case BackendDAE.RESIDUAL_EQUATION(source=source, attr=attr) - then BackendDAE.RESIDUAL_EQUATION(rhs, source, attr); + case eqn as BackendDAE.RESIDUAL_EQUATION() algorithm + eqn.exp := rhs; + then eqn; - else equation + else algorithm Error.addInternalError("function setEquationRHS failed", sourceInfo()); then fail(); end match; @@ -2396,7 +2399,8 @@ public function solveEquation "author: wbraun input Option functions; output BackendDAE.Equation outEqn; algorithm - outEqn := matchcontinue (eqn, crefExp, functions) + // kabdelhak: Why does every kind of equation produce a regular equation? + outEqn := matchcontinue eqn local DAE.Exp e1, e2; DAE.Exp res; @@ -2406,20 +2410,20 @@ algorithm DAE.ElementSource source; BackendDAE.EquationAttributes eqAttr; - case (BackendDAE.EQUATION(exp=e1, scalar=e2, source=source, attr=eqAttr), _, _) equation + case BackendDAE.EQUATION(exp=e1, scalar=e2, source=source, attr=eqAttr) equation (res, _, {}, {}) = ExpressionSolve.solve2(e1, e2, crefExp, functions, NONE()); - then (BackendDAE.EQUATION(crefExp, res, source, eqAttr)); + then BackendDAE.EQUATION(crefExp, res, source, eqAttr); - case (BackendDAE.ARRAY_EQUATION(left=e1, right=e2, source=source, attr=eqAttr), _, _) equation + case BackendDAE.ARRAY_EQUATION(left=e1, right=e2, source=source, attr=eqAttr) equation (res, _, {}, {}) = ExpressionSolve.solve2(e1, e2, crefExp, functions, NONE()); then (BackendDAE.EQUATION(crefExp, res, source, eqAttr)); - case (BackendDAE.SOLVED_EQUATION(componentRef=cref, exp=e2, source=source, attr=eqAttr), _,_) equation + case BackendDAE.SOLVED_EQUATION(componentRef=cref, exp=e2, source=source, attr=eqAttr) equation cr = Expression.expCref(crefExp); true = ComponentReference.crefEqual(cref, cr); then (BackendDAE.EQUATION(crefExp, e2, source, eqAttr)); - case (BackendDAE.SOLVED_EQUATION(componentRef=cref, exp=e2, source=source, attr=eqAttr), _, _) equation + case BackendDAE.SOLVED_EQUATION(componentRef=cref, exp=e2, source=source, attr=eqAttr) equation // already checked in rule above: //cr = Expression.expCref(crefExp); //false = ComponentReference.crefEqual(cref, cr); @@ -2427,23 +2431,18 @@ algorithm (res, _, {}, {}) = ExpressionSolve.solve2(e1, e2, crefExp, functions, NONE()); then (BackendDAE.EQUATION(crefExp, res, source, eqAttr)); - case (BackendDAE.RESIDUAL_EQUATION(exp=e2, source=source, attr=eqAttr), _, _) equation + case BackendDAE.RESIDUAL_EQUATION(exp=e2, source=source, attr=eqAttr) equation e1 = Expression.makeConstZero(Expression.typeof(e2)); (res, _, {}, {}) = ExpressionSolve.solve2(e2, e1, crefExp, functions, NONE()); then (BackendDAE.EQUATION(crefExp, res, source, eqAttr)); - case (BackendDAE.COMPLEX_EQUATION(left=e1, right=e2, source=source, attr=eqAttr), _, _) equation + case BackendDAE.COMPLEX_EQUATION(left=e1, right=e2, source=source, attr=eqAttr) equation (res, _, {}, {}) = ExpressionSolve.solve2(e1, e2, crefExp, functions, NONE()); then (BackendDAE.EQUATION(crefExp, res, source, eqAttr)); -/* - case (eq as BackendDAE.ALGORITHM(alg=_), _) - then eq; - - case (eq as BackendDAE.WHEN_EQUATION(size=_), _) - then eq; - - case (eq as BackendDAE.IF_EQUATION(conditions=_), _) - then eq; +/* These won't get solved + BackendDAE.ALGORITHM + BackendDAE.WHEN_EQUATION + BackendDAE.IF_EQUATION */ else equation BackendDump.dumpBackendDAEEqnList({eqn}, "function BackendEquation.solveEquation failed w.r.t " + ExpressionDump.printExpStr(crefExp), true); @@ -2886,52 +2885,41 @@ public function addOperation " input DAE.SymbolicOperation inSymOp; output BackendDAE.Equation outEqn; algorithm - outEqn := match (inEqn, inSymOp) + outEqn := match inEqn local - Integer size; - DAE.Exp e1, e2; - list conditions; - DAE.ElementSource source; - BackendDAE.WhenEquation whenEquation; - DAE.ComponentRef cr1; - list eqnsfalse; - list> eqnstrue; - list ds; - DAE.Algorithm alg; - DAE.Expand crefExpand; - BackendDAE.EquationAttributes eqAttr; + BackendDAE.Equation eqn; - case (BackendDAE.EQUATION(e1, e2, source, eqAttr), _) equation - source = ElementSource.addSymbolicTransformation(source, inSymOp); - then BackendDAE.EQUATION(e1, e2, source, eqAttr); + case eqn as BackendDAE.EQUATION() equation + eqn.source = ElementSource.addSymbolicTransformation(eqn.source, inSymOp); + then eqn; - case (BackendDAE.ARRAY_EQUATION(ds, e1, e2, source, eqAttr), _) equation - source = ElementSource.addSymbolicTransformation(source, inSymOp); - then BackendDAE.ARRAY_EQUATION(ds, e1, e2, source, eqAttr); + case eqn as BackendDAE.ARRAY_EQUATION() equation + eqn.source = ElementSource.addSymbolicTransformation(eqn.source, inSymOp); + then eqn; - case (BackendDAE.SOLVED_EQUATION(cr1, e1, source, eqAttr), _) equation - source = ElementSource.addSymbolicTransformation(source, inSymOp); - then BackendDAE.SOLVED_EQUATION(cr1, e1, source, eqAttr); + case eqn as BackendDAE.SOLVED_EQUATION() equation + eqn.source = ElementSource.addSymbolicTransformation(eqn.source, inSymOp); + then eqn; - case (BackendDAE.RESIDUAL_EQUATION(e1, source, eqAttr), _) equation - source = ElementSource.addSymbolicTransformation(source, inSymOp); - then BackendDAE.RESIDUAL_EQUATION(e1, source, eqAttr); + case eqn as BackendDAE.RESIDUAL_EQUATION() equation + eqn.source = ElementSource.addSymbolicTransformation(eqn.source, inSymOp); + then eqn; - case (BackendDAE.ALGORITHM(size, alg, source, crefExpand, eqAttr), _) equation - source = ElementSource.addSymbolicTransformation(source, inSymOp); - then BackendDAE.ALGORITHM(size, alg, source, crefExpand, eqAttr); + case eqn as BackendDAE.ALGORITHM() equation + eqn.source = ElementSource.addSymbolicTransformation(eqn.source, inSymOp); + then eqn; - case (BackendDAE.WHEN_EQUATION(size, whenEquation, source, eqAttr), _) equation - source = ElementSource.addSymbolicTransformation(source, inSymOp); - then BackendDAE.WHEN_EQUATION(size, whenEquation, source, eqAttr); + case eqn as BackendDAE.WHEN_EQUATION() equation + eqn.source = ElementSource.addSymbolicTransformation(eqn.source, inSymOp); + then eqn; - case (BackendDAE.COMPLEX_EQUATION(size, e1, e2, source, eqAttr), _) equation - source = ElementSource.addSymbolicTransformation(source, inSymOp); - then BackendDAE.COMPLEX_EQUATION(size, e1, e2, source, eqAttr); + case eqn as BackendDAE.COMPLEX_EQUATION() equation + eqn.source = ElementSource.addSymbolicTransformation(eqn.source, inSymOp); + then eqn; - case (BackendDAE.IF_EQUATION(conditions, eqnstrue, eqnsfalse, source, eqAttr), _) equation - source = ElementSource.addSymbolicTransformation(source, inSymOp); - then BackendDAE.IF_EQUATION(conditions, eqnstrue, eqnsfalse, source, eqAttr); + case eqn as BackendDAE.IF_EQUATION() equation + eqn.source = ElementSource.addSymbolicTransformation(eqn.source, inSymOp); + then eqn; else equation Error.addInternalError("BackendEquation.addOperation failed", sourceInfo()); @@ -3047,35 +3035,27 @@ public function markDifferentiated"sets differentiated=true in EquationAttribute algorithm outEqn := match (inEqn) local - DAE.Exp e1, e2; - DAE.ComponentRef cr; - DAE.ElementSource source; - Integer size; - list dimSize; - list conditions; - list> eqnstrue; - list eqnsfalse; - BackendDAE.EquationAttributes eqAttr; + BackendDAE.Equation eqn; - case BackendDAE.EQUATION(exp=e1, scalar=e2, source=source, attr=eqAttr) equation - eqAttr = markDifferentiated2(eqAttr); - then BackendDAE.EQUATION(e1, e2, source, eqAttr); + case eqn as BackendDAE.EQUATION() equation + eqn.attr = markDifferentiated2(eqn.attr); + then eqn; - case BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left=e1, right=e2, source=source, attr=eqAttr) equation - eqAttr = markDifferentiated2(eqAttr); - then BackendDAE.ARRAY_EQUATION(dimSize, e1, e2, source, eqAttr); + case eqn as BackendDAE.ARRAY_EQUATION() equation + eqn.attr = markDifferentiated2(eqn.attr); + then eqn; - case BackendDAE.SOLVED_EQUATION(componentRef=cr, exp=e2, source=source, attr=eqAttr) equation - eqAttr = markDifferentiated2(eqAttr); - then BackendDAE.SOLVED_EQUATION(cr, e2, source, eqAttr); + case eqn as BackendDAE.SOLVED_EQUATION() equation + eqn.attr = markDifferentiated2(eqn.attr); + then eqn; - case BackendDAE.RESIDUAL_EQUATION(exp=e2, source=source, attr=eqAttr) equation - eqAttr = markDifferentiated2(eqAttr); - then BackendDAE.RESIDUAL_EQUATION(e2, source, eqAttr); + case eqn as BackendDAE.RESIDUAL_EQUATION() equation + eqn.attr = markDifferentiated2(eqn.attr); + then eqn; - case BackendDAE.COMPLEX_EQUATION(size=size, left=e1, right=e2, source=source, attr=eqAttr) equation - eqAttr = markDifferentiated2(eqAttr); - then BackendDAE.COMPLEX_EQUATION(size, e1, e2, source, eqAttr); + case eqn as BackendDAE.COMPLEX_EQUATION() equation + eqn.attr = markDifferentiated2(eqn.attr); + then eqn; case BackendDAE.ALGORITHM() then inEqn; @@ -3083,11 +3063,11 @@ algorithm case BackendDAE.WHEN_EQUATION() then inEqn; - case BackendDAE.IF_EQUATION(conditions=conditions, eqnstrue=eqnstrue, eqnsfalse=eqnsfalse, source=source, attr=eqAttr) equation - eqAttr = markDifferentiated2(eqAttr); - eqnstrue = List.mapList(eqnstrue, markDifferentiated); - eqnsfalse = List.map(eqnsfalse, markDifferentiated); - then BackendDAE.IF_EQUATION(conditions, eqnstrue, eqnsfalse, source, eqAttr); + case eqn as BackendDAE.IF_EQUATION() equation + eqn.attr = markDifferentiated2(eqn.attr); + eqn.eqnstrue = List.mapList(eqn.eqnstrue, markDifferentiated); + eqn.eqnsfalse = List.map(eqn.eqnsfalse, markDifferentiated); + then eqn; end match; end markDifferentiated; diff --git a/OMCompiler/Compiler/BackEnd/BackendInline.mo b/OMCompiler/Compiler/BackEnd/BackendInline.mo index 7edf05e1dd7..b753a34065d 100644 --- a/OMCompiler/Compiler/BackEnd/BackendInline.mo +++ b/OMCompiler/Compiler/BackEnd/BackendInline.mo @@ -183,6 +183,7 @@ algorithm local DAE.Exp e,e_1,e1,e1_1,e2,e2_1; Integer size; + Option recordSize; list explst; DAE.ComponentRef cref; BackendDAE.WhenEquation weq,weq_1; @@ -205,7 +206,7 @@ algorithm then (BackendDAE.EQUATION(e1_1,e2_1,source,attr),true); - case(BackendDAE.ARRAY_EQUATION(dimSize,e1,e2,source,attr),_) + case(BackendDAE.ARRAY_EQUATION(dimSize,e1,e2,source,attr,recordSize),_) equation (e1_1,source,b1,_) = Inline.inlineExp(e1,fns,source); (e2_1,source,b2,_) = Inline.inlineExp(e2,fns,source); @@ -213,7 +214,7 @@ algorithm eqn = match (e1_1, e2_1) case (DAE.ARRAY(array = {e1}), DAE.ARRAY(array = {e2})) then BackendDAE.EQUATION(e1,e2,source,attr); // flatten if size==1 - else BackendDAE.ARRAY_EQUATION(dimSize,e1_1,e2_1,source,attr); + else BackendDAE.ARRAY_EQUATION(dimSize,e1_1,e2_1,source,attr,recordSize); end match; then (eqn, true); diff --git a/OMCompiler/Compiler/BackEnd/BackendVarTransform.mo b/OMCompiler/Compiler/BackEnd/BackendVarTransform.mo index 803ab9667aa..7b6d1f20316 100644 --- a/OMCompiler/Compiler/BackEnd/BackendVarTransform.mo +++ b/OMCompiler/Compiler/BackEnd/BackendVarTransform.mo @@ -1665,6 +1665,7 @@ algorithm BackendDAE.Equation a; DAE.ComponentRef cr; Integer size; + Option recordSize; list expl,expl1,expl2; BackendDAE.WhenEquation whenEqn,whenEqn1; DAE.ElementSource source; @@ -1679,7 +1680,7 @@ algorithm DAE.Expand crefExpand; BackendDAE.EquationAttributes eqAttr; - case (BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left=e1, right=e2, source=source, attr=eqAttr),repl,_,_,_) + case (BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left=e1, right=e2, source=source, attr=eqAttr, recordSize=recordSize),repl,_,_,_) equation (e1_1,b1) = replaceExp(e1, repl,inFuncTypeExpExpToBooleanOption); (e2_1,b2) = replaceExp(e2, repl,inFuncTypeExpExpToBooleanOption); @@ -1688,7 +1689,7 @@ algorithm source = ElementSource.addSymbolicTransformationSubstitution(b2,source,e2,e2_1); (DAE.EQUALITY_EXPS(e1_2,e2_2),source) = ExpressionSimplify.simplifyAddSymbolicOperation(DAE.EQUALITY_EXPS(e1_1,e2_1),source); then - (BackendDAE.ARRAY_EQUATION(dimSize,e1_2,e2_2,source,eqAttr)::inAcc,true); + (BackendDAE.ARRAY_EQUATION(dimSize,e1_2,e2_2,source,eqAttr,recordSize)::inAcc,true); case (BackendDAE.COMPLEX_EQUATION(size=size, left=e1, right=e2, source=source, attr=eqAttr),repl,_,_,_) equation diff --git a/OMCompiler/Compiler/BackEnd/Differentiate.mo b/OMCompiler/Compiler/BackEnd/Differentiate.mo index 4d6dc5eee7f..49de98f9159 100644 --- a/OMCompiler/Compiler/BackEnd/Differentiate.mo +++ b/OMCompiler/Compiler/BackEnd/Differentiate.mo @@ -269,6 +269,7 @@ try DAE.ComponentRef cref; DAE.ElementSource source; Integer size; + Option recordSize; list out1, expExpLst, expExpLst1; DAE.Type exptyp; list dimSize; @@ -347,7 +348,7 @@ try (BackendDAE.COMPLEX_EQUATION(size, e1_1, e2_1, source, eqAttr), funcs); // Array Equations - case BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left=e1, right=e2, source=source, attr=eqAttr) + case BackendDAE.ARRAY_EQUATION(dimSize=dimSize, left=e1, right=e2, source=source, attr=eqAttr, recordSize=recordSize) equation (e1_1, funcs) = differentiateExp(e1, inDiffwrtCref, inInputData, inDiffType, inFunctionTree, defaultMaxIter); (e1_1, _) = ExpressionSimplify.simplify(e1_1); @@ -360,7 +361,7 @@ try source = List.foldr({op1, op2}, ElementSource.addSymbolicTransformation, source); then - (BackendDAE.ARRAY_EQUATION(dimSize, e1_1, e2_1, source, eqAttr), funcs); + (BackendDAE.ARRAY_EQUATION(dimSize, e1_1, e2_1, source, eqAttr, recordSize), funcs); // differentiate algorithm case BackendDAE.ALGORITHM(size=size, alg=DAE.ALGORITHM_STMTS(statementLst=statementLst), source=source, expand=expand, attr=eqAttr) diff --git a/OMCompiler/Compiler/BackEnd/FindZeroCrossings.mo b/OMCompiler/Compiler/BackEnd/FindZeroCrossings.mo index 4073d39a832..d99b1da8c9a 100644 --- a/OMCompiler/Compiler/BackEnd/FindZeroCrossings.mo +++ b/OMCompiler/Compiler/BackEnd/FindZeroCrossings.mo @@ -641,7 +641,7 @@ algorithm list stmts, stmts_1; DAE.ComponentRef cref; list whenOperations; - Option elseClause_; + Option elseClause_, recordSize; list dimsize; BackendDAE.WhenEquation weqn; Boolean diffed; @@ -684,11 +684,11 @@ algorithm (res1, eq_reslst, countMathFunctions, relationsLst, sampleLst) = findZeroCrossings2(inVariables1, globalKnownVars, xs, eq_count, countMathFunctions, res, relationsLst, sampleLst, eqnsAccum); then (res1, eq_reslst, countMathFunctions, relationsLst, sampleLst); - case ((BackendDAE.ARRAY_EQUATION(dimSize=dimsize, left=e1, right=e2, source=source, attr=eqAttr))::xs) equation + case ((BackendDAE.ARRAY_EQUATION(dimSize=dimsize, left=e1, right=e2, source=source, attr=eqAttr, recordSize=recordSize))::xs) equation eq_count = inEqnCount + 1; (eres1, countMathFunctions, zcs1, relationsLst, sampleLst) = findZeroCrossings3(e1, inZeroCrossingLst, inRelationsLst, inSamplesLst, inNumberOfMathFunctions, eq_count, -1, inVariables1, globalKnownVars); (eres2, countMathFunctions, res, relationsLst, sampleLst) = findZeroCrossings3(e2, zcs1, relationsLst, sampleLst, countMathFunctions, eq_count, -1, inVariables1, globalKnownVars); - eqnsAccum = BackendDAE.ARRAY_EQUATION(dimsize, eres1, eres2, source, eqAttr)::inEquationLstAccum; + eqnsAccum = BackendDAE.ARRAY_EQUATION(dimsize, eres1, eres2, source, eqAttr, recordSize)::inEquationLstAccum; (res1, eq_reslst, countMathFunctions, relationsLst, sampleLst) = findZeroCrossings2(inVariables1, globalKnownVars, xs, eq_count, countMathFunctions, res, relationsLst, sampleLst, eqnsAccum); then (res1, eq_reslst, countMathFunctions, relationsLst, sampleLst); diff --git a/OMCompiler/Compiler/BackEnd/IndexReduction.mo b/OMCompiler/Compiler/BackEnd/IndexReduction.mo index 7517098a197..c472a5430b0 100644 --- a/OMCompiler/Compiler/BackEnd/IndexReduction.mo +++ b/OMCompiler/Compiler/BackEnd/IndexReduction.mo @@ -1619,6 +1619,7 @@ protected DAE.ComponentRef crA,set,crJ; DAE.Type tp, tyExpCrStates; Integer rang,nStates,nStateCandidates,nUnassignedEquations,setIndex,level; + Option recordSize; DAE.Exp expcrA,mulAstates,mulAdstates,expset,expderset,expsetstart; list expcrstates,expcrdstates,expcrset,expcrdset,expcrstatesstart; @@ -1658,11 +1659,20 @@ algorithm expset := if b then DAE.ARRAY(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(rang)}),true,expcrset) else listHead(expcrset); expderset := if b then DAE.ARRAY(DAE.T_ARRAY(DAE.T_REAL_DEFAULT,{DAE.DIM_INTEGER(rang)}),true,expcrdset) else listHead(expcrdset); source := DAE.SOURCE(SOURCEINFO("stateselection",false,0,0,0,0,0.0),{},Prefix.NOCOMPPRE(),{},{},{},{}); + + tp := ComponentReference.crefTypeFull(crA); + tp := DAEUtil.expTypeElementType(tp); + if DAEUtil.expTypeComplex(tp) then + recordSize := SOME(Expression.sizeOf(tp)); + else + recordSize := NONE(); + end if; + // set.x = set.A*set.statecandidates - eqn := if b then BackendDAE.ARRAY_EQUATION({rang},expset,mulAstates,source,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC) + eqn := if b then BackendDAE.ARRAY_EQUATION({rang},expset,mulAstates,source,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC,recordSize) else BackendDAE.EQUATION(expset,mulAstates,source,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC); // der(set.x) = set.A*der(set.candidates) - deqn := if b then BackendDAE.ARRAY_EQUATION({rang},expderset,mulAdstates,DAE.emptyElementSource,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC) + deqn := if b then BackendDAE.ARRAY_EQUATION({rang},expderset,mulAdstates,DAE.emptyElementSource,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC,recordSize) else BackendDAE.EQUATION(expderset,mulAdstates,DAE.emptyElementSource,BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC); // start values for the set expsetstart := DAE.BINARY(expcrA,op,DAE.ARRAY(tyExpCrStates,true,expcrstatesstart)); diff --git a/OMCompiler/Compiler/BackEnd/Initialization.mo b/OMCompiler/Compiler/BackEnd/Initialization.mo index 14dab533372..34d110708ce 100644 --- a/OMCompiler/Compiler/BackEnd/Initialization.mo +++ b/OMCompiler/Compiler/BackEnd/Initialization.mo @@ -2116,6 +2116,7 @@ protected function collectInitialStateSets "author: kabdelhak list statesToFix = {}, unfixedStates = {}, VarsF, oInitSetVars; DAE.Type tp, tyExpCrStates; Integer toFix, setsize, nCandidates; + Option recordSize; Boolean b; DAE.Operator op; DAE.ElementSource source; @@ -2124,6 +2125,13 @@ algorithm for stateSet in stateSets loop oVars := BackendVariable.addVars(stateSet.varA, oVars); lhs := Expression.crefToExp(stateSet.crA); + tp := ComponentReference.crefTypeFull(stateSet.crA); + tp := DAEUtil.expTypeElementType(tp); + if DAEUtil.expTypeComplex(tp) then + recordSize := SOME(Expression.sizeOf(tp)); + else + recordSize := NONE(); + end if; expLst:={}; @@ -2132,7 +2140,7 @@ algorithm expLst := DAE.ICONST(integer=stateSet.index-1)::expLst; rhs := DAE.CALL(path=Absyn.IDENT(name="$stateSelectionSet"),expLst=expLst,attr=DAE.callAttrBuiltinOther); - eqn := BackendDAE.ARRAY_EQUATION(dimSize={listLength(stateSet.varA)}, left=lhs, right=rhs,source=DAE.emptyElementSource,attr=BackendDAE.EQ_ATTR_DEFAULT_INITIAL); + eqn := BackendDAE.ARRAY_EQUATION(dimSize={listLength(stateSet.varA)}, left=lhs, right=rhs,source=DAE.emptyElementSource,attr=BackendDAE.EQ_ATTR_DEFAULT_INITIAL, recordSize=recordSize); oEqns := ExpandableArray.add(eqn,oEqns); if Flags.isSet(Flags.BLT_DUMP) or Flags.isSet(Flags.INITIALIZATION) then diff --git a/OMCompiler/Compiler/BackEnd/InlineArrayEquations.mo b/OMCompiler/Compiler/BackEnd/InlineArrayEquations.mo index 020856d2001..1c115f272e2 100644 --- a/OMCompiler/Compiler/BackEnd/InlineArrayEquations.mo +++ b/OMCompiler/Compiler/BackEnd/InlineArrayEquations.mo @@ -190,10 +190,11 @@ protected function generateScalarArrayEqns2 input tuple> iEqns; output tuple> oEqns; algorithm - oEqns := matchcontinue(inExp1, inExp2, inSource, eqAttr, eqExp, iEqns) + oEqns := matchcontinue iEqns local DAE.Type tp; Integer size, i; + Option recordSize; DAE.Dimensions dims; list ds; Boolean b1, b2; @@ -201,7 +202,7 @@ algorithm DAE.ElementSource source; // complex types to complex equations - case (_, _, _, _, _, (i, eqns)) equation + case (i, eqns) equation tp = Expression.typeof(inExp1); true = DAEUtil.expTypeComplex(tp); size = Expression.sizeOf(tp); @@ -209,16 +210,22 @@ algorithm then ((i+1, BackendDAE.COMPLEX_EQUATION(size, inExp1, inExp2, source, eqAttr)::eqns)); // array types to array equations - case (_, _, _, _, _, (i, eqns)) equation + case (i, eqns) equation tp = Expression.typeof(inExp1); true = DAEUtil.expTypeArray(tp); dims = Expression.arrayDimension(tp); + tp = DAEUtil.expTypeElementType(tp); + if DAEUtil.expTypeComplex(tp) then + recordSize = SOME(Expression.sizeOf(tp)); + else + recordSize = NONE(); + end if; ds = Expression.dimensionsSizes(dims); source = ElementSource.addSymbolicTransformation(inSource, DAE.OP_SCALARIZE(eqExp, i, DAE.EQUALITY_EXPS(inExp1, inExp2))); - then ((i+1, BackendDAE.ARRAY_EQUATION(ds, inExp1, inExp2, source, eqAttr)::eqns)); + then ((i+1, BackendDAE.ARRAY_EQUATION(ds, inExp1, inExp2, source, eqAttr, recordSize)::eqns)); // other types - case (_, _, _, _, _, (i, eqns)) equation + case (i, eqns) equation tp = Expression.typeof(inExp1); b1 = DAEUtil.expTypeComplex(tp); b2 = DAEUtil.expTypeArray(tp); diff --git a/OMCompiler/Compiler/BackEnd/RemoveSimpleEquations.mo b/OMCompiler/Compiler/BackEnd/RemoveSimpleEquations.mo index 9c8900e988d..9855651dcb3 100644 --- a/OMCompiler/Compiler/BackEnd/RemoveSimpleEquations.mo +++ b/OMCompiler/Compiler/BackEnd/RemoveSimpleEquations.mo @@ -1305,12 +1305,14 @@ algorithm local Integer size; DAE.Dimensions dims; + DAE.Type tp; list ds; BackendDAE.Variables v; BackendDAE.Shared s; list eqns; list seqns; Integer index; + Option recordSize; array> mT; Boolean b, b1, b2; DAE.ElementSource source; @@ -1332,9 +1334,15 @@ algorithm equation dims = Expression.arrayDimension(ty); ds = Expression.dimensionsSizes(dims); + tp = DAEUtil.expTypeElementType(ty); + if DAEUtil.expTypeComplex(tp) then + recordSize = SOME(Expression.sizeOf(tp)); + else + recordSize = NONE(); + end if; // print("Add Equation:\n" + BackendDump.equationStr(BackendDAE.ARRAY_EQUATION(ds, lhs, rhs, source)) + "\n"); then - ((v, s, BackendDAE.ARRAY_EQUATION(ds, lhs, rhs, source, eqAttr)::eqns, seqns, index, mT, b)); + ((v, s, BackendDAE.ARRAY_EQUATION(ds, lhs, rhs, source, eqAttr, recordSize)::eqns, seqns, index, mT, b)); // other types case (_, _, _, (source, eqAttr), (v, s, eqns, seqns, index, mT, b)) equation diff --git a/OMCompiler/Compiler/BackEnd/SynchronousFeatures.mo b/OMCompiler/Compiler/BackEnd/SynchronousFeatures.mo index a47f4951c4e..e08c62441ed 100644 --- a/OMCompiler/Compiler/BackEnd/SynchronousFeatures.mo +++ b/OMCompiler/Compiler/BackEnd/SynchronousFeatures.mo @@ -1375,6 +1375,7 @@ algorithm list newEqs; list newVars; list dimSize; + Option recordSize; case(BackendDAE.EQUATION(e1, e2, source, attr=BackendDAE.EQUATION_ATTRIBUTES(kind=BackendDAE.DYNAMIC_EQUATION())),(vars, suffixIdx0, newEqs, newVars)) algorithm (e1,(newEqs, newVars, suffixIdx)) := Expression.traverseExpTopDown(e1, replaceSampledClocks2, (newEqs, newVars, suffixIdx0)); @@ -1385,7 +1386,7 @@ algorithm attr := BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC; end if; then (BackendDAE.EQUATION(e1,e2,source,attr),(vars, suffixIdx, newEqs, newVars)); - case(BackendDAE.ARRAY_EQUATION(dimSize, e1, e2, source, attr=BackendDAE.EQUATION_ATTRIBUTES(kind=BackendDAE.DYNAMIC_EQUATION())),(vars, suffixIdx0, newEqs, newVars)) + case(BackendDAE.ARRAY_EQUATION(dimSize, e1, e2, source, attr=BackendDAE.EQUATION_ATTRIBUTES(kind=BackendDAE.DYNAMIC_EQUATION()), recordSize=recordSize),(vars, suffixIdx0, newEqs, newVars)) algorithm (e1,(newEqs, newVars, suffixIdx)) := Expression.traverseExpTopDown(e1, replaceSampledClocks2, (newEqs, newVars, suffixIdx0)); (e2,(newEqs, newVars, suffixIdx)) := Expression.traverseExpTopDown(e2, replaceSampledClocks2, (newEqs, newVars, suffixIdx)); @@ -1394,7 +1395,7 @@ algorithm else attr := BackendDAE.EQ_ATTR_DEFAULT_DYNAMIC; end if; - then (BackendDAE.ARRAY_EQUATION(dimSize, e1, e2, source, attr), (vars, suffixIdx, newEqs, newVars)); + then (BackendDAE.ARRAY_EQUATION(dimSize, e1, e2, source, attr, recordSize), (vars, suffixIdx, newEqs, newVars)); else algorithm then (eqIn,tplIn);