Skip to content

Commit

Permalink
[janitor] Remove unnecessary wrapper (#8566)
Browse files Browse the repository at this point in the history
  • Loading branch information
phannebohm committed Feb 16, 2022
1 parent 2590823 commit 9bca51e
Showing 1 changed file with 29 additions and 37 deletions.
66 changes: 29 additions & 37 deletions OMCompiler/Compiler/FrontEnd/Expression.mo
Expand Up @@ -7890,7 +7890,7 @@ public function isImpure "author: lochel
input DAE.Exp inExp;
output Boolean outBoolean;
algorithm
outBoolean := isConstWork(inExp);
outBoolean := isConst(inExp);
(_, outBoolean) := traverseExpTopDown(inExp, isImpureWork, false);
end isImpure;

Expand Down Expand Up @@ -7988,14 +7988,6 @@ algorithm
end if;
end containsRecordTypeWork;

public function isConst
"Returns true if an expression is constant"
input DAE.Exp inExp;
output Boolean outBoolean;
algorithm
outBoolean := isConstWork(inExp);
end isConst;

public function isEvaluatedConst
"Returns true if an expression is really a constant scalar value. no calls, casts, or something"
input DAE.Exp inExp;
Expand Down Expand Up @@ -8043,7 +8035,7 @@ algorithm
end match;
end getEvaluatedConstReal;

protected function isConstWork
public function isConst
"Returns true if an expression is constant"
input DAE.Exp inExp;
output Boolean outBoolean;
Expand All @@ -8064,77 +8056,77 @@ algorithm
case (DAE.SCONST()) then true;
case (DAE.ENUM_LITERAL()) then true;

case (DAE.UNARY(exp = e)) then isConstWork(e);
case (DAE.UNARY(exp = e)) then isConst(e);

case (DAE.CAST(exp = e)) then isConstWork(e);
case (DAE.CAST(exp = e)) then isConst(e);

case (DAE.BINARY(e1,_,e2))
equation
res = isConstWork(e2);
res = isConst(e2);
then
if res then isConstWork(e1) else false;
if res then isConst(e1) else false;

case (DAE.IFEXP(e,e1,e2))
equation
res = isConstWork(e2);
res = isConst(e2);
if res then
res = isConstWork(e1);
res = isConst(e1);
end if;
then
if res then isConstWork(e) else false;
if res then isConst(e) else false;

case (DAE.LBINARY(exp1=e1,exp2=e2))
equation
res = isConstWork(e2);
res = isConst(e2);
then
if res then isConstWork(e1) else false;
if res then isConst(e1) else false;

case (DAE.LUNARY(exp=e)) then isConstWork(e);
case (DAE.LUNARY(exp=e)) then isConst(e);

case (DAE.RELATION(exp1=e1,exp2=e2))
equation
res = isConstWork(e2);
res = isConst(e2);
then
if res then isConstWork(e1) else false;
if res then isConst(e1) else false;

case (DAE.ARRAY(array = ae)) then isConstWorkList(ae);

case (DAE.MATRIX(matrix = matrix)) then isConstWorkListList(matrix);

case (DAE.RANGE(start=e1,step=NONE(),stop=e2))
equation
res = isConstWork(e2);
res = isConst(e2);
then
if res then isConstWork(e1) else false;
if res then isConst(e1) else false;

case (DAE.RANGE(start=e,step=SOME(e1),stop=e2))
equation
res = isConstWork(e2);
res = isConst(e2);
if res then
res = isConstWork(e1);
res = isConst(e1);
end if;
then
if res then isConstWork(e) else false;
if res then isConst(e) else false;

case (DAE.PARTEVALFUNCTION(expList = ae)) then isConstWorkList(ae);

case (DAE.TUPLE(PR = ae)) then isConstWorkList(ae);

case (DAE.ASUB(exp=e,sub=ae))
equation
res = isConstWork(e);
res = isConst(e);
then
if res then isConstWorkList(ae) else false;

case (DAE.TSUB(exp=e)) then isConstWork(e);
case (DAE.TSUB(exp=e)) then isConst(e);

case (DAE.SIZE(exp=e,sz=NONE())) then isConstWork(e);
case (DAE.SIZE(exp=e,sz=NONE())) then isConst(e);

case (DAE.SIZE(exp=e1,sz=SOME(e2)))
equation
res = isConstWork(e2);
res = isConst(e2);
then
if res then isConstWork(e1) else false;
if res then isConst(e1) else false;

case (DAE.CALL(expLst=ae, attr=DAE.CALL_ATTR(builtin=false, isImpure=false))) then isConstWorkList(ae);
case (DAE.CALL(path=path, expLst=ae, attr=DAE.CALL_ATTR(builtin=true))) then
Expand All @@ -8147,15 +8139,15 @@ algorithm
/*TODO:Make this work for multiple iters, guard exps*/
case (DAE.REDUCTION(expr=e1,iterators={DAE.REDUCTIONITER(exp=e2)}))
equation
res = isConstWork(e2);
res = isConst(e2);
then
if res then isConstWork(e1) else false;
if res then isConst(e1) else false;

case(DAE.BOX(exp=e)) then isConstWork(e);
case(DAE.BOX(exp=e)) then isConst(e);

else false;
end match;
end isConstWork;
end isConst;

protected function isConstValueWork
"Returns true if an expression is a constant value"
Expand Down Expand Up @@ -8203,7 +8195,7 @@ algorithm
exps := inExps;
while b and not listEmpty(exps) loop
e::exps := exps;
b := isConstWork(e);
b := isConst(e);
end while;
outBoolean := b;
end isConstWorkList;
Expand Down

0 comments on commit 9bca51e

Please sign in to comment.