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

Commit

Permalink
add more operators and builtin functions to the embedded codegen
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - #2866
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Jan 13, 2019
1 parent da97141 commit 1871ad3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Compiler/Template/CodegenEmbeddedC.tpl
Expand Up @@ -466,6 +466,8 @@ template daeExpBinary(Exp exp1, Operator op, Exp exp2, Exp origExp)
case ADD(__) then '(<%daeExp(exp1)%>)+(<%daeExp(exp2)%>)'
case SUB(__) then '(<%daeExp(exp1)%>)-(<%daeExp(exp2)%>)'
case MUL(__) then '(<%daeExp(exp1)%>)*(<%daeExp(exp2)%>)'
case DIV(__) then '(<%daeExp(exp1)%>)/(<%daeExp(exp2)%>)' // TODO: some division by zero handling will be needed
case POW(__) then 'pow((<%daeExp(exp1)%>),(<%daeExp(exp2)%>))' // TODO: check sqrt of < 0

case GREATER(__) then '(<%daeExp(exp1)%>)>(<%daeExp(exp2)%>)'
case GREATEREQ(__) then '(<%daeExp(exp1)%>)>=(<%daeExp(exp2)%>)'
Expand Down Expand Up @@ -500,6 +502,10 @@ template daeExpCallBuiltin(Exp exp)
then '<%name%>(<%daeExp(exp1)%>,<%daeExp(exp2)%>)'
/* TODO: Generate used builtin functions before SimCode */
case CALL(path=IDENT(name="mod"),expLst=exp1::exp2::_) then 'om_mod(<%daeExp(exp1)%>,<%daeExp(exp2)%>)'
/* no events for foor and ceil */
case CALL(path=IDENT(name="floor"),expLst=exp1::exp2::_) then 'floor(<%daeExp(exp1)%>)'
case CALL(path=IDENT(name="ceil"),expLst=exp1::exp2::_) then 'ceil(<%daeExp(exp1)%>)'

/* TODO: pre needs to be handled in a special way */
case CALL(path=IDENT(name="pre"),expLst={exp1}) then daeExp(exp1)
case CALL(__) then error(sourceInfo(), 'daeExpCallBuiltin: Not supported: <%ExpressionDumpTpl.dumpExp(exp,"\"")%>')
Expand Down

0 comments on commit 1871ad3

Please sign in to comment.