aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-07-29 08:37:00 +0000
committerdos-reis <gdr@axiomatics.org>2010-07-29 08:37:00 +0000
commitf8232edef433c9bdfa1f072fdd7dafd0fa01c62a (patch)
tree30c70cf2875a9da8c046de8adfc23fea0b224a33 /src/interp
parent708ad63d818302003bbff2306892007cdc9888cf (diff)
downloadopen-axiom-f8232edef433c9bdfa1f072fdd7dafd0fa01c62a.tar.gz
* interp/c-util.boot (removeToplevelRETURN_-FROM): New.
(transformToBackendCode): Use it to clean function body.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/c-util.boot12
1 files changed, 11 insertions, 1 deletions
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: <name, parms, stmt1, ...>
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