Skip to content

Commit

Permalink
- Fixed some bugs introduced by revision 6568.
Browse files Browse the repository at this point in the history
- Renamed DEA to DAE.


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6604 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
perost committed Oct 26, 2010
1 parent c4b4a96 commit 5cea8df
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 66 deletions.
99 changes: 53 additions & 46 deletions Compiler/DAELow.mo
Expand Up @@ -654,7 +654,7 @@ algorithm
algarr = listArray(algs);
funcs = DAEUtil.daeFunctionTree(lst);
einfo = Inline.inlineEventInfo(EVENT_INFO(whenclauses_1,zero_crossings),(NONE(),SOME(funcs),{DAE.NORM_INLINE()}));
DAELowUtil.checkDEALowWithErrorMsg(DAELOW(vars_1,knvars,extVars,aliasVars,eqnarr,reqnarr,ieqnarr,arr_md_eqns,algarr,einfo,extObjCls));
DAELowUtil.checkDAELowWithErrorMsg(DAELOW(vars_1,knvars,extVars,aliasVars,eqnarr,reqnarr,ieqnarr,arr_md_eqns,algarr,einfo,extObjCls));
then DAELOW(vars_1,knvars,extVars,aliasVars,eqnarr,reqnarr,ieqnarr,arr_md_eqns,algarr,einfo,extObjCls);

case(lst, addDummyDerivativeIfNeeded, false) // do not simplify
Expand Down Expand Up @@ -691,7 +691,7 @@ algorithm
algarr = listArray(algs);
funcs = DAEUtil.daeFunctionTree(lst);
einfo = Inline.inlineEventInfo(EVENT_INFO(whenclauses_1,zero_crossings),(NONE(),SOME(funcs),{DAE.NORM_INLINE()}));
DAELowUtil.checkDEALowWithErrorMsg(DAELOW(vars_1,knvars,extVars,aliasVars,eqnarr,reqnarr,ieqnarr,arr_md_eqns,algarr,einfo,extObjCls));
DAELowUtil.checkDAELowWithErrorMsg(DAELOW(vars_1,knvars,extVars,aliasVars,eqnarr,reqnarr,ieqnarr,arr_md_eqns,algarr,einfo,extObjCls));
then DAELOW(vars_1,knvars,extVars,aliasVars,eqnarr,reqnarr,ieqnarr,arr_md_eqns,algarr,einfo,extObjCls);
end matchcontinue;
end lower;
Expand Down Expand Up @@ -15406,7 +15406,7 @@ algorithm
end matchcontinue;
end getAllExpsEqn;

public function traverseDEALowExps "function: traverseDEALowExps
public function traverseDAELowExps "function: traverseDAELowExps
author: Frenkel TUD

This function goes through the DAELow structure and finds all the
Expand Down Expand Up @@ -15438,12 +15438,12 @@ algorithm
case (DAELOW(orderedVars = vars1,knownVars = vars2,orderedEqs = eqns,removedEqs = reqns,
initialEqs = ieqns,arrayEqs = ae,algorithms = algs),true,func,inTypeA)
equation
exps1 = traverseDEALowExpsVars(vars1,func,inTypeA);
exps2 = traverseDEALowExpsVars(vars2,func,inTypeA);
exps3 = traverseDEALowExpsEqns(eqns,func,inTypeA);
exps4 = traverseDEALowExpsEqns(reqns,func,inTypeA);
exps5 = traverseDEALowExpsEqns(ieqns,func,inTypeA);
exps6 = traverseDEALowExpsArrayEqns(ae,func,inTypeA);
exps1 = traverseDAELowExpsVars(vars1,func,inTypeA);
exps2 = traverseDAELowExpsVars(vars2,func,inTypeA);
exps3 = traverseDAELowExpsEqns(eqns,func,inTypeA);
exps4 = traverseDAELowExpsEqns(reqns,func,inTypeA);
exps5 = traverseDAELowExpsEqns(ieqns,func,inTypeA);
exps6 = traverseDAELowExpsArrayEqns(ae,func,inTypeA);
alglst = arrayList(algs);
exps7 = Util.listMapFlat2(alglst, Algorithm.traverseExps,func,inTypeA);
exps = Util.listFlatten({exps1,exps2,exps3,exps4,exps5,exps6,exps7});
Expand All @@ -15452,27 +15452,27 @@ algorithm
case (DAELOW(orderedVars = vars1,knownVars = vars2,orderedEqs = eqns,removedEqs = reqns,
initialEqs = ieqns,arrayEqs = ae,algorithms = algs),false,func,inTypeA)
equation
exps1 = traverseDEALowExpsVars(vars1,func,inTypeA);
exps2 = traverseDEALowExpsVars(vars2,func,inTypeA);
exps3 = traverseDEALowExpsEqns(eqns,func,inTypeA);
exps4 = traverseDEALowExpsEqns(reqns,func,inTypeA);
exps5 = traverseDEALowExpsEqns(ieqns,func,inTypeA);
exps6 = traverseDEALowExpsArrayEqns(ae,func,inTypeA);
exps1 = traverseDAELowExpsVars(vars1,func,inTypeA);
exps2 = traverseDAELowExpsVars(vars2,func,inTypeA);
exps3 = traverseDAELowExpsEqns(eqns,func,inTypeA);
exps4 = traverseDAELowExpsEqns(reqns,func,inTypeA);
exps5 = traverseDAELowExpsEqns(ieqns,func,inTypeA);
exps6 = traverseDAELowExpsArrayEqns(ae,func,inTypeA);
exps = Util.listFlatten({exps1,exps2,exps3,exps4,exps5,exps6});
then
exps;
case (_,_,_,_)
equation
Debug.fprintln("failtrace", "- DAELow.traverseDEALowExps failed");
Debug.fprintln("failtrace", "- DAELow.traverseDAELowExps failed");
then
fail();
end matchcontinue;
end traverseDEALowExps;
end traverseDAELowExps;

protected function traverseDEALowExpsVars "function: traverseDEALowExpsVars
protected function traverseDAELowExpsVars "function: traverseDAELowExpsVars
author: Frenkel TUD

Helper for traverseDEALowExps
Helper for traverseDAELowExps
"
input Variables inVariables;
input FuncExpType func;
Expand Down Expand Up @@ -15500,20 +15500,20 @@ algorithm
case (VARIABLES(crefIdxLstArr = crefindex,strIdxLstArr = oldcrefindex,varArr = vararray,bucketSize = bsize,numberOfVars = nvars),func,inTypeA)
equation
vars = vararrayList(vararray) "We can ignore crefs, they don\'t contain real expressions" ;
talst = Util.listMapFlat2(vars, traverseDEALowExpsVar,func,inTypeA);
talst = Util.listMapFlat2(vars, traverseDAELowExpsVar,func,inTypeA);
then
talst;
case (_,_,_)
equation
Debug.fprintln("failtrace", "- DAELow.traverseDEALowExpsVars failed");
Debug.fprintln("failtrace", "- DAELow.traverseDAELowExpsVars failed");
then
fail();
end matchcontinue;
end traverseDEALowExpsVars;
end traverseDAELowExpsVars;

protected function traverseDEALowExpsVar "function: traverseDEALowExpsVar
protected function traverseDAELowExpsVar "function: traverseDAELowExpsVar
author: Frenkel TUD
Helper traverseDEALowExpsVar. Get all exps from a Var.
Helper traverseDAELowExpsVar. Get all exps from a Var.
DAE.ET_OTHER is used as type for componentref. Not important here.
We only use the exp list for finding function calls"
input Var inVar;
Expand Down Expand Up @@ -15546,23 +15546,23 @@ algorithm
equation
e1 = Util.optionToList(bndexp);
talst = Util.listMapFlat1(e1,func,inTypeA);
talst1 = Util.listMapFlat2(instdims, traverseDEALowExpsSubscript,func,inTypeA);
talst1 = Util.listMapFlat2(instdims, traverseDAELowExpsSubscript,func,inTypeA);
talst2 = listAppend(talst,talst1);
talst3 = func(DAE.CREF(cref,DAE.ET_OTHER()),inTypeA);
talst4 = listAppend(talst2,talst3);
then
talst4;
case (_,_,_)
equation
Debug.fprintln("failtrace", "- DAELow.traverseDEALowExpsVar failed");
Debug.fprintln("failtrace", "- DAELow.traverseDAELowExpsVar failed");
then
fail();
end matchcontinue;
end traverseDEALowExpsVar;
end traverseDAELowExpsVar;

protected function traverseDEALowExpsSubscript "function: traverseDEALowExpsSubscript
protected function traverseDAELowExpsSubscript "function: traverseDAELowExpsSubscript
author: Frenkel TUD
helper for traverseDEALowExpsSubscript"
helper for traverseDAELowExpsSubscript"
input DAE.Subscript inSubscript;
input FuncExpType func;
input Type_a inTypeA;
Expand Down Expand Up @@ -15592,12 +15592,12 @@ algorithm
talst = func(e,inTypeA);
then talst;
end matchcontinue;
end traverseDEALowExpsSubscript;
end traverseDAELowExpsSubscript;

protected function traverseDEALowExpsEqns "function: traverseDEALowExpsEqns
protected function traverseDAELowExpsEqns "function: traverseDAELowExpsEqns
author: Frenkel TUD

Helper for traverseDEALowExpsEqns
Helper for traverseDAELowExpsEqns
"
input EquationArray inEquationArray;
input FuncExpType func;
Expand All @@ -15622,15 +15622,15 @@ algorithm
case ((eqnarray as EQUATION_ARRAY(numberOfElement = _)),func,inTypeA)
equation
eqns = equationList(eqnarray);
talst = Util.listMapFlat2(eqns, traverseDEALowExpsEqn,func,inTypeA);
talst = Util.listMapFlat2(eqns, traverseDAELowExpsEqn,func,inTypeA);
then
talst;
end matchcontinue;
end traverseDEALowExpsEqns;
end traverseDAELowExpsEqns;

protected function traverseDEALowExpsEqn "function: traverseDEALowExpsEqn
protected function traverseDAELowExpsEqn "function: traverseDAELowExpsEqn
author: PA
Helper for traverseDEALowExpsEqn."
Helper for traverseDAELowExpsEqn."
input Equation inEquation;
input FuncExpType func;
input Type_a inTypeA;
Expand Down Expand Up @@ -15689,7 +15689,7 @@ algorithm
talst = func(DAE.CREF(cr,tp),inTypeA);
talst1 = func(e,inTypeA);
talst2 = listAppend(talst,talst1);
talst3 = traverseDEALowExpsEqn(WHEN_EQUATION(elsePart,source),func,inTypeA);
talst3 = traverseDAELowExpsEqn(WHEN_EQUATION(elsePart,source),func,inTypeA);
talst4 = listAppend(talst2,talst3);
then
talst4;
Expand All @@ -15700,13 +15700,20 @@ algorithm
talst = Util.listMapFlat1(expl,func,inTypeA);
then
talst;
case (COMPLEX_EQUATION(index = ind, lhs = e1, rhs = e2),func,inTypeA)
equation
talst = func(e1, inTypeA);
talst1 = func(e2, inTypeA);
talst2 = listAppend(talst, talst1);
then
talst2;
end matchcontinue;
end traverseDEALowExpsEqn;
end traverseDAELowExpsEqn;

protected function traverseDEALowExpsArrayEqns "function: traverseDEALowExpsArrayEqns
protected function traverseDAELowExpsArrayEqns "function: traverseDAELowExpsArrayEqns
author: Frenkel TUD

helper for traverseDEALowExps
helper for traverseDAELowExps
"
input MultiDimEquation[:] arr;
input FuncExpType func;
Expand All @@ -15724,13 +15731,13 @@ protected function traverseDEALowExpsArrayEqns "function: traverseDEALowExpsArra
list<MultiDimEquation> lst;
algorithm
lst := arrayList(arr);
outTypeBLst := Util.listMapFlat2(lst, traverseDEALowExpsArrayEqn,func,inTypeA);
end traverseDEALowExpsArrayEqns;
outTypeBLst := Util.listMapFlat2(lst, traverseDAELowExpsArrayEqn,func,inTypeA);
end traverseDAELowExpsArrayEqns;

protected function traverseDEALowExpsArrayEqn "function: traverseDEALowExpsArrayEqn
protected function traverseDAELowExpsArrayEqn "function: traverseDAELowExpsArrayEqn
author: Frenkel TUD

Helper function to traverseDEALowExpsArrayEqns
Helper function to traverseDAELowExpsArrayEqns
"
input MultiDimEquation inMultiDimEquation;
input FuncExpType func;
Expand Down Expand Up @@ -15759,7 +15766,7 @@ algorithm
then
talst2;
end matchcontinue;
end traverseDEALowExpsArrayEqn;
end traverseDAELowExpsArrayEqn;

public function isParam
"function: isParam
Expand Down Expand Up @@ -16927,7 +16934,7 @@ end collectDelayExpressions;
public function findDelaySubExpressions
"Return all subexpressions of inExp that are calls to delay()"
input DAE.Exp inExp;
input list<Integer> inDummy "this is a dummy for traverseDEALowExps";
input list<Integer> inDummy "this is a dummy for traverseDAELowExps";
output list<DAE.Exp> outExps;
algorithm
((_, outExps)) := Exp.traverseExp(inExp, collectDelayExpressions, {});
Expand Down
40 changes: 21 additions & 19 deletions Compiler/DAELowUtil.mo
Expand Up @@ -54,19 +54,19 @@ public import DAELow;

protected import Debug;

public function checkDEALowWithErrorMsg"function: checkDEALowWithErrorMsg
public function checkDAELowWithErrorMsg"function: checkDAELowWithErrorMsg
author: Frenkel TUD
run checkDEALow and prints all errors"
run checkDAELow and prints all errors"
input DAELow.DAELow inDAELow;
list<tuple<DAE.Exp,list<DAE.ComponentRef>>> expCrefs;
algorithm
expCrefs := checkDEALow(inDAELow);
printcheckDEALowWithErrorMsg(expCrefs);
end checkDEALowWithErrorMsg;
expCrefs := checkDAELow(inDAELow);
printcheckDAELowWithErrorMsg(expCrefs);
end checkDAELowWithErrorMsg;

public function printcheckDEALowWithErrorMsg"function: printcheckDEALowWithErrorMsg
public function printcheckDAELowWithErrorMsg"function: printcheckDAELowWithErrorMsg
author: Frenkel TUD
helper for checkDEALowWithErrorMsg"
helper for checkDAELowWithErrorMsg"
input list<tuple<DAE.Exp,list<DAE.ComponentRef>>> inExpCrefs;
algorithm
_:=
Expand All @@ -83,13 +83,13 @@ algorithm
print(Exp.printExpStr(e));print("\n Variables: ");
strcrefs = Util.listMap(crefs,Exp.crefStr);
print(Util.stringDelimitList(strcrefs,", "));print("\nnot found in DAELow object.\n");
printcheckDEALowWithErrorMsg(res);
printcheckDAELowWithErrorMsg(res);
then
();
end matchcontinue;
end printcheckDEALowWithErrorMsg;
end printcheckDAELowWithErrorMsg;

public function checkDEALow "function: checkDEALow
public function checkDAELow "function: checkDAELow
author: Frenkel TUD

This function checks the DAELow object if
Expand All @@ -112,18 +112,18 @@ algorithm
varlst2 = DAELow.varList(vars2);
allvarslst = listAppend(varlst1,varlst2);
allvars = DAELow.listVar(allvarslst);
expcrefs = DAELow.traverseDEALowExps(inDAELow,false,checkDEALowExp,allvars);
expcrefs = DAELow.traverseDAELowExps(inDAELow,false,checkDAELowExp,allvars);
then
expcrefs;
case (_)
equation
Debug.fprintln("failtrace", "- DAELowUtil.checkDEALow failed");
Debug.fprintln("failtrace", "- DAELowUtil.checkDAELow failed");
then
fail();
end matchcontinue;
end checkDEALow;
end checkDAELow;

protected function checkDEALowExp
protected function checkDAELowExp
input DAE.Exp inExp;
input DAELow.Variables inVars;
output list<tuple<DAE.Exp,list<DAE.ComponentRef>>> outExpCrefs;
Expand All @@ -137,14 +137,14 @@ algorithm
list<tuple<DAE.Exp,list<DAE.ComponentRef>>> lstExpCrefs;
case (exp,vars)
equation
((_,(_,crefs))) = Exp.traverseExpTopDown(exp,traversecheckDEALowExp,((vars,{})));
((_,(_,crefs))) = Exp.traverseExpTopDown(exp,traversecheckDAELowExp,((vars,{})));
lstExpCrefs = Util.if_(listLength(crefs)>0,{(exp,crefs)},{});
then
lstExpCrefs;
end matchcontinue;
end checkDEALowExp;
end checkDAELowExp;

protected function traversecheckDEALowExp
protected function traversecheckDAELowExp
input tuple<DAE.Exp, tuple<DAELow.Variables,list<DAE.ComponentRef>>> inTuple;
output tuple<DAE.Exp, tuple<DAELow.Variables,list<DAE.ComponentRef>>> outTuple;
algorithm
Expand All @@ -158,6 +158,8 @@ algorithm
// special case for time, it is never part of the equation system
case ((e as DAE.CREF(componentRef = DAE.CREF_IDENT(ident="time")),(vars,crefs)))
then ((e, (vars,crefs)));
case ((e as DAE.CREF(componentRef = DAE.WILD()), (vars,crefs)))
then ((e, (vars,crefs)));
/* Special Case for Records */
case ((e as DAE.CREF(componentRef = cr),(vars,crefs)))
local
Expand All @@ -169,7 +171,7 @@ algorithm
equation
DAE.ET_COMPLEX(varLst=varLst) = Exp.crefLastType(cr);
expl = Util.listMap1(varLst,DAELow.generateCrefsExpFromType,e);
expcreflstlst = Util.listMap1(expl,checkDEALowExp,vars);
expcreflstlst = Util.listMap1(expl,checkDAELowExp,vars);
expcreflst = Util.listFlatten(expcreflstlst);
creflstlst = Util.listMap(expcreflst,Util.tuple22);
crlst = Util.listFlatten(creflstlst);
Expand Down Expand Up @@ -204,6 +206,6 @@ algorithm
((e, (vars,cr::crefs)));
case (_) then inTuple;
end matchcontinue;
end traversecheckDEALowExp;
end traversecheckDAELowExp;

end DAELowUtil;
2 changes: 1 addition & 1 deletion Compiler/DAEUtil.mo
Expand Up @@ -5331,4 +5331,4 @@ algorithm
then res;
end matchcontinue;
end varHasName;
*/
*/

0 comments on commit 5cea8df

Please sign in to comment.