aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-07-23 21:09:39 +0000
committerdos-reis <gdr@axiomatics.org>2010-07-23 21:09:39 +0000
commit3a373a0b802ee86308db78cba8696aa7b6cdf4df (patch)
tree108c4c3e28d1fb0c98a0841e9696f51c0e87ec72 /src/interp
parent95a01c8b0ae5635b456e34d95bc7b0570a1952b8 (diff)
downloadopen-axiom-3a373a0b802ee86308db78cba8696aa7b6cdf4df.tar.gz
* interp/g-opt.boot (optBind): Check for dependencies in
initializations in %bind expressions. * interp/g-util.boot (expandBind): The body of s %bind expression may be a sequence of statements.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/g-opt.boot7
-rw-r--r--src/interp/g-util.boot10
2 files changed, 9 insertions, 8 deletions
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index 543cf45e..a42dc1ac 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -590,8 +590,11 @@ optLET_* form ==
optLET form
optBind form ==
- form.first := "LET*"
- optLET_* form
+ form isnt ['%bind,inits,body] => form -- inline only simple expressions
+ inits = nil => body -- no local variable, OK.
+ inits isnt [[var,expr]] => form -- too many local variables
+ canInlineVarDefinition(var,expr,body) => substitute(expr,var,body)
+ form
optLIST form ==
form is ["LIST"] => nil
diff --git a/src/interp/g-util.boot b/src/interp/g-util.boot
index 5889fc2a..13acbdc6 100644
--- a/src/interp/g-util.boot
+++ b/src/interp/g-util.boot
@@ -305,16 +305,14 @@ expandFgt ['%fgt,x,y] ==
expandFlt ['%flt,y,x]
-- Local variable bindings
-expandBind ['%bind,inits,body] ==
+expandBind ['%bind,inits,:body] ==
body := expandToVMForm body
inits := [[first x,expandToVMForm second x] for x in inits]
- n := #inits
- n = 0 => body
-- FIXME: we should consider turning LET* into LET or direct inlining.
op :=
- n = 1 => 'LET
- 'LET_*
- [op,inits,body]
+ or/[CONTAINED(v,x) for [[v,.],:x] in tails inits] => 'LET_*
+ 'LET
+ [op,inits,:body]
-- Memory load/store