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

Commit 5e28f3c

Browse files
perostOpenModelica-Hudson
authored andcommitted
NFInst improvements.
- Handle enumeration relations in NFSimplifyExp. - Fix case for if-equation in NFConvertDAE.convertInitialEquation so that it generates an initial if-equation instead of a normal one. - Fix NFScalarize.scalarizeIfEquation to handle the case where an if-equation is completely removed due to all conditions being false. Belonging to [master]: - #2016 - OpenModelica/OpenModelica-testsuite#780
1 parent 7c50cbc commit 5e28f3c

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

Compiler/NFFrontEnd/NFConvertDAE.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,7 @@ algorithm
677677
unrollForLoop(eq.iterator, body, elements);
678678

679679
case Equation.IF()
680-
then convertIfEquation(eq.branches, eq.info, isInitial = false) :: elements;
680+
then convertIfEquation(eq.branches, eq.info, isInitial = true) :: elements;
681681

682682
case Equation.ASSERT()
683683
algorithm

Compiler/NFFrontEnd/NFScalarize.mo

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,11 @@ algorithm
190190
end if;
191191
end for;
192192

193-
// Add the scalarized if equation to the list of equations if we got this far.
194-
equations := Equation.IF(listReverseInPlace(bl), info) :: equations;
193+
// Add the scalarized if equation to the list of equations if we got this far,
194+
// and there are any branches still remaining.
195+
if not listEmpty(bl) then
196+
equations := Equation.IF(listReverseInPlace(bl), info) :: equations;
197+
end if;
195198
end scalarizeIfEquation;
196199

197200
function scalarizeBranch

Compiler/NFFrontEnd/NFSimplifyExp.mo

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,17 @@ algorithm
241241
case Operator.GREATEREQ() then Expression.BOOLEAN(r1 >= r2);
242242
end match;
243243

244+
case Expression.RELATION(exp1 = Expression.ENUM_LITERAL(index = i1),
245+
exp2 = Expression.ENUM_LITERAL(index = i2))
246+
then Expression.BOOLEAN(match exp.operator
247+
case Operator.LESS() then i1 < i2;
248+
case Operator.LESSEQ() then i1 <= i2;
249+
case Operator.GREATER() then i1 > i2;
250+
case Operator.GREATEREQ() then i1 >= i2;
251+
case Operator.EQUAL() then i1 == i2;
252+
case Operator.NEQUAL() then i1 <> i2;
253+
end match);
254+
244255
case Expression.IF(condition=Expression.BOOLEAN(value=b1))
245256
then if b1 then exp.trueBranch else exp.falseBranch;
246257

0 commit comments

Comments
 (0)