Skip to content

Commit

Permalink
- Fixed use of partially evaulated functions in functions
Browse files Browse the repository at this point in the history
- Added a test case for this


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@4544 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Stefan Brus committed Nov 19, 2009
1 parent dedf4aa commit bbe6461
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion Compiler/PartFn.mo
Expand Up @@ -473,6 +473,39 @@ algorithm
end matchcontinue;
end isFunctionElement;

protected function replaceFnInFnLst
"function: replaceFnInFnLst
takes a given function and replaces the function with the same path in the daelist with it"
input DAE.Element inFunction;
input list<DAE.Element> inElementList;
output list<DAE.Element> outElementList;
algorithm
outElementList := matchcontinue(inFunction,inElementList)
local
list<DAE.Element> cdr,cdr_1;
Absyn.Path newFn,p;
Exp.ComponentRef cr1,cr2;
DAE.Element fn,el;
case(_,{})
equation
Debug.fprintln("failtrace","- PartFn.replaceFnInFnLst failed");
then
fail();
case(fn as DAE.FUNCTION(path = newFn),DAE.FUNCTION(path = p) :: cdr)
equation
cr1 = Exp.pathToCref(newFn);
cr2 = Exp.pathToCref(p);
true = Exp.crefEqual(cr1,cr2);
then
fn :: cdr;
case(fn, el :: cdr)
equation
cdr_1 = replaceFnInFnLst(fn,cdr);
then
el :: cdr_1;
end matchcontinue;
end replaceFnInFnLst;

protected function elabElements
"function: elabElements
goes through a list of DAE.Element for partevalfunction"
Expand Down Expand Up @@ -615,8 +648,10 @@ algorithm
equation
(elts_1,dae) = elabElements(elts,dae);
(cdr_1,dae) = elabElements(cdr,dae);
el = DAE.FUNCTION(p,DAE.DAE(elts_1),fullType,pp);
dae = replaceFnInFnLst(el,dae);
then
(DAE.FUNCTION(p,DAE.DAE(elts_1),fullType,pp) :: cdr_1,dae);
(el :: cdr_1,dae);
case(DAE.EXTFUNCTION(p,DAE.DAE(elts),fullType,ed) :: cdr,dae)
equation
(elts_1,dae) = elabElements(elts,dae);
Expand Down

0 comments on commit bbe6461

Please sign in to comment.