From dcc0ed6a46a2607284dbfa87ee7fb9514dbbf705 Mon Sep 17 00:00:00 2001 From: hkiel Date: Mon, 1 Feb 2016 16:23:23 +0100 Subject: [PATCH] convert some matchcontinue to match makes some functions tail recursive --- Compiler/FrontEnd/ClassInf.mo | 13 ++++----- Compiler/FrontEnd/Graphviz.mo | 54 +++++++++++++++++------------------ Compiler/FrontEnd/Inline.mo | 4 +-- Compiler/FrontEnd/MMath.mo | 6 ++-- 4 files changed, 38 insertions(+), 39 deletions(-) diff --git a/Compiler/FrontEnd/ClassInf.mo b/Compiler/FrontEnd/ClassInf.mo index 7ca0d708875..30133b1ae6e 100644 --- a/Compiler/FrontEnd/ClassInf.mo +++ b/Compiler/FrontEnd/ClassInf.mo @@ -234,7 +234,7 @@ public function printState input State inState; algorithm _:= - matchcontinue (inState) + match (inState) local Absyn.Path p; case UNKNOWN(path = p) @@ -334,7 +334,7 @@ algorithm Print.printBuf(Absyn.pathString(p)); Print.printBuf(printStateStr(inState)); then (); - end matchcontinue; + end match; end printState; public function getStateName "Returns the classname of the state." @@ -663,9 +663,8 @@ public function matchingState " output Boolean outBoolean; algorithm outBoolean:= - matchcontinue (inState,inStateLst) + match (inState,inStateLst) local - State st,first; list rest; Boolean res; case (_,{}) then false; @@ -685,12 +684,12 @@ algorithm // BTH case (TYPE_CLOCK(),(TYPE_CLOCK() :: _)) then true; case (TYPE_ENUM(),(TYPE_ENUM() :: _)) then true; - case (st,(_ :: rest)) + case (_,(_ :: rest)) equation - res = matchingState(st, rest); + res = matchingState(inState, rest); then res; - end matchcontinue; + end match; end matchingState; public function isFunction diff --git a/Compiler/FrontEnd/Graphviz.mo b/Compiler/FrontEnd/Graphviz.mo index 691495031f9..2f7a5430c3b 100644 --- a/Compiler/FrontEnd/Graphviz.mo +++ b/Compiler/FrontEnd/Graphviz.mo @@ -144,37 +144,37 @@ protected function makeLabel "Creates a label from a list of strings." protected Label s0,s1; algorithm - s0 := makeLabelReq(sl); + s0 := makeLabelReq(sl,""); s1 := stringAppend("\"", s0); s2 := stringAppend(s1, "\""); end makeLabel; protected function makeLabelReq "Helper function to makeLabel" input list inStringLst; + input String inString; output String outString; algorithm - outString := matchcontinue (inStringLst) + outString := match (inStringLst) local - Label s,res,s1,s2,old; + Label s,s1,s2; list