Skip to content

Commit

Permalink
[NF] Real range fixes.
Browse files Browse the repository at this point in the history
- Fix constant evaluation of real ranges.
- Expand expressions in SimplifyExp.simplifyBinaryOp before delegating
  to Ceval.evalBinaryOp, since Ceval.evalBinaryOp doesn't handle ranges.

Belonging to [master]:
  - OpenModelica/OMCompiler#2981
  • Loading branch information
perost authored and OpenModelica-Hudson committed Mar 15, 2019
1 parent 2f5968b commit f440207
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFCeval.mo
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ algorithm
result := {Expression.REAL(start)};
else
result := {Expression.REAL(stop)};
for i in steps-1:-1:1 loop
for i in steps-2:-1:1 loop
result := Expression.REAL(start + i * step) :: result;
end for;
result := Expression.REAL(start) :: result;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/NFFrontEnd/NFSimplifyExp.mo
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ function simplifyBinaryOp
import NFOperator.Op;
algorithm
if Expression.isLiteral(exp1) and Expression.isLiteral(exp2) then
outExp := Ceval.evalBinaryOp(exp1, op, exp2);
outExp := Ceval.evalBinaryOp(ExpandExp.expand(exp1), op, ExpandExp.expand(exp2));
else
outExp := match op.op
case Op.ADD then simplifyBinaryAdd(exp1, op, exp2);
Expand Down

0 comments on commit f440207

Please sign in to comment.