Skip to content

Commit

Permalink
- Expression.mo
Browse files Browse the repository at this point in the history
  delete makeCrefExpNoType and use crefExp
  rename generateCrefsExpFromType to generateCrefsExpFromExpVar

git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/sjoelund-functiontree@6671 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Oct 27, 2010
1 parent 5156ff2 commit 91f758f
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
11 changes: 5 additions & 6 deletions Compiler/BackendDAECreate.mo
Expand Up @@ -3044,7 +3044,6 @@ algorithm
DAE.FunctionTree funcs;
BackendDAE.Equation eqn;
DAE.ComponentRef cr1,cr2;
DAE.Exp e1,e2;
list<DAE.Exp> e1lst,e2lst;
list<DAE.ExpVar> varLst;
Integer i;
Expand All @@ -3058,12 +3057,12 @@ algorithm
list<DAE.Exp> expLst;
list<tuple<DAE.Exp,DAE.Exp>> exptpllst;
// a=b
case (BackendDAE.COMPLEX_EQUATION(index=i,lhs = e1 as DAE.CREF(componentRef=cr1), rhs = e2 as DAE.CREF(componentRef=cr2),source = source),funcs)
case (BackendDAE.COMPLEX_EQUATION(index=i,lhs = DAE.CREF(componentRef=cr1), rhs = DAE.CREF(componentRef=cr2),source = source),funcs)
equation
// create as many equations as the dimension of the record
DAE.ET_COMPLEX(varLst=varLst) = ComponentReference.crefLastType(cr1);
e1lst = Util.listMap1(varLst,Expression.generateCrefsExpFromType,e1);
e2lst = Util.listMap1(varLst,Expression.generateCrefsExpFromType,e2);
e1lst = Util.listMap1(varLst,Expression.generateCrefsExpFromExpVar,cr1);
e2lst = Util.listMap1(varLst,Expression.generateCrefsExpFromExpVar,cr2);
exptpllst = Util.listThreadTuple(e1lst,e2lst);
compmultilistlst = Util.listMap2(exptpllst,generateextendedRecordEqn,source,funcs);
complexEqsLst = Util.listMap(compmultilistlst,Util.tuple21);
Expand All @@ -3080,12 +3079,12 @@ algorithm
then
((complexEqs1,multiEqs2));
// a=Record()
case (BackendDAE.COMPLEX_EQUATION(index=i,lhs = e1 as DAE.CREF(componentRef=cr1), rhs = e2 as DAE.CALL(path=path,expLst=expLst),source = source),funcs)
case (BackendDAE.COMPLEX_EQUATION(index=i,lhs = DAE.CREF(componentRef=cr1), rhs = DAE.CALL(path=path,expLst=expLst),source = source),funcs)
equation
SOME(DAE.RECORD_CONSTRUCTOR(path=fname)) = DAEUtil.avlTreeGet(funcs,path);
// create as many equations as the dimension of the record
DAE.ET_COMPLEX(varLst=varLst) = ComponentReference.crefLastType(cr1);
e1lst = Util.listMap1(varLst,Expression.generateCrefsExpFromType,e1);
e1lst = Util.listMap1(varLst,Expression.generateCrefsExpFromExpVar,cr1);
exptpllst = Util.listThreadTuple(e1lst,expLst);
compmultilistlst = Util.listMap2(exptpllst,generateextendedRecordEqn,source,funcs);
complexEqsLst = Util.listMap(compmultilistlst,Util.tuple21);
Expand Down
10 changes: 5 additions & 5 deletions Compiler/BackendDAEUtil.mo
Expand Up @@ -199,7 +199,7 @@ algorithm
list<DAE.ExpVar> varLst;
equation
DAE.ET_COMPLEX(varLst=varLst) = ComponentReference.crefLastType(cr);
expl = Util.listMap1(varLst,Expression.generateCrefsExpFromType,e);
expl = Util.listMap1(varLst,Expression.generateCrefsExpFromExpVar,cr);
expcreflstlst = Util.listMap1(expl,checkBackendDAEExp,vars);
expcreflst = Util.listFlatten(expcreflstlst);
creflstlst = Util.listMap(expcreflst,Util.tuple22);
Expand Down Expand Up @@ -1405,10 +1405,10 @@ algorithm
list<list<tuple<DAE.Exp, Boolean>>> mexp;
list<DAE.ExpVar> varLst;
/* Special Case for Records */
case ((e as DAE.CREF(componentRef = cr)),vars)
case ((DAE.CREF(componentRef = cr)),vars)
equation
DAE.ET_COMPLEX(varLst=varLst) = ComponentReference.crefLastType(cr);
expl = Util.listMap1(varLst,Expression.generateCrefsExpFromType,e);
expl = Util.listMap1(varLst,Expression.generateCrefsExpFromExpVar,cr);
lst = Util.listMap1(expl, statesAndVarsExp, vars);
res = Util.listListUnionOnTrue(lst, Expression.expEqual);
then
Expand Down Expand Up @@ -2815,9 +2815,9 @@ algorithm outExp := matchcontinue(inExp)
then
(restpl);
// CASE for Records
case( (e as DAE.CREF(componentRef=cr,ty= t as DAE.ET_COMPLEX(name=name,varLst=varLst,complexClassType=ClassInf.RECORD(_))), funcs) )
case( (DAE.CREF(componentRef=cr,ty= t as DAE.ET_COMPLEX(name=name,varLst=varLst,complexClassType=ClassInf.RECORD(_))), funcs) )
equation
expl = Util.listMap1(varLst,Expression.generateCrefsExpFromType,e);
expl = Util.listMap1(varLst,Expression.generateCrefsExpFromExpVar,cr);
e_new = DAE.CALL(name,expl,false,false,t,DAE.NO_INLINE());
restpl = Expression.traverseExp(e_new, traversingextendArrExp, funcs);
then
Expand Down
40 changes: 20 additions & 20 deletions Compiler/Expression.mo
Expand Up @@ -466,26 +466,6 @@ end dimensionSubscript;
/* Change */
/***************************************************/

public function generateCrefsExpFromType "
Author: Frenkel TUD 2010-05"
input DAE.ExpVar inVar;
input DAE.Exp inExp;
output DAE.Exp outCrefExp;
algorithm outCrefExp := matchcontinue(inVar,inExp)
local
String name;
DAE.ExpType tp;
DAE.ComponentRef cr,cr1;
DAE.Exp e;
case (DAE.COMPLEX_VAR(name=name,tp=tp),DAE.CREF(componentRef=cr))
equation
cr1 = ComponentReference.crefPrependIdent(cr,name,{},tp);
e = makeCrefExp(cr1, tp);
then
e;
end matchcontinue;
end generateCrefsExpFromType;

public function negate
"function: negate
author: PA
Expand Down Expand Up @@ -2146,6 +2126,26 @@ algorithm cref := matchcontinue(cr)
end matchcontinue;
end crefExp;

public function generateCrefsExpFromExpVar "
Author: Frenkel TUD 2010-05"
input DAE.ExpVar inVar;
input DAE.ComponentRef inCrefPrefix;
output DAE.Exp outCrefExp;
algorithm outCrefExp := matchcontinue(inVar,inCrefPrefix)
local
String name;
DAE.ExpType tp;
DAE.ComponentRef cr;
DAE.Exp e;
case (DAE.COMPLEX_VAR(name=name,tp=tp),inCrefPrefix)
equation
cr = ComponentReference.crefPrependIdent(inCrefPrefix,name,{},tp);
e = makeCrefExp(cr, tp);
then
e;
end matchcontinue;
end generateCrefsExpFromExpVar;

public function makeRealArray
"function: makeRealArray
Construct an array node of an DAE.Exp list of type REAL."
Expand Down

0 comments on commit 91f758f

Please sign in to comment.