From f8232edef433c9bdfa1f072fdd7dafd0fa01c62a Mon Sep 17 00:00:00 2001 From: dos-reis Date: Thu, 29 Jul 2010 08:37:00 +0000 Subject: * interp/c-util.boot (removeToplevelRETURN_-FROM): New. (transformToBackendCode): Use it to clean function body. --- src/ChangeLog | 5 +++++ src/interp/c-util.boot | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ChangeLog b/src/ChangeLog index 5055d842..b7e694f2 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2010-07-29 Gabriel Dos Reis + + * interp/c-util.boot (removeToplevelRETURN_-FROM): New. + (transformToBackendCode): Use it to clean function body. + 2010-07-28 Gabriel Dos Reis * interp/spad.lisp (DIVIDE2): Remove. diff --git a/src/interp/c-util.boot b/src/interp/c-util.boot index d18c4dea..c72da0df 100644 --- a/src/interp/c-util.boot +++ b/src/interp/c-util.boot @@ -1603,6 +1603,16 @@ needsPROG? form == form is ['BLOCK,=nil,:.] => false or/[needsPROG? x for x in form] +++ We are processing the complete `body' of a function definition. +++ If this body is a multiway test, there is no need to have +++ a RETURN-FROM operator in the immediate consequence of a branch. +removeToplevelRETURN_-FROM body == + if body is [['COND,:stmts]] then + for stmt in stmts repeat + stmt is [.,['RETURN_-FROM,.,expr]] => + second(stmt) := expr + body + ++ Generate Lisp code by lowering middle end defining form `x'. ++ x has the strucrure: transformToBackendCode: %Form -> %Code @@ -1635,7 +1645,7 @@ transformToBackendCode x == [declareGlobalVariables fluids,:body] lvars ~= nil or needsPROG? body => [["PROG",lvars,["RETURN",:body]]] - body + removeToplevelRETURN_-FROM body -- add reference parameters to the list of special variables. fluids := S_+(backendFluidize second x, $SpecialVars) lastdecl := lastDeclarationNode rest x -- cgit v1.2.3