Skip to content

Commit

Permalink
- remove local variables with same name as inputs
Browse files Browse the repository at this point in the history
- fix tests

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12578 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Aug 17, 2012
1 parent 2f089f6 commit 871a1a0
Show file tree
Hide file tree
Showing 25 changed files with 78 additions and 80 deletions.
3 changes: 1 addition & 2 deletions Compiler/BackEnd/BackendDAECreate.mo
Original file line number Diff line number Diff line change
Expand Up @@ -2692,7 +2692,7 @@ protected function zerocrossingindex
algorithm
out_exp := matchcontinue (exp,index,zeroCrossings,/*inputzeroinfo,*/zc)
local
DAE.Exp exp,e_1,e1,e2;
DAE.Exp e_1,e1,e2;
DAE.Operator op;
list<BackendDAE.ZeroCrossing> newzero,zc_lst;
BackendDAE.ZeroCrossing z_c;
Expand Down Expand Up @@ -3068,7 +3068,6 @@ algorithm
local
list<DAE.Statement> statementLst;
DAE.Exp ie,range;
list<DAE.Exp> inExplst;
BackendDAE.Variables v,kn;
list<BackendDAE.ZeroCrossing> zcs;
Integer idx,alg_idx;
Expand Down
32 changes: 26 additions & 6 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1293,7 +1293,7 @@ algorithm
ordvarslst = BackendVariable.equationSystemsVarsLst(systs,{});
ordvars = BackendDAEUtil.listVar(ordvarslst);
// replace moved vars in knvars,ineqns,remeqns
(aliasVars,_) = BackendVariable.traverseBackendDAEVarsWithUpdate(aliasVars,replaceVarTraverser,repl);
(aliasVars,_) = BackendVariable.traverseBackendDAEVarsWithUpdate(aliasVars,replaceAliasVarTraverser,repl);
(knvars1,_) = BackendVariable.traverseBackendDAEVarsWithUpdate(knvars,replaceVarTraverser,repl);
(inieqns1,_) = BackendEquation.traverseBackendDAEEqnsWithUpdate(inieqns,replaceEquationTraverser,repl);
(remeqns1,_) = BackendEquation.traverseBackendDAEEqnsWithUpdate(remeqns,replaceEquationTraverser,repl);
Expand Down Expand Up @@ -1328,6 +1328,27 @@ algorithm
end match;
end removeSimpleEquationsUpdateWrapper;

protected function replaceAliasVarTraverser
"autor: Frenkel TUD 2011-03"
input tuple<BackendDAE.Var, BackendVarTransform.VariableReplacements> inTpl;
output tuple<BackendDAE.Var, BackendVarTransform.VariableReplacements> outTpl;
algorithm
outTpl:=
matchcontinue (inTpl)
local
BackendDAE.Var v,v1;
BackendVarTransform.VariableReplacements repl;
DAE.Exp e,e1;
case ((v as BackendDAE.VAR(bindExp=SOME(e)),repl))
equation
(e1,true) = BackendVarTransform.replaceExp(e, repl, NONE());
false = Expression.isConst(e1);
v1 = BackendVariable.setBindExp(v,e1);
then ((v1,repl));
case inTpl then inTpl;
end matchcontinue;
end replaceAliasVarTraverser;

protected function replaceVarTraverser
"autor: Frenkel TUD 2011-03"
input tuple<BackendDAE.Var, BackendVarTransform.VariableReplacements> inTpl;
Expand Down Expand Up @@ -5950,7 +5971,7 @@ algorithm
list<tuple<Real,BackendDAE.Value>> rest;
Real weight,oldWeight;
BackendDAE.Value var,oldVar;
tuple<Real,BackendDAE.Value> tupl,oldTupl;
tuple<Real,BackendDAE.Value> tupl;
list<BackendDAE.Value> exclude;
case ((weight,var)::rest,(oldWeight,oldVar),exclude)
equation
Expand Down Expand Up @@ -8674,7 +8695,6 @@ algorithm
outExpList := matchcontinue (inExp, indiffVars, func, inTypeA)
local
DAE.Exp e,e1;
FuncExpType func;
DAE.ComponentRef diff_cref;
list<DAE.ComponentRef> rest;
list<DAE.Exp> res;
Expand Down Expand Up @@ -9173,11 +9193,11 @@ protected function partitionIndependentBlocksHelper
"Finds independent partitions of the equation system by "
input BackendDAE.EqSystem isyst;
input BackendDAE.Shared ishared;
input Integer i;
input Integer numErrorMessages;
output list<BackendDAE.EqSystem> systs;
output BackendDAE.Shared oshared;
algorithm
(systs,oshared) := matchcontinue (isyst,ishared,i)
(systs,oshared) := matchcontinue (isyst,ishared,numErrorMessages)
local
BackendDAE.IncidenceMatrix m,mT;
array<Integer> ixs;
Expand All @@ -9201,7 +9221,7 @@ algorithm
then (systs,shared);
else
equation
Error.assertion(not (i==Error.getNumErrorMessages()),"BackendDAEOptimize.partitionIndependentBlocks failed without good error message",Absyn.dummyInfo);
Error.assertion(not (numErrorMessages==Error.getNumErrorMessages()),"BackendDAEOptimize.partitionIndependentBlocks failed without good error message",Absyn.dummyInfo);
then fail();
end matchcontinue;
end partitionIndependentBlocksHelper;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/BackendDAETransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ algorithm
BackendDAE.IncidenceMatrixT mt;
Integer i_1,nv_1,nf_1,nvd,an1,am1,an2,am2;
BackendDAE.MatchingOptions match_opts;
BackendDAE.EquationArray eqns;
BackendDAE.EquationArray eqnsarr;
BackendDAE.EquationConstraints eq_cons;
list<Integer> eqn_lst,var_lst,meqns;
String eqn_str,var_str;
Expand Down Expand Up @@ -479,8 +479,8 @@ algorithm
the original equation is removed from the system." ;
ass1_1 = BackendDAE.ASSIGNMENTS(an1,am1,vec1);
ass2_1 = BackendDAE.ASSIGNMENTS(an2,am2,vec2);
eqns = BackendEquation.daeEqns(syst);
nf_1 = BackendDAEUtil.equationSize(eqns) "and try again, restarting. This could be optimized later. It should not
eqnsarr = BackendEquation.daeEqns(syst);
nf_1 = BackendDAEUtil.equationSize(eqnsarr) "and try again, restarting. This could be optimized later. It should not
be necessary to restart the matching, according to Bernard Bachmann. Instead one
could continue the matching as usual. This was tested (2004-11-22) and it does not
work to continue without restarting.
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/BackendDAEUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6261,7 +6261,7 @@ protected function adjacencyRowEnhanced3
algorithm
oSolvab := matchcontinue(b1,b2,cr,e,crlst,vars,kvars)
local
Boolean b,b1;
Boolean b,b_1;
DAE.Exp e1;
case(true,true,_,_,_,_,_)
equation
Expand All @@ -6280,9 +6280,9 @@ algorithm
((e1,_)) = Expression.traverseExp(e, replaceVartraverser, kvars);
(e1,_) = ExpressionSimplify.simplify(e1);
b = not Expression.isZero(e1);
b1 = Expression.isConst(e1);
b_1 = Expression.isConst(e1);
then
Util.if_(b1,BackendDAE.SOLVABILITY_PARAMETER(b),BackendDAE.SOLVABILITY_TIMEVARYING(b));
Util.if_(b_1,BackendDAE.SOLVABILITY_PARAMETER(b),BackendDAE.SOLVABILITY_TIMEVARYING(b));
case(_,_,_,_,_,_,_)
equation
b = not Expression.isZero(e);
Expand Down
2 changes: 1 addition & 1 deletion Compiler/BackEnd/BackendVarTransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ algorithm
matchcontinue (extendrepl,cr,preCr)
local
HashTable2.HashTable erepl,erepl1;
DAE.ComponentRef cr,subcr,precr,precr1,pcr,precrn,precrn1;
DAE.ComponentRef subcr,precr,precr1,pcr,precrn,precrn1;
DAE.Ident ident;
DAE.Type ty;
list<DAE.Subscript> subscriptLst;
Expand Down
6 changes: 3 additions & 3 deletions Compiler/BackEnd/Matching.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4178,7 +4178,7 @@ protected function PR_Global_Relabel1
algorithm
_ := matchcontinue(queue,l_label,r_label,max,nv,ne,m,mT,ass1,ass2,nextqueue)
local
list<Integer> rest,collums,queue;
list<Integer> rest,collums,queue1;
Integer r;
case({},_,_,_,_,_,_,_,_,_,{}) then ();
case({},_,_,_,_,_,_,_,_,_,_)
Expand All @@ -4189,8 +4189,8 @@ algorithm
case(r::rest,_,_,_,_,_,_,_,_,_,_)
equation
collums = List.select(mT[r], Util.intPositive);
queue = PR_Global_Relabel_traverseCollums(collums,max,r,l_label,r_label,nv,ne,m,mT,ass1,ass2,nextqueue);
PR_Global_Relabel1(rest,l_label,r_label,max,nv,ne,m,mT,ass1,ass2,queue);
queue1 = PR_Global_Relabel_traverseCollums(collums,max,r,l_label,r_label,nv,ne,m,mT,ass1,ass2,nextqueue);
PR_Global_Relabel1(rest,l_label,r_label,max,nv,ne,m,mT,ass1,ass2,queue1);
then
();
end matchcontinue;
Expand Down
30 changes: 15 additions & 15 deletions Compiler/BackEnd/OnRelaxation.mo
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ algorithm
ocolummarks = List.fold1(eorphans,markOrphans,1,ocolummarks);
mark = getIndexesForEqnsAdvanced(vorphans,1,m,mt,mark,rowmarks,colummarks,orowmarks,ocolummarks,ass1,ass22,vec1,vec2,arrayCreate(esize,false), vars,eqns,shared,size);

BackendDump.dumpIncidenceMatrix(vec1);
BackendDump.dumpMatching(vec2);
// BackendDump.dumpIncidenceMatrix(vec1);
// BackendDump.dumpMatching(vec2);
// vec3 = arrayCreate(size,-1);
// _ = List.fold1(arrayList(vec2),transposeOrphanVec,vec3,1);
// IndexReduction.dumpSystemGraphML(subsyst,shared,SOME(vec3),"System.graphml");
Expand All @@ -336,7 +336,7 @@ algorithm
dumpMatrix(1,size,matrix);
ht = HashTable4.emptyHashTable();
(tvars,teqns) = gaussElimination(1,size,matrix,BackendDAEUtil.emptyVars(),BackendDAEUtil.listEquation({}),(1,1));
// dumpMatrix(1,size,matrix);
dumpMatrix(1,size,matrix);
// subsyst = BackendDAE.EQSYSTEM(tvars,teqns,NONE(),NONE(),BackendDAE.NO_MATCHING());
// BackendDump.dumpEqSystem(subsyst);
eqn_lst = BackendDAEUtil.equationList(teqns);
Expand Down Expand Up @@ -568,7 +568,7 @@ algorithm
(omark,oconstraints) := matchcontinue(inOrphans,ass1,ass2,m,mt,mark,rowmarks,colummarks,vars,iconstraints)
local
list<Integer> rest,constraints,rlst,elst,partner;
Integer o,mark;
Integer o;
Boolean foundflow;
list<Boolean> blst;
list<BackendDAE.Var> vlst;
Expand Down Expand Up @@ -596,14 +596,14 @@ algorithm
foundflow = generateCliquesResidual1(rlst,ass1,ass2,m,mt,mark,rowmarks,colummarks,foundflow,vars);
generateCliquesResidual2(rlst,ass1,ass2,m,mt,mark+1,rowmarks,colummarks,o::partner);
constraints = Debug.bcallret2(not foundflow, listAppend, o::partner, iconstraints, iconstraints);
(mark,constraints) = generateCliquesResidual(rest,ass1,ass2,m,mt,mark,rowmarks,colummarks,vars,constraints);
(omark,constraints) = generateCliquesResidual(rest,ass1,ass2,m,mt,mark,rowmarks,colummarks,vars,constraints);
then
(mark,constraints);
(omark,constraints);
case (_::rest,_,_,_,_,_,_,_,_,_)
equation
(mark,constraints) = generateCliquesResidual(rest,ass1,ass2,m,mt,mark,rowmarks,colummarks,vars,iconstraints);
(omark,constraints) = generateCliquesResidual(rest,ass1,ass2,m,mt,mark,rowmarks,colummarks,vars,iconstraints);
then
(mark,constraints);
(omark,constraints);
end matchcontinue;
end generateCliquesResidual;

Expand Down Expand Up @@ -808,7 +808,7 @@ algorithm
(omark,oroots,oconstraints) := matchcontinue(inOrphans,ass1,ass2,m,mt,mark,rowmarks,colummarks,orphans,vars,iroots,iconstraints)
local
list<Integer> rest,roots,constraints,elst,rlst;
Integer o,mark;
Integer o;
Boolean foundflow,constr;
list<Boolean> blst;
list<BackendDAE.Var> vlst;
Expand All @@ -831,14 +831,14 @@ algorithm
// BackendDump.debuglst((mt[o],intString,", ","\n"));
foundflow = prepairOrphansOrder1(mt[o],ass1,ass2,m,mt,mark,rowmarks,colummarks,o,orphans,{o},false,vars);
roots = List.consOnTrue(foundflow and not constr, o, iroots);
(mark,roots,constraints) = prepairOrphansOrder(rest,ass1,ass2,m,mt,mark+1,rowmarks,colummarks,orphans,vars,roots,constraints);
(omark,roots,constraints) = prepairOrphansOrder(rest,ass1,ass2,m,mt,mark+1,rowmarks,colummarks,orphans,vars,roots,constraints);
then
(mark,roots,constraints);
(omark,roots,constraints);
case (_::rest,_,_,_,_,_,_,_,_,_,_,_)
equation
(mark,roots,constraints) = prepairOrphansOrder(rest,ass1,ass2,m,mt,mark,rowmarks,colummarks,orphans,vars,iroots,iconstraints);
(omark,roots,constraints) = prepairOrphansOrder(rest,ass1,ass2,m,mt,mark,rowmarks,colummarks,orphans,vars,iroots,iconstraints);
then
(mark,roots,constraints);
(omark,roots,constraints);
end matchcontinue;
end prepairOrphansOrder;

Expand Down Expand Up @@ -1830,7 +1830,7 @@ algorithm
s := stringAppendList({cs,":",es});
end dumpMatrix1;

protected function dumpMatrix
public function dumpMatrix
"function dumpMatrix
author: Frenkel TUD 2012-05"
input Integer row;
Expand Down Expand Up @@ -2275,7 +2275,7 @@ algorithm
end matchcontinue;
end transformJacToIncidenceMatrix;

protected function transformJacToMatrix
public function transformJacToMatrix
input list<tuple<Integer, Integer, BackendDAE.Equation>> jac;
input Integer row;
input Integer col;
Expand Down
11 changes: 5 additions & 6 deletions Compiler/BackEnd/SimCode.mo
Original file line number Diff line number Diff line change
Expand Up @@ -4779,8 +4779,8 @@ protected function createOdeSystem
input Boolean genDiscrete "if true generate discrete equations";
input Boolean skipDiscInAlgorithm "if true skip discrete algorithm vars";
input Boolean linearSystem "if true generate allway a linear system";
input BackendDAE.EqSystem syst;
input BackendDAE.Shared shared;
input BackendDAE.EqSystem isyst;
input BackendDAE.Shared ishared;
input BackendDAE.StrongComponent inComp;
input list<HelpVarInfo> helpVarInfo;
input Integer iuniqueEqIndex;
Expand All @@ -4791,7 +4791,7 @@ protected function createOdeSystem
output list<SimVar> otempvars;
algorithm
(equations_,noDiscequations_,ouniqueEqIndex,otempvars) :=
matchcontinue(genDiscrete, skipDiscInAlgorithm, linearSystem, syst, shared, inComp, helpVarInfo, iuniqueEqIndex,itempvars)
matchcontinue(genDiscrete, skipDiscInAlgorithm, linearSystem, isyst, ishared, inComp, helpVarInfo, iuniqueEqIndex,itempvars)
local
list<BackendDAE.Equation> eqn_lst,cont_eqn,disc_eqn;
list<BackendDAE.Var> var_lst,cont_var,disc_var,var_lst_1;
Expand Down Expand Up @@ -7880,6 +7880,7 @@ algorithm
// does not work
//e = BaseHashTable.get(name,varMappings);
e = BackendVariable.varBindExp(var);
(e,_) = ExpressionSimplify.simplify(e);
alias = getAliasVar1(e,var);
then alias;
case(_,_) then NOALIAS();
Expand Down Expand Up @@ -10724,7 +10725,6 @@ end addNoUpdCheck;
array<list<tuple<Key,Integer>>> hashvec_1,hashvec;
String name_str;
tuple<Key,Value> v,newv;
Key key;
Value value;
// * adding when already present => Updating value * /
case (key,(hashTable as HASHTABLE(hashvec,varr,bsize,n)))
Expand Down Expand Up @@ -10998,7 +10998,7 @@ end valueArraySetnth;
matchcontinue (valueArray,pos)
local
array<Option<tuple<Key,Value>>> arr_1,arr;
Integer n,size,pos;
Integer n,size;
case (VALUE_ARRAY(n,size,arr),pos)
equation
(pos < size) = true;
Expand Down Expand Up @@ -11149,7 +11149,6 @@ algorithm outOrder := matchcontinue(inDlow,syst)
list<tuple<DAE.ComponentRef, Integer>> variableIndex;
list<list<DAE.ComponentRef>> firstOrderVars;
list<DAE.ComponentRef> firstOrderVarsFiltered;
BackendDAE.EqSystem syst;
case(inDlow,syst)
equation
Debug.fcall(Flags.CPP_VAR,print, " set variabale der index"+& "\n");
Expand Down
9 changes: 4 additions & 5 deletions Compiler/BackEnd/Uncertainties.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1158,16 +1158,15 @@ algorithm
(outEqns,outSimpleEqns,outMvars,outRepl):=
matchcontinue (eqns,eqnIndex,vars,knvars,mvars,repl,inDoubles,m,elimVarIndexList,failCheck)
local
BackendDAE.Variables vars,knvars;
HashTable.HashTable mvars,mvars_1,mvars_2;
BackendVarTransform.VariableReplacements repl,repl_1,repl_2;
HashTable.HashTable mvars_1,mvars_2;
BackendVarTransform.VariableReplacements repl_1,repl_2;
DAE.ComponentRef cr1;
list<BackendDAE.Equation> eqns_1,seqns_1,eqns;
list<BackendDAE.Equation> eqns_1,seqns_1;
list<Integer> varIndexList, elimVarIndexList_1;
Integer elimVarIndex;
BackendDAE.Equation e;
DAE.Exp e2;
DAE.ElementSource source "origin of equation";
DAE.ElementSource source;
array<Option<BackendDAE.Var>> varOptArr;
BackendDAE.Var elimVar;

Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/AbsynDep.mo
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function dumpAvlTreeKeys "prints all keys in an Avltree to stdout"
input AvlTree used;
algorithm
_ := matchcontinue(used)
local AvlTree used, usedBy;
local AvlTree usedBy;
list<tuple<AvlKey,AvlValue>> usedLst;
case(used) equation
usedLst = avlTreeToList(used);
Expand Down
7 changes: 3 additions & 4 deletions Compiler/FrontEnd/Ceval.mo
Original file line number Diff line number Diff line change
Expand Up @@ -6042,7 +6042,6 @@ algorithm
array<list<tuple<Key,Integer>>> hashvec_1,hashvec;
String name_str;
tuple<Key,Value> v,newv;
Key key;
Value value;
// adding when already present => Updating value
case (key,(hashTable as HASHTABLE(hashvec,varr,bsize,n)))
Expand Down Expand Up @@ -6275,7 +6274,7 @@ algorithm
outValueArray := matchcontinue (valueArray,pos,entry)
local
array<Option<tuple<Key,Value>>> arr_1,arr;
Integer n,size,pos;
Integer n,size;
case (VALUE_ARRAY(n,size,arr),pos,entry)
equation
(pos < size) = true;
Expand All @@ -6300,7 +6299,7 @@ algorithm
outValueArray := matchcontinue (valueArray,pos)
local
array<Option<tuple<Key,Value>>> arr_1,arr;
Integer n,size,pos;
Integer n,size;
case (VALUE_ARRAY(n,size,arr),pos)
equation
(pos < size) = true;
Expand All @@ -6326,7 +6325,7 @@ algorithm
value := matchcontinue (valueArray,pos)
local
Value v;
Integer n,pos,len;
Integer n,len;
array<Option<tuple<Key,Value>>> arr;
String ps,lens,ns;
case (VALUE_ARRAY(numberOfElements = n,valueArray = arr),pos)
Expand Down
2 changes: 1 addition & 1 deletion Compiler/FrontEnd/ClassLoader.mo
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function loadFile
algorithm
outProgram := matchcontinue (name,encoding)
local
String dir,name,filename,cname,prio,mp;
String dir,filename,cname,prio,mp;
Absyn.Program p1;
list<String> rest;

Expand Down

0 comments on commit 871a1a0

Please sign in to comment.