Skip to content

Commit

Permalink
Code generator works again. Still needs to have unnecessary code remo…
Browse files Browse the repository at this point in the history
…ved.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@9884 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
smiz committed Sep 20, 2011
1 parent 7a361e3 commit 9b1171e
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions Compiler/susan_codegen/SimCode/SimCodeAdevs.tpl
Expand Up @@ -45,6 +45,7 @@

package SimCodeAdevs
import interface SimCodeTV;
import SimCodeC;

template translateModel(SimCode simCode)
"Generates Cpp code and header file for an adevs model."
Expand Down Expand Up @@ -144,11 +145,11 @@ case SIMCODE(modelInfo = MODELINFO(varInfo = vi as VARINFO(__))) then
// Are we initializing the model?
bool atInit;
// Helping variables for when clauses
bool helpVars[<%vi.numHelpVars%>], helpVars_saved[<%vi.numHelpVars%>];
bool *helpVars, *helpVars_saved;
int numHelpVars() const { return <%vi.numHelpVars%>; }

// Zero crossing variables
int zc[<%vi.numZeroCrossings%>];
int *zc;
int numZeroCrossings() const { return <%vi.numZeroCrossings%>; }

// Initial unknowns via solution to least squares
Expand Down Expand Up @@ -296,13 +297,26 @@ case SIMCODE(modelInfo = MODELINFO(varInfo = vi as VARINFO(__))) then
<%vi.numStateVars%>+1, // Number of state variables plus one for the clock
<%vi.numZeroCrossings%>+extra_state_events // Number of state event functions
),
epsilon(1E-4)
epsilon(1E-4),
helpVars(NULL),
helpVars_saved(NULL),
zc(NULL)
{
timeValue = 0.0;
if (numHelpVars() > 0)
{
helpVars = new bool[numHelpVars()];
helpVars_saved = new bool[numHelpVars()];
}
if (numZeroCrossings() > 0)
zc = new int[numZeroCrossings()];
}

<%lastIdentOfPath(modelInfo.name)%>::~<%lastIdentOfPath(modelInfo.name)%>()
{
if (helpVars != NULL) delete [] helpVars;
if (helpVars_saved != NULL) delete [] helpVars_saved;
if (zc != NULL) delete [] zc;
}

<%makeExtraResiduals(allEquations,lastIdentOfPath(modelInfo.name))%>
Expand Down Expand Up @@ -5125,7 +5139,9 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/,
case exp as CALL(attr=CALL_ATTR(__)) then
let argStr = (expLst |> exp => '<%daeExp(exp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/)%>' ;separator=", ")
let funName = '<%underscorePath(path)%>'
let retType = '<%funName%>_rettype'
let retType = if attr.builtin then (match attr.ty case ET_NORETCALL(__) then ""
else expTypeModelica(attr.ty))
else '<%funName%>_rettype'
let retVar = match attr.ty
case ET_NORETCALL(__) then ""
else tempDecl(retType, &varDecls)
Expand Down

0 comments on commit 9b1171e

Please sign in to comment.