Skip to content

Commit

Permalink
- do not replace crefs from initial equations
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@14606 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Jens Frenkel committed Dec 31, 2012
1 parent 631a3b9 commit 7632aa0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 30 deletions.
32 changes: 11 additions & 21 deletions Compiler/BackEnd/BackendEquation.mo
Original file line number Diff line number Diff line change
Expand Up @@ -479,36 +479,26 @@ protected function traversingEquationCrefFinder
"author: Frenkel TUD 2010-11"
input tuple<BackendDAE.Equation, list<DAE.ComponentRef>> inTpl;
output tuple<BackendDAE.Equation, list<DAE.ComponentRef>> outTpl;
protected
BackendDAE.Equation e;
list<DAE.ComponentRef> cr_lst;
algorithm
outTpl:=
matchcontinue (inTpl)
local
BackendDAE.Equation e;
list<DAE.ComponentRef> cr_lst,cr_lst1;
case ((e,cr_lst))
equation
(_,cr_lst1) = traverseBackendDAEExpsEqn(e,extractCrefsFromExp,cr_lst);
then ((e,cr_lst1));
case _ then inTpl;
end matchcontinue;
(e,cr_lst) := inTpl;
(_,cr_lst) := traverseBackendDAEExpsEqn(e,extractCrefsFromExp,cr_lst);
outTpl := (e,cr_lst);
end traversingEquationCrefFinder;

protected function extractCrefsFromExp "function: extractCrefsFromExp
author: Frenkel TUD 2010-11
helper for equationsCrefs"
input tuple<DAE.Exp, list<DAE.ComponentRef>> inTpl;
output tuple<DAE.Exp, list<DAE.ComponentRef>> outTpl;
protected
list<DAE.ComponentRef> crefs;
DAE.Exp e,e1;
algorithm
outTpl := match(inTpl)
local
list<DAE.ComponentRef> crefs,crefs1;
DAE.Exp e,e1;
case((e,crefs))
equation
((e1,crefs1)) = Expression.traverseExp(e, Expression.traversingComponentRefFinder, crefs);
then
((e1,crefs1));
end match;
(e,crefs) := inTpl;
outTpl := Expression.traverseExp(e, Expression.traversingComponentRefFinder, crefs);
end extractCrefsFromExp;

public function equationUnknownCrefs
Expand Down
37 changes: 36 additions & 1 deletion Compiler/BackEnd/RemoveSimpleEquations.mo
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,46 @@ protected function addUnreplacableFromWhens
output HashSet.HashSet outUnreplacable;
protected
BackendDAE.EqSystems systs;
BackendDAE.EquationArray eqns;
algorithm
BackendDAE.DAE(eqs=systs) := inDAE;
BackendDAE.DAE(eqs=systs,shared=BackendDAE.SHARED(initialEqs=eqns)) := inDAE;
outUnreplacable := List.fold(systs,addUnreplacableFromWhensSystem,inUnreplacable);
outUnreplacable := BackendDAEUtil.traverseBackendDAEExpsEqns(eqns,addUnreplacableFromEqns,outUnreplacable);
end addUnreplacableFromWhens;

protected function addUnreplacableFromEqns "function: addUnreplacableFromEqns
author: Frenkel TUD 2010-12
helper for equationsCrefs"
input tuple<DAE.Exp,HashSet.HashSet> inTpl;
output tuple<DAE.Exp,HashSet.HashSet> outTpl;
protected
HashSet.HashSet hs;
DAE.Exp e,e1;
algorithm
(e,hs) := inTpl;
outTpl := Expression.traverseExp(e, addUnreplacableFromEqnsExp, hs);
end addUnreplacableFromEqns;

protected function addUnreplacableFromEqnsExp "function: addUnreplacableFromEqnsExp
author: Frenkel TUD 2010-12"
input tuple<DAE.Exp,HashSet.HashSet> inExp;
output tuple<DAE.Exp,HashSet.HashSet> outExp;
algorithm
outExp := match(inExp)
local
HashSet.HashSet hs;
DAE.ComponentRef cr;
DAE.Exp e;
case((e as DAE.CREF(componentRef=cr), hs))
equation
cr = ComponentReference.crefStripLastSubs(cr);
hs = BaseHashSet.add(cr,hs);
then
((e, hs ));
case _ then inExp;
end match;
end addUnreplacableFromEqnsExp;

protected function addUnreplacableFromWhensSystem
"function: addUnreplacableFromWhensSystem
author: Frenkel TUD 2012-12
Expand Down
11 changes: 3 additions & 8 deletions Compiler/FrontEnd/Expression.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5143,23 +5143,18 @@ Returns a list containing, unique, all componentRef in an Expression."
input tuple<DAE.Exp, list<ComponentRef>> inExp;
output tuple<DAE.Exp, list<ComponentRef>> outExp;
algorithm
outExp := matchcontinue(inExp)
outExp := match(inExp)
local
list<ComponentRef> crefs;
ComponentRef cr;
Type ty;
DAE.Exp e;

case((e as DAE.CREF(cr,ty), crefs))
case((e as DAE.CREF(componentRef=cr), crefs))
equation
crefs = List.unionEltOnTrue(cr,crefs,ComponentReference.crefEqual);
// e = makeCrefExp(cr,ty);
then
((e, crefs ));

case _ then inExp;

end matchcontinue;
end match;
end traversingComponentRefFinder;

public function traversingDerAndComponentRefFinder "
Expand Down

0 comments on commit 7632aa0

Please sign in to comment.