Skip to content

Commit

Permalink
Generalize SES_ARRAY_CALL_ASSIGN for Cpp runtime (#7585)
Browse files Browse the repository at this point in the history
So far only arrays of bool, int and double were supported.
The new frontend generates arrays of other types as well,
see 9 examples from MSL, e.g.
Modelica.Electrical.MultiPhase.Examples.Rectifier
  • Loading branch information
rfranke committed Jun 21, 2021
1 parent 6600e3d commit e30a43b
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions OMCompiler/Compiler/Template/CodegenCppOld.tpl
Expand Up @@ -10977,22 +10977,19 @@ case eqn as SES_ARRAY_CALL_ASSIGN(lhs=lhs as CREF(__)) then
'localData->helpVars[<%hidx%>] && !localData->helpVars_saved[<%hidx%>] /* edge */'
;separator=" || ")C*/, &varDecls /*BUFD*/,simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
match expTypeFromExpShort(eqn.exp)
case "bool"
case "int" then
let lhsStr = cref1(lhs.componentRef, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, context, varDeclsCref, stateDerVectorName, useFlatArrayNotation)
case "double" then
<<
<%if not assignToStartValues then '<%startFixedExp%>'%>
<%preExp%>
<%lhsStr%>.assign(<%expPart%>);
<%assignDerArray(context, expPart, lhs, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)%>
>>
case "double" then
else
let lhsStr = cref1(lhs.componentRef, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, context, varDeclsCref, stateDerVectorName, useFlatArrayNotation)
<<
<%if not assignToStartValues then '<%startFixedExp%>'%>
<%preExp%>
<%assignDerArray(context, expPart, lhs, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)%>
<%lhsStr%>.assign(<%expPart%>);
>>
else
error(sourceInfo(), 'Unsupported type of array call assign: <%expTypeFromExpShort(eqn.exp)%>')
end equationArrayCallAssign;

template assignDerArray(Context context, String arr, Exp lhs_ecr, SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl, Text extraFuncsNamespace, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
Expand Down

0 comments on commit e30a43b

Please sign in to comment.