Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Tail recursion for SimCodeUtil.elaborateRecordDeclarationsForMetarecords


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@15150 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Feb 11, 2013
1 parent e192663 commit 7e534e4
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions Compiler/BackEnd/SimCodeUtil.mo
Original file line number Diff line number Diff line change
Expand Up @@ -5488,28 +5488,29 @@ protected function elaborateRecordDeclarationsForMetarecords
output list<SimCode.RecordDeclaration> outRecordDecls;
output list<String> outReturnTypes;
algorithm
(outRecordDecls, outReturnTypes) := matchcontinue(inExpl, inAccRecordDecls, inReturnTypes)
(outRecordDecls, outReturnTypes) := match (inExpl, inAccRecordDecls, inReturnTypes)
local
list<String> rt, rt_1, rt_2, fieldNames;
list<DAE.Exp> rest;
String name;
Absyn.Path path;
list<SimCode.RecordDeclaration> accRecDecls;
Boolean b;

case ({}, accRecDecls, rt) then (accRecDecls, rt);
case (DAE.METARECORDCALL(path=path, fieldNames=fieldNames)::rest, accRecDecls, rt)
equation
name = Absyn.pathStringReplaceDot(path, "_");
false = listMember(name, rt);
accRecDecls = SimCode.RECORD_DECL_DEF(path, fieldNames) :: accRecDecls;
rt_1 = name::rt;
b = listMember(name, rt);
accRecDecls = List.consOnTrue(not b, SimCode.RECORD_DECL_DEF(path, fieldNames), accRecDecls);
rt_1 = List.consOnTrue(not b, name, rt);
(accRecDecls, rt_2) = elaborateRecordDeclarationsForMetarecords(rest, accRecDecls, rt_1);
then (accRecDecls, rt_2);
case (_::rest, accRecDecls, rt)
equation
(accRecDecls, rt_1) = elaborateRecordDeclarationsForMetarecords(rest, accRecDecls, rt);
then (accRecDecls, rt_1);
end matchcontinue;
case (_::rest, accRecDecls, rt)
equation
(accRecDecls, rt_1) = elaborateRecordDeclarationsForMetarecords(rest, accRecDecls, rt);
then (accRecDecls, rt_1);
end match;
end elaborateRecordDeclarationsForMetarecords;

protected function createExtObjInfo
Expand Down

0 comments on commit 7e534e4

Please sign in to comment.