Skip to content

Commit

Permalink
- fix bugs in BackendVarTransform.addExtendReplacement, prior not all…
Browse files Browse the repository at this point in the history
… necessary extendsions added

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@12207 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Jun 25, 2012
1 parent 7b1fb8d commit 34dfc7d
Showing 1 changed file with 30 additions and 12 deletions.
42 changes: 30 additions & 12 deletions Compiler/BackEnd/BackendVarTransform.mo
Expand Up @@ -397,33 +397,43 @@ algorithm
DAE.Ident ident;
DAE.Type ty;
list<DAE.Subscript> subscriptLst;
case (extendrepl,cr as DAE.CREF_IDENT(ident=ident,identType=ty as DAE.T_ARRAY(ty=_),subscriptLst=subscriptLst),NONE())
list<DAE.Var> varLst;
list<DAE.ComponentRef> crefs;
case (extendrepl,cr as DAE.CREF_IDENT(ident=ident,identType=ty as DAE.T_ARRAY(ty=_)),NONE())
equation
precr = ComponentReference.makeCrefIdent(ident,ty,{});
failure(_ = BaseHashTable.get(precr,extendrepl));
// update Replacements
erepl = BaseHashTable.add((precr, DAE.RCONST(0.0)),extendrepl);
then erepl;
case (extendrepl,cr as DAE.CREF_IDENT(ident=ident,identType=ty as DAE.T_ARRAY(ty=_),subscriptLst=subscriptLst),SOME(pcr))
case (extendrepl,cr as DAE.CREF_IDENT(ident=ident,identType=ty as DAE.T_ARRAY(ty=_)),SOME(pcr))
equation
precr = ComponentReference.makeCrefIdent(ident,ty,{});
precr1 = ComponentReference.joinCrefs(pcr,precr);
failure(_ = BaseHashTable.get(precr1,extendrepl));
// update Replacements
erepl = BaseHashTable.add((precr1, DAE.RCONST(0.0)),extendrepl);
then erepl;
case (extendrepl,cr as DAE.CREF_IDENT(ident=ident,identType=ty as DAE.T_COMPLEX(complexClassType=ClassInf.RECORD(_)),subscriptLst=subscriptLst),NONE())
case (extendrepl,cr as DAE.CREF_IDENT(ident=ident,identType=ty as DAE.T_COMPLEX(complexClassType=ClassInf.RECORD(_),varLst=varLst)),NONE())
equation
failure(_ = BaseHashTable.get(cr,extendrepl));
precr = ComponentReference.makeCrefIdent(ident,ty,{});
failure(_ = BaseHashTable.get(precr,extendrepl));
// update Replacements
erepl = BaseHashTable.add((cr, DAE.RCONST(0.0)),extendrepl);
erepl = BaseHashTable.add((precr, DAE.RCONST(0.0)),extendrepl);
// Create a list of crefs from names
crefs = List.map(varLst,ComponentReference.creffromVar);
erepl = List.fold1r(crefs,addExtendReplacement,SOME(precr),erepl);
then erepl;
case (extendrepl,cr as DAE.CREF_IDENT(ident=ident,identType=ty as DAE.T_COMPLEX(complexClassType=ClassInf.RECORD(_)),subscriptLst=subscriptLst),SOME(pcr))
case (extendrepl,cr as DAE.CREF_IDENT(ident=ident,identType=ty as DAE.T_COMPLEX(complexClassType=ClassInf.RECORD(_),varLst=varLst),subscriptLst=subscriptLst),SOME(pcr))
equation
precr = ComponentReference.makeCrefIdent(ident,ty,{});
precr1 = ComponentReference.joinCrefs(pcr,cr);
failure(_ = BaseHashTable.get(precr1,extendrepl));
// update Replacements
erepl = BaseHashTable.add((precr1, DAE.RCONST(0.0)),extendrepl);
// Create a list of crefs from names
crefs = List.map(varLst,ComponentReference.creffromVar);
erepl = List.fold1r(crefs,addExtendReplacement,SOME(precr1),erepl);
then erepl;
case (extendrepl,DAE.CREF_IDENT(ident=_),_) then extendrepl;
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.T_ARRAY(ty=_),subscriptLst=subscriptLst,componentRef=subcr),NONE())
Expand All @@ -435,14 +445,17 @@ algorithm
precrn = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
erepl1 = addExtendReplacement(erepl,subcr,SOME(precrn));
then erepl1;
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.T_COMPLEX(complexClassType=ClassInf.RECORD(_)),subscriptLst=subscriptLst,componentRef=subcr),NONE())
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.T_COMPLEX(complexClassType=ClassInf.RECORD(_),varLst=varLst),subscriptLst=subscriptLst,componentRef=subcr),NONE())
equation
precr = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
precr = ComponentReference.makeCrefIdent(ident,ty,{});
failure(_ = BaseHashTable.get(precr,extendrepl));
// update Replacements
erepl = BaseHashTable.add((precr, DAE.RCONST(0.0)),extendrepl);
erepl1 = addExtendReplacement(erepl,subcr,SOME(precr));
then erepl1;
// Create a list of crefs from names
crefs = List.map(varLst,ComponentReference.creffromVar);
precr1 = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
erepl = List.fold1r(crefs,addExtendReplacement,SOME(precr1),erepl);
then erepl;
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.T_ARRAY(ty=_),subscriptLst=subscriptLst,componentRef=subcr),SOME(pcr))
equation
precr = ComponentReference.makeCrefIdent(ident,ty,{});
Expand All @@ -454,14 +467,19 @@ algorithm
precrn1 = ComponentReference.joinCrefs(pcr,precrn);
erepl1 = addExtendReplacement(erepl,subcr,SOME(precrn1));
then erepl1;
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.T_COMPLEX(complexClassType=ClassInf.RECORD(_)),subscriptLst=subscriptLst,componentRef=subcr),SOME(pcr))
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.T_COMPLEX(complexClassType=ClassInf.RECORD(_),varLst=varLst),subscriptLst=subscriptLst,componentRef=subcr),SOME(pcr))
equation
precr = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
precr = ComponentReference.makeCrefIdent(ident,ty,{});
precr1 = ComponentReference.joinCrefs(pcr,precr);
failure(_ = BaseHashTable.get(precr1,extendrepl));
// update Replacements
erepl = BaseHashTable.add((precr1, DAE.RCONST(0.0)),extendrepl);
erepl1 = addExtendReplacement(erepl,subcr,SOME(precr1));
// Create a list of crefs from names
crefs = List.map(varLst,ComponentReference.creffromVar);
precrn = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
precrn1 = ComponentReference.joinCrefs(pcr,precrn);
erepl1 = List.fold1r(crefs,addExtendReplacement,SOME(precrn1),erepl1);
then erepl1;
// all other
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty,subscriptLst=subscriptLst,componentRef=subcr),NONE())
Expand Down

0 comments on commit 34dfc7d

Please sign in to comment.