Skip to content

Commit

Permalink
Another attempt to fix the bug http://openmodelica.ida.liu.se:8080/cb…
Browse files Browse the repository at this point in the history
…/issue/1098 -- this time, without adding extra equations, only modifying parameter bindings.

git-svn-id: https://openmodelica.org/svn/OpenModelica/branches/MathCoreOSMC@4082 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Alexey Lebedev committed Jun 15, 2009
1 parent 90e5afd commit b7b7aec
Showing 1 changed file with 85 additions and 1 deletion.
86 changes: 85 additions & 1 deletion Compiler/Inst.mo
Expand Up @@ -5371,7 +5371,10 @@ algorithm
dae2 = Util.if_(Types.isComplexType(ty), dae2,{});
dae3 = listAppend(dae2,dae3);
*/
dae = listAppend(dae1_1, dae3);
dae2 = instModEquation(cr, ty, mod, impl);
daex= propagateBinding(dae1_1, dae2) "The equations generated by instModEquation are used only to modify
the bindings of parameters (DAE.VAR's in dae1_1). No extra equations are added. -- alleb";
dae = listAppend(daex, dae3);
then
(cache,env_1,dae,csets_1,ty,graph);

Expand Down Expand Up @@ -13896,5 +13899,86 @@ algorithm
end matchcontinue;
end daeDeclareComplexVarType;

protected function propagateBinding "
This function modifies equations into bindings for parameters"
input list<DAE.Element> inVars;
input list<DAE.Element> inEquations;
output list<DAE.Element> outVars;
algorithm
outVars:=matchcontinue(inVars,inEquations)
local
list<DAE.Element> vars, vars1, equations;
DAE.Element var;
Exp.Exp e;
Exp.ComponentRef componentRef;
DAE.VarKind kind;
DAE.VarDirection direction;
DAE.VarProtection protection;
DAE.Type ty;
Option<Exp.Exp> binding;
DAE.InstDims dims;
DAE.Flow flowPrefix;
DAE.Stream streamPrefix;
list<Absyn.Path> pathLst;
Option<DAE.VariableAttributes> variableAttributesOption;
Option<Absyn.Comment> absynCommentOption;
Absyn.InnerOuter innerOuter;
Types.Type fullType;

case (vars,{}) then vars;
case ({},_) then {};
case (DAE.VAR(componentRef,kind,direction,protection,ty,NONE(),dims,flowPrefix,streamPrefix,pathLst,variableAttributesOption,absynCommentOption,innerOuter,fullType)::vars, equations)
equation
SOME(e)=findCorrespondingBinding(componentRef, equations);
vars1=propagateBinding(vars,equations);
then
DAE.VAR(componentRef,kind,direction,protection,ty,SOME(e),dims,flowPrefix,streamPrefix,pathLst,variableAttributesOption,absynCommentOption,innerOuter,fullType)::vars1;
case (var::vars, equations)
equation
vars1=propagateBinding(vars,equations);
then
var::vars1;
end matchcontinue;
end propagateBinding;

protected function findCorrespondingBinding "
Helper function for propagateBinding"
input Exp.ComponentRef inCref;
input list<DAE.Element> inEquations;
output Option<Exp.Exp> outExp;
algorithm
outExp:=matchcontinue(inCref, inEquations)
local
Exp.ComponentRef cref,cref2,cref3;
Exp.Exp e;
list<DAE.Element> equations;

case (_, {}) then NONE();
case (cref, DAE.DEFINE(cref2, e)::_)
equation
true=Exp.crefEqual(cref,cref2);
then
SOME(e);
case (cref, DAE.EQUATION(Exp.CREF(cref2,_),e)::_)
equation
true=Exp.crefEqual(cref,cref2);
then
SOME(e);
case (cref, DAE.EQUEQUATION(cref2,cref3)::_)
equation
true=Exp.crefEqual(cref,cref2);
e=Exp.crefExp(cref3);
then
SOME(e);
case (cref, DAE.COMPLEX_EQUATION(Exp.CREF(cref2,_),e)::_)
equation
true=Exp.crefEqual(cref,cref2);
then
SOME(e);
case (cref, _::equations)
then findCorrespondingBinding(cref,equations);
end matchcontinue;
end findCorrespondingBinding;

end Inst;

0 comments on commit b7b7aec

Please sign in to comment.