Skip to content

Commit

Permalink
- sort inners again to put inner Modelica.* component; first.
Browse files Browse the repository at this point in the history
- some tests might need changes, I'll do that next

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@13939 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Nov 17, 2012
1 parent 7ecfb70 commit 1fde101
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions Compiler/FrontEnd/Inst.mo
Original file line number Diff line number Diff line change
Expand Up @@ -15194,6 +15194,8 @@ algorithm
equation
// split into inner, inner outer and other elements
(innerElts, innerouterElts, otherElts) = splitInnerAndOtherTplLstElementMod(inTplLstElementMod);
// sort the inners to put Modelica types first!
innerElts = sortInnerPutModelicaFirst(innerElts, {});
// put the inner elements first
sorted = listAppend(innerElts, innerouterElts);
// put the innerouter elements second
Expand All @@ -15203,7 +15205,41 @@ algorithm
end matchcontinue;
end sortInnerFirstTplLstElementMod;

protected function sortInnerPutModelicaFirst
"@author: adrpo
This function will move all the *inner* Modelica.*
elements first in the given list of elements"
input list<tuple<SCode.Element, DAE.Mod>> inTplLstElementMod;
input list<tuple<SCode.Element, DAE.Mod>> inAcc;
output list<tuple<SCode.Element, DAE.Mod>> outTplLstElementMod;
algorithm
outTplLstElementMod := matchcontinue(inTplLstElementMod, inAcc)
local
list<tuple<SCode.Element, DAE.Mod>> rest, acc;
SCode.Element e;
DAE.Mod m;
tuple<SCode.Element, DAE.Mod> em;
Absyn.Path p;

case ({}, _)
then listReverse(inAcc);

case (em::rest, _)
equation
e = Util.tuple21(em);
Absyn.TPATH(p, _) = SCode.getComponentTypeSpec(e);
true = stringEq("Modelica", Absyn.pathFirstIdent(p));
acc = sortInnerPutModelicaFirst(rest, listAppend(inAcc, {em}));
then
acc;

case ((em as (e, m))::rest, _)
equation
acc = sortInnerPutModelicaFirst(rest, em::inAcc);
then
acc;
end matchcontinue;
end sortInnerPutModelicaFirst;

public function splitInnerAndOtherTplLstElementMod
"@author: adrpo
Expand Down

0 comments on commit 1fde101

Please sign in to comment.