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

Commit 695f2e1

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Support function pointers with underscores in them
Fixes ticket:4571 Belonging to [master]: - #2284
1 parent 5aa5373 commit 695f2e1

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Compiler/Template/CodegenCFunctions.tpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5991,9 +5991,11 @@ template daeExpCallTuple(Exp call, Text additionalOutputs /* arguments 2..N */,
59915991
then
59925992
let typeCast1 = generateTypeCast(attr.ty, expLst, true)
59935993
let typeCast2 = generateTypeCast(attr.ty, expLst, false)
5994-
let name = '_<%underscorePath(path)%>'
5995-
let func = '(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(<%name%>), 1)))'
5996-
let closure = '(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(<%name%>), 2)))'
5994+
let n = match path
5995+
case IDENT(__) then contextCref(makeUntypedCrefIdent(name), context, &auxFunction)
5996+
else error(sourceInfo(), 'We only support function pointer calls where the pointer is a local variable (not inside any record). Got: <%underscorePath(path)%>')
5997+
let func = '(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(<%n%>), 1)))'
5998+
let closure = '(MMC_FETCH(MMC_OFFSET(MMC_UNTAGPTR(<%n%>), 2)))'
59975999
let argStrPointer = ('threadData, <%closure%>' + (expLst |> exp => (", " + daeExp(exp, context, &preExp, &varDecls, &auxFunction))))
59986000
//'<%name%>(<%argStr%><%additionalOutputs%>)'
59996001
'<%closure%> ? (<%typeCast1%> <%func%>) (<%argStrPointer%><%additionalOutputs%>) : (<%typeCast2%> <%func%>) (<%argStr%><%additionalOutputs%>)'

0 commit comments

Comments
 (0)