Skip to content
This repository has been archived by the owner on May 18, 2019. It is now read-only.

Commit

Permalink
More add underscore to variable names in Cpp runtime
Browse files Browse the repository at this point in the history
- add underscore to iterators outside functions
- remove filter for keywords outside functions --
  they are covered with the generally added underscores
  • Loading branch information
rfranke authored and OpenModelica-Hudson committed Jan 29, 2017
1 parent 4d45d7a commit b4a66a2
Showing 1 changed file with 11 additions and 26 deletions.
37 changes: 11 additions & 26 deletions Compiler/Template/CodegenCppCommon.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@ template contextFunName(String funName, Context context)
else '_functions-><%funName%>'
end contextFunName;

template contextIteratorName(Ident name, Context context)
"Generates code for an iterator variable."
::=
match context
case FUNCTION_CONTEXT(__) then name
else name + "_"
end contextIteratorName;

template crefWithIndex(ComponentRef cr, Context context, Text &varDecls, SimCode simCode, Text& extraFuncs, Text& extraFuncsDecl,
Text extraFuncsNamespace, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation)
"Return cref with index for the lhs of a for loop, i.e., _resistori_P_i."
Expand Down Expand Up @@ -206,17 +214,12 @@ template cref1(ComponentRef cr, SimCode simCode ,Text& extraFuncs,Text& extraFun
match cr
case CREF_IDENT(ident = "xloc") then '<%representationCref(cr, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, context, varDecls, stateDerVectorName, useFlatArrayNotation)%>'
case CREF_IDENT(ident = "time") then
match context
match context
case ALGLOOP_CONTEXT(genInitialisation=false)
then "_system->_simTime"
else
"_simTime"
else "_simTime"
end match
//filter key words for variable names
case CREF_IDENT(ident = "unsigned") then 'unsigned_'
case CREF_IDENT(ident = "string") then 'string_'
case CREF_IDENT(ident = "int") then 'int_'
else '<%representationCref(cr, simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,context, varDecls, stateDerVectorName, useFlatArrayNotation) %>'
else '<%representationCref(cr, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, context, varDecls, stateDerVectorName, useFlatArrayNotation)%>'
end cref1;

template representationCref(ComponentRef inCref, SimCode simCode ,Text& extraFuncs,Text& extraFuncsDecl,Text extraFuncsNamespace, Context context, Text &varDecls, Text stateDerVectorName /*=__zDot*/, Boolean useFlatArrayNotation) ::=
Expand Down Expand Up @@ -2761,24 +2764,6 @@ template encloseInParantheses(String expStr)
if intEq(stringGet(expStr, 1), stringGet("(", 1)) then '<%expStr%>' else '(<%expStr%>)'
end encloseInParantheses;







template contextIteratorName(Ident name, Context context)
"Generates code for an iterator variable."
::=
name
end contextIteratorName;







template writeLhsCref(Exp exp, String rhsStr, Context context, Text &preExp, Text &varDecls, SimCode simCode,
Text& extraFuncs,Text& extraFuncsDecl,Text extraFuncsNamespace, Text stateDerVectorName, Boolean useFlatArrayNotation)
"Generates code for writing a returnStructur to var."
Expand Down

0 comments on commit b4a66a2

Please sign in to comment.