Skip to content

Commit 5cea8df

Browse files
committed
- Fixed some bugs introduced by revision 6568.
- Renamed DEA to DAE. git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@6604 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent c4b4a96 commit 5cea8df

File tree

3 files changed

+75
-66
lines changed

3 files changed

+75
-66
lines changed

Compiler/DAELow.mo

Lines changed: 53 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -654,7 +654,7 @@ algorithm
654654
algarr = listArray(algs);
655655
funcs = DAEUtil.daeFunctionTree(lst);
656656
einfo = Inline.inlineEventInfo(EVENT_INFO(whenclauses_1,zero_crossings),(NONE(),SOME(funcs),{DAE.NORM_INLINE()}));
657-
DAELowUtil.checkDEALowWithErrorMsg(DAELOW(vars_1,knvars,extVars,aliasVars,eqnarr,reqnarr,ieqnarr,arr_md_eqns,algarr,einfo,extObjCls));
657+
DAELowUtil.checkDAELowWithErrorMsg(DAELOW(vars_1,knvars,extVars,aliasVars,eqnarr,reqnarr,ieqnarr,arr_md_eqns,algarr,einfo,extObjCls));
658658
then DAELOW(vars_1,knvars,extVars,aliasVars,eqnarr,reqnarr,ieqnarr,arr_md_eqns,algarr,einfo,extObjCls);
659659

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

15409-
public function traverseDEALowExps "function: traverseDEALowExps
15409+
public function traverseDAELowExps "function: traverseDAELowExps
1541015410
author: Frenkel TUD
1541115411

1541215412
This function goes through the DAELow structure and finds all the
@@ -15438,12 +15438,12 @@ algorithm
1543815438
case (DAELOW(orderedVars = vars1,knownVars = vars2,orderedEqs = eqns,removedEqs = reqns,
1543915439
initialEqs = ieqns,arrayEqs = ae,algorithms = algs),true,func,inTypeA)
1544015440
equation
15441-
exps1 = traverseDEALowExpsVars(vars1,func,inTypeA);
15442-
exps2 = traverseDEALowExpsVars(vars2,func,inTypeA);
15443-
exps3 = traverseDEALowExpsEqns(eqns,func,inTypeA);
15444-
exps4 = traverseDEALowExpsEqns(reqns,func,inTypeA);
15445-
exps5 = traverseDEALowExpsEqns(ieqns,func,inTypeA);
15446-
exps6 = traverseDEALowExpsArrayEqns(ae,func,inTypeA);
15441+
exps1 = traverseDAELowExpsVars(vars1,func,inTypeA);
15442+
exps2 = traverseDAELowExpsVars(vars2,func,inTypeA);
15443+
exps3 = traverseDAELowExpsEqns(eqns,func,inTypeA);
15444+
exps4 = traverseDAELowExpsEqns(reqns,func,inTypeA);
15445+
exps5 = traverseDAELowExpsEqns(ieqns,func,inTypeA);
15446+
exps6 = traverseDAELowExpsArrayEqns(ae,func,inTypeA);
1544715447
alglst = arrayList(algs);
1544815448
exps7 = Util.listMapFlat2(alglst, Algorithm.traverseExps,func,inTypeA);
1544915449
exps = Util.listFlatten({exps1,exps2,exps3,exps4,exps5,exps6,exps7});
@@ -15452,27 +15452,27 @@ algorithm
1545215452
case (DAELOW(orderedVars = vars1,knownVars = vars2,orderedEqs = eqns,removedEqs = reqns,
1545315453
initialEqs = ieqns,arrayEqs = ae,algorithms = algs),false,func,inTypeA)
1545415454
equation
15455-
exps1 = traverseDEALowExpsVars(vars1,func,inTypeA);
15456-
exps2 = traverseDEALowExpsVars(vars2,func,inTypeA);
15457-
exps3 = traverseDEALowExpsEqns(eqns,func,inTypeA);
15458-
exps4 = traverseDEALowExpsEqns(reqns,func,inTypeA);
15459-
exps5 = traverseDEALowExpsEqns(ieqns,func,inTypeA);
15460-
exps6 = traverseDEALowExpsArrayEqns(ae,func,inTypeA);
15455+
exps1 = traverseDAELowExpsVars(vars1,func,inTypeA);
15456+
exps2 = traverseDAELowExpsVars(vars2,func,inTypeA);
15457+
exps3 = traverseDAELowExpsEqns(eqns,func,inTypeA);
15458+
exps4 = traverseDAELowExpsEqns(reqns,func,inTypeA);
15459+
exps5 = traverseDAELowExpsEqns(ieqns,func,inTypeA);
15460+
exps6 = traverseDAELowExpsArrayEqns(ae,func,inTypeA);
1546115461
exps = Util.listFlatten({exps1,exps2,exps3,exps4,exps5,exps6});
1546215462
then
1546315463
exps;
1546415464
case (_,_,_,_)
1546515465
equation
15466-
Debug.fprintln("failtrace", "- DAELow.traverseDEALowExps failed");
15466+
Debug.fprintln("failtrace", "- DAELow.traverseDAELowExps failed");
1546715467
then
1546815468
fail();
1546915469
end matchcontinue;
15470-
end traverseDEALowExps;
15470+
end traverseDAELowExps;
1547115471

15472-
protected function traverseDEALowExpsVars "function: traverseDEALowExpsVars
15472+
protected function traverseDAELowExpsVars "function: traverseDAELowExpsVars
1547315473
author: Frenkel TUD
1547415474

15475-
Helper for traverseDEALowExps
15475+
Helper for traverseDAELowExps
1547615476
"
1547715477
input Variables inVariables;
1547815478
input FuncExpType func;
@@ -15500,20 +15500,20 @@ algorithm
1550015500
case (VARIABLES(crefIdxLstArr = crefindex,strIdxLstArr = oldcrefindex,varArr = vararray,bucketSize = bsize,numberOfVars = nvars),func,inTypeA)
1550115501
equation
1550215502
vars = vararrayList(vararray) "We can ignore crefs, they don\'t contain real expressions" ;
15503-
talst = Util.listMapFlat2(vars, traverseDEALowExpsVar,func,inTypeA);
15503+
talst = Util.listMapFlat2(vars, traverseDAELowExpsVar,func,inTypeA);
1550415504
then
1550515505
talst;
1550615506
case (_,_,_)
1550715507
equation
15508-
Debug.fprintln("failtrace", "- DAELow.traverseDEALowExpsVars failed");
15508+
Debug.fprintln("failtrace", "- DAELow.traverseDAELowExpsVars failed");
1550915509
then
1551015510
fail();
1551115511
end matchcontinue;
15512-
end traverseDEALowExpsVars;
15512+
end traverseDAELowExpsVars;
1551315513

15514-
protected function traverseDEALowExpsVar "function: traverseDEALowExpsVar
15514+
protected function traverseDAELowExpsVar "function: traverseDAELowExpsVar
1551515515
author: Frenkel TUD
15516-
Helper traverseDEALowExpsVar. Get all exps from a Var.
15516+
Helper traverseDAELowExpsVar. Get all exps from a Var.
1551715517
DAE.ET_OTHER is used as type for componentref. Not important here.
1551815518
We only use the exp list for finding function calls"
1551915519
input Var inVar;
@@ -15546,23 +15546,23 @@ algorithm
1554615546
equation
1554715547
e1 = Util.optionToList(bndexp);
1554815548
talst = Util.listMapFlat1(e1,func,inTypeA);
15549-
talst1 = Util.listMapFlat2(instdims, traverseDEALowExpsSubscript,func,inTypeA);
15549+
talst1 = Util.listMapFlat2(instdims, traverseDAELowExpsSubscript,func,inTypeA);
1555015550
talst2 = listAppend(talst,talst1);
1555115551
talst3 = func(DAE.CREF(cref,DAE.ET_OTHER()),inTypeA);
1555215552
talst4 = listAppend(talst2,talst3);
1555315553
then
1555415554
talst4;
1555515555
case (_,_,_)
1555615556
equation
15557-
Debug.fprintln("failtrace", "- DAELow.traverseDEALowExpsVar failed");
15557+
Debug.fprintln("failtrace", "- DAELow.traverseDAELowExpsVar failed");
1555815558
then
1555915559
fail();
1556015560
end matchcontinue;
15561-
end traverseDEALowExpsVar;
15561+
end traverseDAELowExpsVar;
1556215562

15563-
protected function traverseDEALowExpsSubscript "function: traverseDEALowExpsSubscript
15563+
protected function traverseDAELowExpsSubscript "function: traverseDAELowExpsSubscript
1556415564
author: Frenkel TUD
15565-
helper for traverseDEALowExpsSubscript"
15565+
helper for traverseDAELowExpsSubscript"
1556615566
input DAE.Subscript inSubscript;
1556715567
input FuncExpType func;
1556815568
input Type_a inTypeA;
@@ -15592,12 +15592,12 @@ algorithm
1559215592
talst = func(e,inTypeA);
1559315593
then talst;
1559415594
end matchcontinue;
15595-
end traverseDEALowExpsSubscript;
15595+
end traverseDAELowExpsSubscript;
1559615596

15597-
protected function traverseDEALowExpsEqns "function: traverseDEALowExpsEqns
15597+
protected function traverseDAELowExpsEqns "function: traverseDAELowExpsEqns
1559815598
author: Frenkel TUD
1559915599

15600-
Helper for traverseDEALowExpsEqns
15600+
Helper for traverseDAELowExpsEqns
1560115601
"
1560215602
input EquationArray inEquationArray;
1560315603
input FuncExpType func;
@@ -15622,15 +15622,15 @@ algorithm
1562215622
case ((eqnarray as EQUATION_ARRAY(numberOfElement = _)),func,inTypeA)
1562315623
equation
1562415624
eqns = equationList(eqnarray);
15625-
talst = Util.listMapFlat2(eqns, traverseDEALowExpsEqn,func,inTypeA);
15625+
talst = Util.listMapFlat2(eqns, traverseDAELowExpsEqn,func,inTypeA);
1562615626
then
1562715627
talst;
1562815628
end matchcontinue;
15629-
end traverseDEALowExpsEqns;
15629+
end traverseDAELowExpsEqns;
1563015630

15631-
protected function traverseDEALowExpsEqn "function: traverseDEALowExpsEqn
15631+
protected function traverseDAELowExpsEqn "function: traverseDAELowExpsEqn
1563215632
author: PA
15633-
Helper for traverseDEALowExpsEqn."
15633+
Helper for traverseDAELowExpsEqn."
1563415634
input Equation inEquation;
1563515635
input FuncExpType func;
1563615636
input Type_a inTypeA;
@@ -15689,7 +15689,7 @@ algorithm
1568915689
talst = func(DAE.CREF(cr,tp),inTypeA);
1569015690
talst1 = func(e,inTypeA);
1569115691
talst2 = listAppend(talst,talst1);
15692-
talst3 = traverseDEALowExpsEqn(WHEN_EQUATION(elsePart,source),func,inTypeA);
15692+
talst3 = traverseDAELowExpsEqn(WHEN_EQUATION(elsePart,source),func,inTypeA);
1569315693
talst4 = listAppend(talst2,talst3);
1569415694
then
1569515695
talst4;
@@ -15700,13 +15700,20 @@ algorithm
1570015700
talst = Util.listMapFlat1(expl,func,inTypeA);
1570115701
then
1570215702
talst;
15703+
case (COMPLEX_EQUATION(index = ind, lhs = e1, rhs = e2),func,inTypeA)
15704+
equation
15705+
talst = func(e1, inTypeA);
15706+
talst1 = func(e2, inTypeA);
15707+
talst2 = listAppend(talst, talst1);
15708+
then
15709+
talst2;
1570315710
end matchcontinue;
15704-
end traverseDEALowExpsEqn;
15711+
end traverseDAELowExpsEqn;
1570515712

15706-
protected function traverseDEALowExpsArrayEqns "function: traverseDEALowExpsArrayEqns
15713+
protected function traverseDAELowExpsArrayEqns "function: traverseDAELowExpsArrayEqns
1570715714
author: Frenkel TUD
1570815715

15709-
helper for traverseDEALowExps
15716+
helper for traverseDAELowExps
1571015717
"
1571115718
input MultiDimEquation[:] arr;
1571215719
input FuncExpType func;
@@ -15724,13 +15731,13 @@ protected function traverseDEALowExpsArrayEqns "function: traverseDEALowExpsArra
1572415731
list<MultiDimEquation> lst;
1572515732
algorithm
1572615733
lst := arrayList(arr);
15727-
outTypeBLst := Util.listMapFlat2(lst, traverseDEALowExpsArrayEqn,func,inTypeA);
15728-
end traverseDEALowExpsArrayEqns;
15734+
outTypeBLst := Util.listMapFlat2(lst, traverseDAELowExpsArrayEqn,func,inTypeA);
15735+
end traverseDAELowExpsArrayEqns;
1572915736

15730-
protected function traverseDEALowExpsArrayEqn "function: traverseDEALowExpsArrayEqn
15737+
protected function traverseDAELowExpsArrayEqn "function: traverseDAELowExpsArrayEqn
1573115738
author: Frenkel TUD
1573215739

15733-
Helper function to traverseDEALowExpsArrayEqns
15740+
Helper function to traverseDAELowExpsArrayEqns
1573415741
"
1573515742
input MultiDimEquation inMultiDimEquation;
1573615743
input FuncExpType func;
@@ -15759,7 +15766,7 @@ algorithm
1575915766
then
1576015767
talst2;
1576115768
end matchcontinue;
15762-
end traverseDEALowExpsArrayEqn;
15769+
end traverseDAELowExpsArrayEqn;
1576315770

1576415771
public function isParam
1576515772
"function: isParam
@@ -16927,7 +16934,7 @@ end collectDelayExpressions;
1692716934
public function findDelaySubExpressions
1692816935
"Return all subexpressions of inExp that are calls to delay()"
1692916936
input DAE.Exp inExp;
16930-
input list<Integer> inDummy "this is a dummy for traverseDEALowExps";
16937+
input list<Integer> inDummy "this is a dummy for traverseDAELowExps";
1693116938
output list<DAE.Exp> outExps;
1693216939
algorithm
1693316940
((_, outExps)) := Exp.traverseExp(inExp, collectDelayExpressions, {});

Compiler/DAELowUtil.mo

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -54,19 +54,19 @@ public import DAELow;
5454

5555
protected import Debug;
5656

57-
public function checkDEALowWithErrorMsg"function: checkDEALowWithErrorMsg
57+
public function checkDAELowWithErrorMsg"function: checkDAELowWithErrorMsg
5858
author: Frenkel TUD
59-
run checkDEALow and prints all errors"
59+
run checkDAELow and prints all errors"
6060
input DAELow.DAELow inDAELow;
6161
list<tuple<DAE.Exp,list<DAE.ComponentRef>>> expCrefs;
6262
algorithm
63-
expCrefs := checkDEALow(inDAELow);
64-
printcheckDEALowWithErrorMsg(expCrefs);
65-
end checkDEALowWithErrorMsg;
63+
expCrefs := checkDAELow(inDAELow);
64+
printcheckDAELowWithErrorMsg(expCrefs);
65+
end checkDAELowWithErrorMsg;
6666

67-
public function printcheckDEALowWithErrorMsg"function: printcheckDEALowWithErrorMsg
67+
public function printcheckDAELowWithErrorMsg"function: printcheckDAELowWithErrorMsg
6868
author: Frenkel TUD
69-
helper for checkDEALowWithErrorMsg"
69+
helper for checkDAELowWithErrorMsg"
7070
input list<tuple<DAE.Exp,list<DAE.ComponentRef>>> inExpCrefs;
7171
algorithm
7272
_:=
@@ -83,13 +83,13 @@ algorithm
8383
print(Exp.printExpStr(e));print("\n Variables: ");
8484
strcrefs = Util.listMap(crefs,Exp.crefStr);
8585
print(Util.stringDelimitList(strcrefs,", "));print("\nnot found in DAELow object.\n");
86-
printcheckDEALowWithErrorMsg(res);
86+
printcheckDAELowWithErrorMsg(res);
8787
then
8888
();
8989
end matchcontinue;
90-
end printcheckDEALowWithErrorMsg;
90+
end printcheckDAELowWithErrorMsg;
9191

92-
public function checkDEALow "function: checkDEALow
92+
public function checkDAELow "function: checkDAELow
9393
author: Frenkel TUD
9494

9595
This function checks the DAELow object if
@@ -112,18 +112,18 @@ algorithm
112112
varlst2 = DAELow.varList(vars2);
113113
allvarslst = listAppend(varlst1,varlst2);
114114
allvars = DAELow.listVar(allvarslst);
115-
expcrefs = DAELow.traverseDEALowExps(inDAELow,false,checkDEALowExp,allvars);
115+
expcrefs = DAELow.traverseDAELowExps(inDAELow,false,checkDAELowExp,allvars);
116116
then
117117
expcrefs;
118118
case (_)
119119
equation
120-
Debug.fprintln("failtrace", "- DAELowUtil.checkDEALow failed");
120+
Debug.fprintln("failtrace", "- DAELowUtil.checkDAELow failed");
121121
then
122122
fail();
123123
end matchcontinue;
124-
end checkDEALow;
124+
end checkDAELow;
125125

126-
protected function checkDEALowExp
126+
protected function checkDAELowExp
127127
input DAE.Exp inExp;
128128
input DAELow.Variables inVars;
129129
output list<tuple<DAE.Exp,list<DAE.ComponentRef>>> outExpCrefs;
@@ -137,14 +137,14 @@ algorithm
137137
list<tuple<DAE.Exp,list<DAE.ComponentRef>>> lstExpCrefs;
138138
case (exp,vars)
139139
equation
140-
((_,(_,crefs))) = Exp.traverseExpTopDown(exp,traversecheckDEALowExp,((vars,{})));
140+
((_,(_,crefs))) = Exp.traverseExpTopDown(exp,traversecheckDAELowExp,((vars,{})));
141141
lstExpCrefs = Util.if_(listLength(crefs)>0,{(exp,crefs)},{});
142142
then
143143
lstExpCrefs;
144144
end matchcontinue;
145-
end checkDEALowExp;
145+
end checkDAELowExp;
146146

147-
protected function traversecheckDEALowExp
147+
protected function traversecheckDAELowExp
148148
input tuple<DAE.Exp, tuple<DAELow.Variables,list<DAE.ComponentRef>>> inTuple;
149149
output tuple<DAE.Exp, tuple<DAELow.Variables,list<DAE.ComponentRef>>> outTuple;
150150
algorithm
@@ -158,6 +158,8 @@ algorithm
158158
// special case for time, it is never part of the equation system
159159
case ((e as DAE.CREF(componentRef = DAE.CREF_IDENT(ident="time")),(vars,crefs)))
160160
then ((e, (vars,crefs)));
161+
case ((e as DAE.CREF(componentRef = DAE.WILD()), (vars,crefs)))
162+
then ((e, (vars,crefs)));
161163
/* Special Case for Records */
162164
case ((e as DAE.CREF(componentRef = cr),(vars,crefs)))
163165
local
@@ -169,7 +171,7 @@ algorithm
169171
equation
170172
DAE.ET_COMPLEX(varLst=varLst) = Exp.crefLastType(cr);
171173
expl = Util.listMap1(varLst,DAELow.generateCrefsExpFromType,e);
172-
expcreflstlst = Util.listMap1(expl,checkDEALowExp,vars);
174+
expcreflstlst = Util.listMap1(expl,checkDAELowExp,vars);
173175
expcreflst = Util.listFlatten(expcreflstlst);
174176
creflstlst = Util.listMap(expcreflst,Util.tuple22);
175177
crlst = Util.listFlatten(creflstlst);
@@ -204,6 +206,6 @@ algorithm
204206
((e, (vars,cr::crefs)));
205207
case (_) then inTuple;
206208
end matchcontinue;
207-
end traversecheckDEALowExp;
209+
end traversecheckDAELowExp;
208210

209211
end DAELowUtil;

Compiler/DAEUtil.mo

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5331,4 +5331,4 @@ algorithm
53315331
then res;
53325332
end matchcontinue;
53335333
end varHasName;
5334-
*/
5334+
*/

0 commit comments

Comments
 (0)