Skip to content

Commit

Permalink
Access iterators locally in alg loops as well
Browse files Browse the repository at this point in the history
See: PowerSystems.Examples.Spot.DrivesAC3ph.SM_ctrl
  • Loading branch information
rfranke committed Mar 30, 2016
1 parent 630a9d0 commit a37f8ba
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions Compiler/Template/CodegenCppCommon.tpl
Expand Up @@ -23,14 +23,7 @@ template cref(ComponentRef cr, Boolean useFlatArrayNotation)
case WILD(__) then ''
else "_"+crefToCStr(cr, useFlatArrayNotation)
end cref;
template localcref(ComponentRef cr, Boolean useFlatArrayNotation)
"Generates C equivalent name for component reference."
::=
match cr
case CREF_IDENT(ident = "time") then "_simTime"
case WILD(__) then ''
else crefToCStr(cr,useFlatArrayNotation)
end localcref;

template subscriptsToCStr(list<Subscript> subscripts, Boolean useFlatArrayNotation)
::=
if subscripts then
Expand Down Expand Up @@ -229,11 +222,10 @@ template representationCref(ComponentRef inCref, SimCode simCode ,Text& extraFun
case SIMVAR(index=-2) then
match context
case JACOBIAN_CONTEXT() then
'_<%crefToCStr(inCref,false)%>'
case ALGLOOP_CONTEXT(__) then
'_system->_<%crefToCStr(inCref,false)%>'
'_<%crefToCStr(inCref, false)%>'
else
'<%localcref(inCref, useFlatArrayNotation)%>'
// a local variable, like an iterator
'<%crefToCStr(inCref, useFlatArrayNotation)%>'
end match
else
match context
Expand Down

0 comments on commit a37f8ba

Please sign in to comment.