Skip to content

Commit

Permalink
get rid of some matchcontinue statements
Browse files Browse the repository at this point in the history
  • Loading branch information
hkiel committed Jan 26, 2016
1 parent b04455e commit b1fb7f9
Show file tree
Hide file tree
Showing 4 changed files with 101 additions and 157 deletions.
31 changes: 5 additions & 26 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -3374,18 +3374,7 @@ protected function getOldVars
input Integer pos;
output list<Integer> oldvars;
algorithm
oldvars := matchcontinue(m,pos)
local
Integer alen;
case(_,_)
equation
alen = arrayLength(m);
(pos <= alen) = true;
oldvars = m[pos];
then
oldvars;
case (_,_) then {};
end matchcontinue;
oldvars := if pos <= arrayLength(m) then m[pos] else {};
end getOldVars;

protected function removeValuefromMatrix
Expand Down Expand Up @@ -5240,7 +5229,7 @@ public function solvabilityCMP
input BackendDAE.Solvability sb;
output Boolean b;
algorithm
b := matchcontinue(sa,sb)
b := match(sa,sb)
case (BackendDAE.SOLVABILITY_SOLVED(),BackendDAE.SOLVABILITY_SOLVED()) then false;
case (_,BackendDAE.SOLVABILITY_SOLVED()) then true;
case (BackendDAE.SOLVABILITY_SOLVED(),BackendDAE.SOLVABILITY_CONSTONE()) then false;
Expand Down Expand Up @@ -5270,7 +5259,7 @@ algorithm
case (_,BackendDAE.SOLVABILITY_NONLINEAR()) then true;
case (BackendDAE.SOLVABILITY_UNSOLVABLE(),BackendDAE.SOLVABILITY_UNSOLVABLE()) then false;
case (BackendDAE.SOLVABILITY_UNSOLVABLE(),_) then true;
end matchcontinue;
end match;
end solvabilityCMP;

public function getArrayEquationSub"author: Frenkel TUD
Expand Down Expand Up @@ -8359,38 +8348,29 @@ algorithm
list<Integer> l1,l2,k1,k2;
list<tuple<Integer,list<Integer>>> l3,k3;
case(BackendDAE.SINGLEEQUATION(eqn=i1,var=i2),BackendDAE.SINGLEEQUATION(eqn=j1,var=j2))
equation
then intEq(i1,j1) and intEq(i2,j2);

case(BackendDAE.EQUATIONSYSTEM(eqns=l1,vars=l2),BackendDAE.EQUATIONSYSTEM(eqns=k1,vars=k2))
equation
then List.isEqualOnTrue(l1,k1,intEq) and List.isEqualOnTrue(l2,k2,intEq);

case(BackendDAE.SINGLEARRAY(eqn=i1,vars=l1),BackendDAE.SINGLEARRAY(eqn=j1,vars=k1))
equation
then intEq(i1,j1) and List.isEqualOnTrue(l1,k1,intEq);

case(BackendDAE.SINGLEALGORITHM(eqn=i1,vars=l1),BackendDAE.SINGLEALGORITHM(eqn=j1,vars=k1))
equation
then intEq(i1,j1) and List.isEqualOnTrue(l1,k1,intEq);

case(BackendDAE.SINGLECOMPLEXEQUATION(eqn=i1,vars=l1),BackendDAE.SINGLECOMPLEXEQUATION(eqn=j1,vars=k1))
equation
then intEq(i1,j1) and List.isEqualOnTrue(l1,k1,intEq);

case(BackendDAE.SINGLEWHENEQUATION(eqn=i1,vars=l1),BackendDAE.SINGLEWHENEQUATION(eqn=j1,vars=k1))
equation
then intEq(i1,j1) and List.isEqualOnTrue(l1,k1,intEq);

case(BackendDAE.SINGLEIFEQUATION(eqn=i1,vars=l1),BackendDAE.SINGLEIFEQUATION(eqn=j1,vars=k1))
equation
then intEq(i1,j1) and List.isEqualOnTrue(l1,k1,intEq);

case(BackendDAE.TORNSYSTEM(strictTearingSet=BackendDAE.TEARINGSET(tearingvars=l1,residualequations=l2,otherEqnVarTpl=l3)),BackendDAE.TORNSYSTEM(strictTearingSet=BackendDAE.TEARINGSET(tearingvars=k1,residualequations=k2,otherEqnVarTpl=k3)))
equation
then List.isEqualOnTrue(l1,k1,intEq) and List.isEqualOnTrue(l2,k2,intEq) and List.isEqualOnTrue(l3,k3,otherEqnVarTplEqual);
else
then false;
else false;
end matchcontinue;
end componentsEqual;

Expand All @@ -8404,11 +8384,10 @@ algorithm
Integer i1,i2;
list<Integer> l1,l2;
case((i1,l1),(i2,l2))
equation
then intEq(i1,i2) and List.isEqualOnTrue(l1,l2,intEq);

else
then false;
false;
end matchcontinue;
end otherEqnVarTplEqual;

Expand Down
12 changes: 6 additions & 6 deletions Compiler/BackEnd/BackendVarTransform.mo
Expand Up @@ -1560,19 +1560,19 @@ public function skipPreOperator "The variable/exp in the pre operator should not
input DAE.Exp inExp;
output Boolean outBoolean;
algorithm
outBoolean := matchcontinue (inExp)
outBoolean := match (inExp)
case (DAE.CALL(path = Absyn.IDENT(name = "pre"))) then false;
case (DAE.CALL(path = Absyn.IDENT(name = "previous"))) then false;
case (_) then true;
end matchcontinue;
else true;
end match;
end skipPreOperator;

public function skipPreChangeEdgeOperator "The variable/exp in the pre/change/edge operator should not be replaced.
This function is passed to replace_exp to ensure this."
input DAE.Exp inExp;
output Boolean outBoolean;
algorithm
outBoolean := matchcontinue (inExp)
outBoolean := match (inExp)
local
DAE.ComponentRef cr;
case DAE.CALL(path = Absyn.IDENT(name = "pre"),expLst = {DAE.CREF(componentRef=cr)}) then selfGeneratedVar(cr);
Expand All @@ -1583,8 +1583,8 @@ algorithm
case DAE.CALL(path = Absyn.IDENT(name = "previous")) then false;
case DAE.CALL(path = Absyn.IDENT(name = "change")) then false;
case DAE.CALL(path = Absyn.IDENT(name = "edge")) then false;
case (_) then true;
end matchcontinue;
else true;
end match;
end skipPreChangeEdgeOperator;

protected function selfGeneratedVar
Expand Down

0 comments on commit b1fb7f9

Please sign in to comment.