From c495c2687c07d038481ec2e338d704e9028382a3 Mon Sep 17 00:00:00 2001 From: Niklas Worschech Date: Fri, 13 Jun 2014 12:46:45 +0000 Subject: [PATCH] fix in cpp template for missing evaluate git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@21100 f25d12d1-65f4-0310-ae8a-bbce733d8d8e --- Compiler/Template/CodegenCpp.tpl | 124 +++++++++++++++++++++++-------- 1 file changed, 94 insertions(+), 30 deletions(-) diff --git a/Compiler/Template/CodegenCpp.tpl b/Compiler/Template/CodegenCpp.tpl index 635dd0839fa..d79201bd6e7 100644 --- a/Compiler/Template/CodegenCpp.tpl +++ b/Compiler/Template/CodegenCpp.tpl @@ -3701,18 +3701,35 @@ template generateEquationMemberFuncDecls(list allEquations) ::= match allEquations case _ then - let equation_func_decls = (allEquations |> eq => 'void evaluate_<%equationIndex(eq)%>();' ;separator="\n") + let equation_func_decls = (allEquations |> eq => generateEquationMemberFuncDecls2(eq) ;separator="\n") << /*! Index of the first equation. We use this to calculate the offset of an equation in the - equation array given the index of the equation.*/ - int first_equation_index; + equation array given the index of the equation.*/ + int first_equation_index; + <%equation_func_decls%> + >> + end match +end generateEquationMemberFuncDecls; - /*! Equations*/ - <%equation_func_decls%> + +template generateEquationMemberFuncDecls2(SimEqSystem eq) +::= + match eq + case e as SES_MIXED(__) + then + << + /*! Equations*/ + void evaluate_<%equationIndex(e.cont)%>(); + void evaluate_<%equationIndex(eq)%>(); + >> + else + << + /*! Equations*/ + void evaluate_<%equationIndex(eq)%>(); >> end match -end generateEquationMemberFuncDecls; +end generateEquationMemberFuncDecls2; /* <%modelname%>Algloop<%index%>( @@ -6303,44 +6320,91 @@ template equation_function_create_single_func(SimEqSystem eq, Context context, ::= let ix_str = equationIndex(eq) let &varDeclsLocal = buffer "" /*BUFD*/ - let body = match eq case e as SES_SIMPLE_ASSIGN(__) - then equationSimpleAssign(e, context,&varDeclsLocal,simCode) + then + let body = equationSimpleAssign(e, context,&varDeclsLocal,simCode) + << + /* + <%dumpEqs(fill(eq,1))%> + */ + void <%lastIdentOfPathFromSimCode(simCode)%>::evaluate_<%ix_str%>() + { + <%varDeclsLocal%> + <%body%> + } + >> case e as SES_IFEQUATION(__) then "SES_IFEQUATION" case e as SES_ALGORITHM(__) - then equationAlgorithm(e, context, &varDeclsLocal,simCode) + then + let body = equationAlgorithm(e, context, &varDeclsLocal,simCode) + << + /* + <%dumpEqs(fill(eq,1))%> + */ + void <%lastIdentOfPathFromSimCode(simCode)%>::evaluate_<%ix_str%>() + { + <%varDeclsLocal%> + <%body%> + } + >> case e as SES_WHEN(__) - then equationWhen(e, context, &varDeclsLocal,simCode) + then + let body = equationWhen(e, context, &varDeclsLocal,simCode) + << + /* + <%dumpEqs(fill(eq,1))%> + */ + void <%lastIdentOfPathFromSimCode(simCode)%>::evaluate_<%ix_str%>() + { + <%varDeclsLocal%> + <%body%> + } + >> case e as SES_ARRAY_CALL_ASSIGN(__) - then equationArrayCallAssign(e, context, &varDeclsLocal,simCode) + then + let body = equationArrayCallAssign(e, context, &varDeclsLocal,simCode) + << + /* + <%dumpEqs(fill(eq,1))%> + */ + void <%lastIdentOfPathFromSimCode(simCode)%>::evaluate_<%ix_str%>() + { + <%varDeclsLocal%> + <%body%> + } + >> case e as SES_LINEAR(__) case e as SES_NONLINEAR(__) - then equationLinearOrNonLinear(e, context, &varDeclsLocal,simCode) - case e as SES_MIXED(__) + then + let body = equationLinearOrNonLinear(e, context, &varDeclsLocal,simCode) + << + /* + <%dumpEqs(fill(eq,1))%> + */ + void <%lastIdentOfPathFromSimCode(simCode)%>::evaluate_<%ix_str%>() + { + <%varDeclsLocal%> + <%body%> + } + >> + case e as SES_MIXED(__) then /*<%equationMixed(e, context, &varDeclsLocal, simCode)%>*/ - then + let body = equation_function_create_single_func(e.cont,context,simCode) << - - throw std::runtime_error("Mixed systems are not supported yet"); - >> + <%body%> + /* + <%dumpEqs(fill(eq,1))%> + */ + void <%lastIdentOfPathFromSimCode(simCode)%>::evaluate_<%ix_str%>() + { + throw std::runtime_error("Mixed systems are not supported yet"); + } + >> else "NOT IMPLEMENTED EQUATION" end match - - << - /* - <%dumpEqs(fill(eq,1))%> - */ - void <%lastIdentOfPathFromSimCode(simCode)%>::evaluate_<%ix_str%>() - { - <%varDeclsLocal%> - <%body%> - } - - >> - end equation_function_create_single_func;