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

Commit 1871ad3

Browse files
adrpoOpenModelica-Hudson
authored andcommitted
add more operators and builtin functions to the embedded codegen
Belonging to [master]: - #2866
1 parent da97141 commit 1871ad3

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Compiler/Template/CodegenEmbeddedC.tpl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,8 @@ template daeExpBinary(Exp exp1, Operator op, Exp exp2, Exp origExp)
466466
case ADD(__) then '(<%daeExp(exp1)%>)+(<%daeExp(exp2)%>)'
467467
case SUB(__) then '(<%daeExp(exp1)%>)-(<%daeExp(exp2)%>)'
468468
case MUL(__) then '(<%daeExp(exp1)%>)*(<%daeExp(exp2)%>)'
469+
case DIV(__) then '(<%daeExp(exp1)%>)/(<%daeExp(exp2)%>)' // TODO: some division by zero handling will be needed
470+
case POW(__) then 'pow((<%daeExp(exp1)%>),(<%daeExp(exp2)%>))' // TODO: check sqrt of < 0
469471

470472
case GREATER(__) then '(<%daeExp(exp1)%>)>(<%daeExp(exp2)%>)'
471473
case GREATEREQ(__) then '(<%daeExp(exp1)%>)>=(<%daeExp(exp2)%>)'
@@ -500,6 +502,10 @@ template daeExpCallBuiltin(Exp exp)
500502
then '<%name%>(<%daeExp(exp1)%>,<%daeExp(exp2)%>)'
501503
/* TODO: Generate used builtin functions before SimCode */
502504
case CALL(path=IDENT(name="mod"),expLst=exp1::exp2::_) then 'om_mod(<%daeExp(exp1)%>,<%daeExp(exp2)%>)'
505+
/* no events for foor and ceil */
506+
case CALL(path=IDENT(name="floor"),expLst=exp1::exp2::_) then 'floor(<%daeExp(exp1)%>)'
507+
case CALL(path=IDENT(name="ceil"),expLst=exp1::exp2::_) then 'ceil(<%daeExp(exp1)%>)'
508+
503509
/* TODO: pre needs to be handled in a special way */
504510
case CALL(path=IDENT(name="pre"),expLst={exp1}) then daeExp(exp1)
505511
case CALL(__) then error(sourceInfo(), 'daeExpCallBuiltin: Not supported: <%ExpressionDumpTpl.dumpExp(exp,"\"")%>')

0 commit comments

Comments
 (0)