Skip to content

Commit

Permalink
Fix stack overflow in traversal
Browse files Browse the repository at this point in the history
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Mar 31, 2016
1 parent 29cc490 commit 09afcd1
Showing 1 changed file with 15 additions and 29 deletions.
44 changes: 15 additions & 29 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -5821,42 +5821,28 @@ public function traverseStrongComponentsJacobiansExp
replaceable type Type_a subtypeof Any;
input BackendDAE.StrongComponents inComps;
input FuncExpType inFunc;
input Type_a inTypeA;
output Type_a outTypeA;
input output Type_a arg;
partial function FuncExpType
input DAE.Exp inExp;
input Type_a inTypeA;
output DAE.Exp outExp;
output Type_a outA;
end FuncExpType;
algorithm
outTypeA :=
matchcontinue(inComps, inFunc, inTypeA)
local
BackendDAE.StrongComponents rest;
BackendDAE.StrongComponent comp;
list<tuple<Integer, Integer, BackendDAE.Equation>> jac;
BackendDAE.BackendDAE bdae;
Type_a arg;
case ({}, _, _) then inTypeA;
case (BackendDAE.EQUATIONSYSTEM(jac=BackendDAE.FULL_JACOBIAN(SOME(jac)))::rest, _, _)
equation
arg = traverseBackendDAEExpsJacobianEqn(jac, inFunc, inTypeA);
then
traverseStrongComponentsJacobiansExp(rest, inFunc, arg);
case (BackendDAE.EQUATIONSYSTEM(jac=BackendDAE.GENERIC_JACOBIAN(jacobian = (bdae,_,_,_,_)))::rest, _, _)
equation
arg = traverseBackendDAEExps(bdae, inFunc, inTypeA);
then
traverseStrongComponentsJacobiansExp(rest, inFunc, arg);
case (BackendDAE.TORNSYSTEM(BackendDAE.TEARINGSET(jac=BackendDAE.GENERIC_JACOBIAN(jacobian = (bdae,_,_,_,_))))::rest, _, _)
equation
arg = traverseBackendDAEExps(bdae, inFunc, inTypeA);
then
traverseStrongComponentsJacobiansExp(rest, inFunc, arg);
case (_::rest, _, _) then
traverseStrongComponentsJacobiansExp(rest, inFunc, inTypeA);
end matchcontinue;
for comp in inComps loop
arg := match comp
local
list<tuple<Integer, Integer, BackendDAE.Equation>> jac;
BackendDAE.BackendDAE bdae;
case BackendDAE.EQUATIONSYSTEM(jac=BackendDAE.FULL_JACOBIAN(SOME(jac)))
then traverseBackendDAEExpsJacobianEqn(jac, inFunc, arg);
case BackendDAE.EQUATIONSYSTEM(jac=BackendDAE.GENERIC_JACOBIAN(jacobian = (bdae,_,_,_,_)))
then traverseBackendDAEExps(bdae, inFunc, arg);
case BackendDAE.TORNSYSTEM(BackendDAE.TEARINGSET(jac=BackendDAE.GENERIC_JACOBIAN(jacobian = (bdae,_,_,_,_))))
then traverseBackendDAEExps(bdae, inFunc, arg);
else arg;
end match;
end for;
end traverseStrongComponentsJacobiansExp;

protected function traverseBackendDAEExpsJacobianEqn "Helper for traverseExpsOfEquation."
Expand Down

0 comments on commit 09afcd1

Please sign in to comment.