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

Commit c0983d2

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix equation order for branch selection.
Belonging to [master]: - #2921 - OpenModelica/OpenModelica-testsuite#1120
1 parent e13c41a commit c0983d2

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Compiler/NFFrontEnd/NFFlatten.mo

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -997,7 +997,7 @@ algorithm
997997
algorithm
998998
// Flatten the condition and body of the branch.
999999
cond := flattenExp(cond, prefix);
1000-
eql := listReverseInPlace(flattenEquations(eql, prefix));
1000+
eql := flattenEquations(eql, prefix);
10011001

10021002
// Evaluate structural conditions.
10031003
if var <= Variability.STRUCTURAL_PARAMETER then
@@ -1022,12 +1022,12 @@ algorithm
10221022
equations := listAppend(eql, equations);
10231023
else
10241024
// Otherwise, append this branch.
1025-
bl := Equation.makeBranch(cond, eql, var) :: bl;
1025+
bl := Equation.makeBranch(cond, listReverseInPlace(eql), var) :: bl;
10261026
end if;
10271027
elseif not Expression.isFalse(cond) then
10281028
// Only add the branch to the list of branches if the condition is not
10291029
// literal false, otherwise just drop it since it will never trigger.
1030-
bl := Equation.makeBranch(cond, eql, var) :: bl;
1030+
bl := Equation.makeBranch(cond, listReverseInPlace(eql), var) :: bl;
10311031
end if;
10321032
then
10331033
bl;

Compiler/NFFrontEnd/NFSimplifyModel.mo

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,9 @@ algorithm
376376
if Expression.isTrue(cond) then
377377
if listEmpty(accum) then
378378
// If it's the first branch, remove the if and keep only the branch body.
379-
elements := listAppend(simplifyEquations(body), elements);
379+
for eq in body loop
380+
elements := simplifyEquation(eq, elements);
381+
end for;
380382
return;
381383
else
382384
// Otherwise just discard the rest of the branches.

0 commit comments

Comments
 (0)