Skip to content

Commit 69ec413

Browse files
author
Jens Frenkel
committed
- add case for simplifyIfExp as workaround for real and integer types, see Ticket #1787
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12679 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 6c41f52 commit 69ec413

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Compiler/FrontEnd/ExpressionSimplify.mo

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,29 @@ protected function simplifyIfExp
515515
output DAE.Exp exp;
516516
algorithm
517517
exp := match (cond,tb,fb)
518-
local
518+
local
519+
Real r;
520+
Integer i;
521+
Boolean b,b1;
522+
DAE.Exp e;
519523
// Condition is constant
520524
case (DAE.BCONST(true),tb,fb) then tb;
521525
case (DAE.BCONST(false),tb,fb) then fb;
526+
// because ther is somewhere an error (maybe eval return reals instead of bools)
527+
case (DAE.RCONST(r),tb,fb)
528+
equation
529+
b = r ==. 1.0;
530+
b1 = r ==. 0.0;
531+
true = b or b1;
532+
then
533+
Util.if_(b,tb,fb);
534+
case (DAE.ICONST(i),tb,fb)
535+
equation
536+
b = i == 1;
537+
b1 = i == 0;
538+
true = b or b1;
539+
then
540+
Util.if_(b,tb,fb);
522541
// The expression is the condition
523542
case (exp,DAE.BCONST(true),DAE.BCONST(false)) then exp;
524543
case (exp,DAE.BCONST(false),DAE.BCONST(true))

0 commit comments

Comments
 (0)