diff --git a/Compiler/BackendDAECreate.mo b/Compiler/BackendDAECreate.mo index ee31f0b04a4..6ba2ee62036 100644 --- a/Compiler/BackendDAECreate.mo +++ b/Compiler/BackendDAECreate.mo @@ -3044,7 +3044,6 @@ algorithm DAE.FunctionTree funcs; BackendDAE.Equation eqn; DAE.ComponentRef cr1,cr2; - DAE.Exp e1,e2; list e1lst,e2lst; list varLst; Integer i; @@ -3058,12 +3057,12 @@ algorithm list expLst; list> 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); @@ -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); diff --git a/Compiler/BackendDAEUtil.mo b/Compiler/BackendDAEUtil.mo index 57ac43706ba..7afa00e3d6e 100644 --- a/Compiler/BackendDAEUtil.mo +++ b/Compiler/BackendDAEUtil.mo @@ -199,7 +199,7 @@ algorithm list 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); @@ -1405,10 +1405,10 @@ algorithm list>> mexp; list 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 @@ -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 diff --git a/Compiler/Expression.mo b/Compiler/Expression.mo index af61aa330d0..e68b4d10c04 100644 --- a/Compiler/Expression.mo +++ b/Compiler/Expression.mo @@ -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 @@ -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."