Skip to content

Commit 83bc76c

Browse files
committed
fix for struct access in cpp template
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17225 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent c7c48ad commit 83bc76c

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

Compiler/Template/CodegenCpp.tpl

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3928,7 +3928,7 @@ case CREF_QUAL(ident = "$PRE") then
39283928
'_event_handling.pre(<%contextCref(componentRef,context,simCode)%>,"<%cref(componentRef)%>")'
39293929
else
39303930
match context
3931-
case FUNCTION_CONTEXT(__) then '<%crefToCStr(cr)%>'
3931+
case FUNCTION_CONTEXT(__) then System.unquoteIdentifier(crefStr(cr))
39323932
else cref1(cr,simCode,context)
39333933
end contextCref;
39343934

@@ -5149,6 +5149,29 @@ template daeExpCall(Exp call, Context context, Text &preExp /*BUFP*/,
51495149
case CALL(path=IDENT(name="print"), expLst={e1}) then
51505150
let var1 = daeExp(e1, context, &preExp, &varDecls,simCode)
51515151
if acceptMetaModelicaGrammar() then 'print(<%var1%>)' else 'puts(<%var1%>)'
5152+
5153+
5154+
5155+
case CALL(path=IDENT(name="integer"), expLst={inExp,index}) then
5156+
let exp = daeExp(inExp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)
5157+
let constIndex = daeExp(index, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)
5158+
'(_event_integer(<%exp%>, <%constIndex%>, data))'
5159+
5160+
case CALL(path=IDENT(name="floor"), expLst={inExp,index}, attr=CALL_ATTR(ty = ty)) then
5161+
let exp = daeExp(inExp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)
5162+
let constIndex = daeExp(index, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)
5163+
'((modelica_<%expTypeShort(ty)%>)_event_floor(<%exp%>, <%constIndex%>, data))'
5164+
5165+
case CALL(path=IDENT(name="ceil"), expLst={inExp,index}, attr=CALL_ATTR(ty = ty)) then
5166+
let exp = daeExp(inExp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)
5167+
let constIndex = daeExp(index, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)
5168+
'((modelica_<%expTypeShort(ty)%>)_event_ceil(<%exp%>, <%constIndex%>, data))'
5169+
5170+
5171+
case CALL(path=IDENT(name="integer"), expLst={inExp}) then
5172+
let exp = daeExp(inExp, context, &preExp /*BUFC*/, &varDecls /*BUFD*/,simCode)
5173+
'((int)floor(<%exp%>))'
5174+
51525175

51535176
case CALL(path=IDENT(name="max"), attr=CALL_ATTR(ty = T_REAL(__)), expLst={e1,e2}) then
51545177
let var1 = daeExp(e1, context, &preExp, &varDecls,simCode)

0 commit comments

Comments
 (0)