Skip to content

Commit ff8345d

Browse files
author
Jens Frenkel
committed
- Algorithm.mo
use Exp.makeCrefExp for crefToExp - Convert.mo use Exp.unelabExp for fromExpExpToAbsynExp use ComponentReference.unelabCref for fromExpCrefToAbsynCref - DAELow.mo use ComponentReference.crefAddPrefix for crefPrefixDer and delete makeDerCref because it has done the same as crefPrefixDer - SimCode.mo use crefPrefixDer instead of crefPrefixDer git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/sjoelund-functiontree@6592 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 47b9c86 commit ff8345d

File tree

4 files changed

+11
-77
lines changed

4 files changed

+11
-77
lines changed

Compiler/Algorithm.mo

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -827,11 +827,7 @@ protected function crefToExp "function: crefToExp
827827
input DAE.ComponentRef inComponentRef;
828828
output DAE.Exp outExp;
829829
algorithm
830-
outExp:=
831-
matchcontinue (inComponentRef)
832-
local DAE.ComponentRef cref;
833-
case cref then DAE.CREF(cref,DAE.ET_OTHER());
834-
end matchcontinue;
830+
outExp:= Exp.makeCrefExp(inComponentRef,DAE.ET_OTHER());
835831
end crefToExp;
836832

837833

Compiler/Convert.mo

Lines changed: 5 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ package Convert
4040
RCS: $Id$"
4141

4242
public import Absyn;
43+
public import ComponentReference;
4344
public import DAE;
45+
public import Exp;
4446

4547
public function fromDAEEqsToAbsynAlg "function: fromDAEEqsToAbsynAlgElts"
4648
input DAE.DAElist ld;
@@ -98,71 +100,15 @@ public function fromExpExpToAbsynExp "function: fromExpExpToAbsynExp"
98100
input DAE.Exp exp1;
99101
output Absyn.Exp expOut;
100102
algorithm
101-
expOut :=
102-
matchcontinue (exp1)
103-
case (DAE.ICONST(i)) local Integer i; equation then Absyn.INTEGER(i);
104-
case (DAE.RCONST(r)) local Real r; equation then Absyn.REAL(r);
105-
case (DAE.SCONST(s)) local String s; equation then Absyn.STRING(s);
106-
case (DAE.BCONST(b)) local Boolean b; equation then Absyn.BOOL(b);
107-
case (DAE.CREF(cr,_))
108-
local
109-
DAE.ComponentRef cr;
110-
Absyn.ComponentRef c;
111-
equation
112-
c = fromExpCrefToAbsynCref(cr);
113-
then Absyn.CREF(c);
114-
end matchcontinue;
103+
expOut := Exp.unelabExp(exp1);
115104
end fromExpExpToAbsynExp;
116105

117106
public function fromExpCrefToAbsynCref
118107
input DAE.ComponentRef cIn;
119108
output Absyn.ComponentRef cOut;
120109
algorithm
121-
cOut := matchcontinue (cIn)
122-
local
123-
DAE.Ident id;
124-
list<DAE.Subscript> subScriptList;
125-
list<Absyn.Subscript> subScriptList2;
126-
DAE.ComponentRef cRef;
127-
Absyn.ComponentRef elem,cRef2;
128-
case (DAE.CREF_QUAL(id,_,subScriptList,cRef))
129-
equation
130-
cRef2 = fromExpCrefToAbsynCref(cRef);
131-
subScriptList2 = fromExpSubsToAbsynSubs(subScriptList,{});
132-
elem = Absyn.CREF_QUAL(id,subScriptList2,cRef2);
133-
then elem;
134-
case (DAE.CREF_IDENT(id,_,subScriptList))
135-
equation
136-
subScriptList2 = fromExpSubsToAbsynSubs(subScriptList,{});
137-
elem = Absyn.CREF_IDENT(id,subScriptList2);
138-
then elem;
139-
end matchcontinue;
140-
end fromExpCrefToAbsynCref;
141-
142-
public function fromExpSubsToAbsynSubs
143-
input list<DAE.Subscript> inList;
144-
input list<Absyn.Subscript> accList;
145-
output list<Absyn.Subscript> outList;
146-
algorithm
147-
outList :=
148-
matchcontinue (inList,accList)
149-
local
150-
list<Absyn.Subscript> localAccList;
151-
case ({},localAccList) then localAccList;
152-
case (DAE.INDEX(e) :: restList,localAccList)
153-
local
154-
DAE.Exp e;
155-
Absyn.Exp e2;
156-
Absyn.Subscript elem;
157-
list<DAE.Subscript> restList;
158-
equation
159-
e2 = fromExpExpToAbsynExp(e);
160-
elem = Absyn.SUBSCRIPT(e2);
161-
localAccList = listAppend(localAccList,{elem});
162-
localAccList = fromExpSubsToAbsynSubs(restList,localAccList);
163-
then localAccList;
164-
end matchcontinue;
165-
end fromExpSubsToAbsynSubs;
110+
cOut := ComponentReference.unelabCref(cIn);
111+
end fromExpCrefToAbsynCref;
166112

167113
end Convert;
168114

Compiler/DAELow.mo

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11423,17 +11423,9 @@ public function crefPrefixDer
1142311423
input DAE.ComponentRef inCref;
1142411424
output DAE.ComponentRef outCref;
1142511425
algorithm
11426-
outCref := ComponentReference.makeCrefQual("$DER", DAE.ET_REAL(), {}, inCref);
11426+
outCref := ComponentReference.crefAddPrefix(derivativeNamePrefix,{},DAE.ET_REAL(), inCref);
1142711427
end crefPrefixDer;
1142811428

11429-
public function makeDerCref
11430-
"Appends $DER to a cref and constructs a DAE.CREF_QUAL from the resulting cref."
11431-
input DAE.ComponentRef inCref;
11432-
output DAE.ComponentRef outCref;
11433-
algorithm
11434-
outCref := ComponentReference.makeCrefQual("$DER", DAE.ET_REAL(), {}, inCref);
11435-
end makeDerCref;
11436-
1143711429
public function equationSource "Retrieve the source from a BackendDAE.DAELow equation"
1143811430
input BackendDAE.Equation eq;
1143911431
output DAE.ElementSource source;
@@ -12073,7 +12065,7 @@ algorithm
1207312065
case(cref, x, stateVars) equation
1207412066
({v1}, _) = getVar(cref, BackendDAEUtil.listVar(stateVars));
1207512067
true = isStateVar(v1);
12076-
cref = makeDerCref(cref);
12068+
cref = crefPrefixDer(cref);
1207712069
id = ComponentReference.printComponentRefStr(cref) +& BackendDAE.partialDerivativeNamePrefix +& ComponentReference.printComponentRefStr(x);
1207812070
id = Util.stringReplaceChar(id, ".", "$P");
1207912071
id = Util.stringReplaceChar(id, "[", "$pL");
@@ -12222,7 +12214,7 @@ algorithm
1222212214
equation
1222312215
Builtin.isDer(fname);
1222412216
cref = Exp.expCref(e1);
12225-
cref = makeDerCref(cref);
12217+
cref = crefPrefixDer(cref);
1222612218
//str = derivativeNamePrefix +& Exp.printExpStr(e1);
1222712219
//cref = ComponentReference.makeCrefIdent(str, DAE.ET_REAL(),{});
1222812220
e1_ = differentiateWithRespectToX(Exp.crefExp(cref), x, functions, inputVars, paramVars, stateVars);

Compiler/SimCode.mo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2877,7 +2877,7 @@ algorithm
28772877
equation
28782878
(BackendDAE.EQUATION(e1, e2,_), v as BackendDAE.VAR(varName = cr, varKind = BackendDAE.STATE()))
28792879
= getEquationAndSolvedVar(eqNum, eqns, vars, ass2);
2880-
cr = DAELow.makeDerCref(cr);
2880+
cr = DAELow.crefPrefixDer(cr);
28812881
exp_ = solve(e1, e2, DAE.CREF(cr,DAE.ET_REAL()));
28822882
then
28832883
SES_SIMPLE_ASSIGN(cr, exp_);
@@ -3883,7 +3883,7 @@ algorithm
38833883
expLst = {DAE.CREF(componentRef = cr)}),
38843884
NONE()))
38853885
equation
3886-
cr = DAELow.makeDerCref(cr);
3886+
cr = DAELow.crefPrefixDer(cr);
38873887
then
38883888
((DAE.CREF(cr,DAE.ET_REAL()), NONE()));
38893889
case (_) then inExp;

0 commit comments

Comments
 (0)