Skip to content

Commit

Permalink
Tail recursion
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@17899 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
sjoelund committed Oct 27, 2013
1 parent 032163c commit c299554
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 21 deletions.
4 changes: 1 addition & 3 deletions Compiler/BackEnd/BackendDAETransform.mo
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,7 @@ algorithm
e = -1;
then
varAssignmentNonScalar(index+1,size,ass1,mapIncRowEqn,e::iAcc);
else
then
listArray(listReverse(iAcc));
else listArray(listReverse(iAcc));
end matchcontinue;
end varAssignmentNonScalar;

Expand Down
22 changes: 6 additions & 16 deletions Compiler/BackEnd/IndexReduction.mo
Original file line number Diff line number Diff line change
Expand Up @@ -157,27 +157,17 @@ protected function getChangedEqnsAndLowest
output list<Integer> oAcc;
output Integer oLowest;
algorithm
(oAcc,oLowest) := matchcontinue(index,ass2,iAcc,iLowest)
(oAcc,oLowest) := match (index,ass2,iAcc,iLowest)
local
list<Integer> acc;
Integer l;
case(_,_,_,_)
equation
true = intGt(index,0);
true = intLt(ass2[index],1);
(acc,l) = getChangedEqnsAndLowest(index-1,ass2,index::iAcc,index);
then
(acc,l);
case(_,_,_,_)
case (0,_,_,_) then (iAcc,iLowest);
case (_,_,_,_)
equation
true = intGt(index,0);
(acc,l) = getChangedEqnsAndLowest(index-1,ass2,iAcc,iLowest);
then
(acc,l);
case(_,_,_,_)
then
(iAcc,iLowest);
end matchcontinue;
(acc,l) = getChangedEqnsAndLowest(index-1,ass2,List.consOnTrue(intLt(ass2[index],1),index,iAcc),index);
then (acc,l);
end match;
end getChangedEqnsAndLowest;

protected function pantelidesIndexReduction1
Expand Down
4 changes: 2 additions & 2 deletions Compiler/Util/List.mo
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ public function split2
output list<ElementType> outList1;
output list<ElementType> outList2;
algorithm
(outList1, outList2) := matchcontinue(inList1, inList2, inPosition)
(outList1, outList2) := match (inList1, inList2, inPosition)
local
ElementType e;
list<ElementType> rest, list1, list2;
Expand All @@ -1306,7 +1306,7 @@ algorithm
print("Index out of bounds (greater than list length) in relation List.split\n");
then
fail();
end matchcontinue;
end match;
end split2;

public function splitOnTrue
Expand Down

0 comments on commit c299554

Please sign in to comment.