Skip to content

Commit

Permalink
[NF] Fix nfExpandOperations with unary ops.
Browse files Browse the repository at this point in the history
  • Loading branch information
perost authored and OpenModelica-Hudson committed Sep 5, 2018
1 parent b8a0777 commit dd340df
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 7 additions & 1 deletion Compiler/NFFrontEnd/NFExpandExp.mo
Expand Up @@ -832,7 +832,13 @@ public
function makeUnaryOp
input Expression exp1;
input Operator op;
output Expression exp = Expression.UNARY(op, exp1);
output Expression exp;
algorithm
if Expression.isScalarLiteral(exp1) then
exp := Ceval.evalUnaryOp(exp1, op);
else
exp := Expression.UNARY(op, exp1);
end if;
end makeUnaryOp;

function expandLogicalBinary
Expand Down
4 changes: 3 additions & 1 deletion Compiler/NFFrontEnd/NFSimplifyExp.mo
Expand Up @@ -292,7 +292,9 @@ algorithm
Expression.UNARY(op, e) := unaryExp;
se := simplify(e);

if Expression.isLiteral(se) then
if Flags.isSet(Flags.NF_EXPAND_OPERATIONS) then
unaryExp := ExpandExp.expand(ExpandExp.makeUnaryOp(se, op));
elseif Expression.isLiteral(se) then
unaryExp := Ceval.evalUnaryOp(se, op);
elseif not referenceEq(e, se) then
unaryExp := Expression.UNARY(op, se);
Expand Down

0 comments on commit dd340df

Please sign in to comment.