Skip to content

Commit

Permalink
more improvements to new frontend
Browse files Browse the repository at this point in the history
- provide souce information to all DAE elements
- flatten all statements and equations (except connect)
- use a for loop in DAEUtil.getVarBinding
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Dec 18, 2016
1 parent 778e564 commit 5fed053
Show file tree
Hide file tree
Showing 4 changed files with 304 additions and 112 deletions.
149 changes: 74 additions & 75 deletions Compiler/FrontEnd/DAEUtil.mo
Expand Up @@ -6135,81 +6135,80 @@ public function getVarBinding "
input list<DAE.Element> iels;
input DAE.ComponentRef icr;
output Option<DAE.Exp> obnd;
algorithm
obnd :=
matchcontinue (iels)
local
DAE.ComponentRef cr;
DAE.Exp e;
list<DAE.Element> lst;

case ({}) then NONE();

case (DAE.VAR(componentRef = cr, binding = obnd)::lst)
algorithm
if not ComponentReference.crefEqualNoStringCompare(icr, cr) then
obnd := getVarBinding(lst, icr);
end if;
then
obnd;

case (DAE.DEFINE(componentRef = cr, exp = e)::lst)
algorithm
obnd := SOME(e);
if not ComponentReference.crefEqualNoStringCompare(icr, cr) then
obnd := getVarBinding(lst, icr);
end if;
then
obnd;

case (DAE.INITIALDEFINE(componentRef = cr, exp = e)::lst)
algorithm
obnd := SOME(e);
if not ComponentReference.crefEqualNoStringCompare(icr, cr) then
obnd := getVarBinding(lst, icr);
end if;
then
obnd;

case (DAE.EQUATION(exp = DAE.CREF(componentRef = cr), scalar = e)::lst)
algorithm
obnd := SOME(e);
if not ComponentReference.crefEqualNoStringCompare(icr, cr) then
obnd := getVarBinding(lst, icr);
end if;
then
obnd;

case (DAE.EQUATION(exp = e, scalar = DAE.CREF(componentRef = cr))::lst)
algorithm
obnd := SOME(e);
if not ComponentReference.crefEqualNoStringCompare(icr, cr) then
obnd := getVarBinding(lst, icr);
end if;
then
obnd;

case (DAE.INITIALEQUATION(exp1 = DAE.CREF(componentRef = cr), exp2 = e)::lst)
algorithm
obnd := SOME(e);
if not ComponentReference.crefEqualNoStringCompare(icr, cr) then
obnd := getVarBinding(lst, icr);
end if;
then
obnd;

case (DAE.INITIALEQUATION(exp1 = e, exp2 = DAE.CREF(componentRef = cr))::lst)
algorithm
obnd := SOME(e);
if not ComponentReference.crefEqualNoStringCompare(icr, cr) then
obnd := getVarBinding(lst, icr);
end if;
then
obnd;

case (_::lst)
then getVarBinding(lst, icr);
end matchcontinue;
protected
DAE.ComponentRef cr;
DAE.Exp e;
list<DAE.Element> lst;
algorithm
obnd := NONE();
for i in iels loop
obnd := match i
case DAE.VAR(componentRef = cr, binding = obnd)
algorithm
if ComponentReference.crefEqualNoStringCompare(icr, cr) then
return;
end if;
then
obnd;

case DAE.DEFINE(componentRef = cr, exp = e)
algorithm
obnd := SOME(e);
if ComponentReference.crefEqualNoStringCompare(icr, cr) then
return;
end if;
then
obnd;

case DAE.INITIALDEFINE(componentRef = cr, exp = e)
algorithm
obnd := SOME(e);
if ComponentReference.crefEqualNoStringCompare(icr, cr) then
return;
end if;
then
obnd;

case DAE.EQUATION(exp = DAE.CREF(componentRef = cr), scalar = e)
algorithm
obnd := SOME(e);
if ComponentReference.crefEqualNoStringCompare(icr, cr) then
return;
end if;
then
obnd;

case DAE.EQUATION(exp = e, scalar = DAE.CREF(componentRef = cr))
algorithm
obnd := SOME(e);
if ComponentReference.crefEqualNoStringCompare(icr, cr) then
return;
end if;
then
obnd;

case DAE.INITIALEQUATION(exp1 = DAE.CREF(componentRef = cr), exp2 = e)
algorithm
obnd := SOME(e);
if ComponentReference.crefEqualNoStringCompare(icr, cr) then
return;
end if;
then
obnd;

case DAE.INITIALEQUATION(exp1 = e, exp2 = DAE.CREF(componentRef = cr))
algorithm
obnd := SOME(e);
if ComponentReference.crefEqualNoStringCompare(icr, cr) then
return;
end if;
then
obnd;

else obnd;

end match;
end for;
end getVarBinding;

public function evaluateCref
Expand Down
6 changes: 3 additions & 3 deletions Compiler/FrontEnd/ElementSource.mo
Expand Up @@ -67,9 +67,9 @@ function createElementSource
"@author: adrpo
set the various sources of the element"
input SourceInfo fileInfo;
input Option<Absyn.Path> partOf "the model(s) this element came from";
input Prefix.Prefix prefix "the instance(s) this element is part of";
input tuple<DAE.ComponentRef, DAE.ComponentRef> connectEquation=(DAE.emptyCref, DAE.emptyCref) "this element came from this connect(s)";
input Option<Absyn.Path> partOf = NONE() "the model(s) this element came from";
input Prefix.Prefix prefix = Prefix.NOPRE() "the instance(s) this element is part of";
input tuple<DAE.ComponentRef, DAE.ComponentRef> connectEquation = (DAE.emptyCref, DAE.emptyCref) "this element came from this connect(s)";
output DAE.ElementSource source;
protected
Absyn.Path path;
Expand Down

0 comments on commit 5fed053

Please sign in to comment.