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

Commit dd340df

Browse files
perostOpenModelica-Hudson
authored andcommitted
[NF] Fix nfExpandOperations with unary ops.
Belonging to [master]: - #2633 - OpenModelica/OpenModelica-testsuite#1023
1 parent b8a0777 commit dd340df

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Compiler/NFFrontEnd/NFExpandExp.mo

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,13 @@ public
832832
function makeUnaryOp
833833
input Expression exp1;
834834
input Operator op;
835-
output Expression exp = Expression.UNARY(op, exp1);
835+
output Expression exp;
836+
algorithm
837+
if Expression.isScalarLiteral(exp1) then
838+
exp := Ceval.evalUnaryOp(exp1, op);
839+
else
840+
exp := Expression.UNARY(op, exp1);
841+
end if;
836842
end makeUnaryOp;
837843

838844
function expandLogicalBinary

Compiler/NFFrontEnd/NFSimplifyExp.mo

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,9 @@ algorithm
292292
Expression.UNARY(op, e) := unaryExp;
293293
se := simplify(e);
294294

295-
if Expression.isLiteral(se) then
295+
if Flags.isSet(Flags.NF_EXPAND_OPERATIONS) then
296+
unaryExp := ExpandExp.expand(ExpandExp.makeUnaryOp(se, op));
297+
elseif Expression.isLiteral(se) then
296298
unaryExp := Ceval.evalUnaryOp(se, op);
297299
elseif not referenceEq(e, se) then
298300
unaryExp := Expression.UNARY(op, se);

0 commit comments

Comments
 (0)