Skip to content

Commit

Permalink
- continue to reimplement remove simple equation stuff using informat…
Browse files Browse the repository at this point in the history
…ion of the incidence matrix

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@8462 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Apr 1, 2011
1 parent 0f90cf3 commit dcc8c76
Showing 1 changed file with 69 additions and 1 deletion.
70 changes: 69 additions & 1 deletion Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -1502,7 +1502,7 @@ algorithm
vareqns1 = Util.listRemoveOnTrue(pos,intEq,vareqns);
// update Replacements
repl_1 = VarTransform.addReplacement(repl, cr, exp);
//extendrepl1 = addExtendReplacement(extendrepl, cr, exp);
extendrepl1 = addExtendReplacement(extendrepl, cr, NONE());
// replace var=exp in vareqns
dae2 = replacementsInEqns(vareqns1,repl_1,extendrepl,dae1);
// set eqn to 0=0 to avoid next call
Expand All @@ -1515,6 +1515,74 @@ algorithm
end matchcontinue;
end removeSimpleEquationsFinder;

protected function addExtendReplacement
"function: addExtendReplacement
author: Frenkel TUD 2011-04
checks if the parents of cref from type array or record
and add a rule to extend them."
input VarTransform.VariableReplacements extendrepl;
input DAE.ComponentRef cr;
input Option<DAE.ComponentRef> preCr;
output VarTransform.VariableReplacements outExtendrepl;
algorithm
outExtendrepl:=
matchcontinue (extendrepl,cr,preCr)
local
VarTransform.VariableReplacements erepl,erepl1;
DAE.ComponentRef cr,subcr,precr,precr1,pcr;
DAE.Ident ident;
DAE.ExpType ty;
list<DAE.Subscript> subscriptLst;
DAE.Exp exp,crexp;
case (extendrepl,DAE.CREF_IDENT(ident=_),NONE()) then extendrepl;
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.ET_ARRAY(ty=_),subscriptLst=subscriptLst,componentRef=subcr),NONE())
equation
precr = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
crexp = Expression.crefExp(precr);
((exp,_)) = BackendDAEUtil.extendArrExp((crexp,NONE()));
// update Replacements
erepl = VarTransform.addReplacement(extendrepl, precr, exp);
erepl1 = addExtendReplacement(erepl,subcr,SOME(precr));
then erepl1;
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.ET_COMPLEX(complexClassType=ClassInf.RECORD(_)),subscriptLst=subscriptLst,componentRef=subcr),NONE())
equation
precr = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
crexp = Expression.crefExp(precr);
((exp,_)) = BackendDAEUtil.extendArrExp((crexp,NONE()));
// update Replacements
erepl = VarTransform.addReplacement(extendrepl, precr, exp);
erepl1 = addExtendReplacement(erepl,subcr,SOME(precr));
then erepl1;
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.ET_ARRAY(ty=_),subscriptLst=subscriptLst,componentRef=subcr),SOME(pcr))
equation
precr = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
precr1 = ComponentReference.joinCrefs(pcr,precr);
crexp = Expression.crefExp(precr1);
((exp,_)) = BackendDAEUtil.extendArrExp((crexp,NONE()));
// update Replacements
erepl = VarTransform.addReplacement(extendrepl, precr1, exp);
erepl1 = addExtendReplacement(erepl,subcr,SOME(precr));
then erepl1;
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty as DAE.ET_COMPLEX(complexClassType=ClassInf.RECORD(_)),subscriptLst=subscriptLst,componentRef=subcr),SOME(pcr))
equation
precr = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
precr1 = ComponentReference.joinCrefs(pcr,precr);
crexp = Expression.crefExp(precr1);
((exp,_)) = BackendDAEUtil.extendArrExp((crexp,NONE()));
// update Replacements
erepl = VarTransform.addReplacement(extendrepl, precr1, exp);
erepl1 = addExtendReplacement(erepl,subcr,SOME(precr));
then erepl1;
// all other
case (extendrepl,cr as DAE.CREF_QUAL(ident=ident,identType=ty,subscriptLst=subscriptLst,componentRef=subcr),SOME(pcr))
equation
precr = ComponentReference.makeCrefIdent(ident,ty,subscriptLst);
precr1 = ComponentReference.joinCrefs(pcr,precr);
erepl = addExtendReplacement(extendrepl,subcr,SOME(precr1));
then erepl;
end matchcontinue;
end addExtendReplacement;

protected function replacementsInEqns
"function: replacementsInEqns
author: Frenkel TUD 2011-04"
Expand Down

0 comments on commit dcc8c76

Please sign in to comment.