aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-07-24 01:50:09 +0000
committerdos-reis <gdr@axiomatics.org>2010-07-24 01:50:09 +0000
commitc19e54f03e3230811e6c86998568ce63ccbc42c9 (patch)
treeea96f5e883e0aa28215c397677fcd213b10d6735 /src/interp
parent3a373a0b802ee86308db78cba8696aa7b6cdf4df (diff)
downloadopen-axiom-c19e54f03e3230811e6c86998568ce63ccbc42c9.tar.gz
* interp/compiler.boot (compMatchAlternative): Don't generate
LET-expressions. * interp/g-opt.boot (optBind): Tidy.
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/compiler.boot3
-rw-r--r--src/interp/g-opt.boot16
2 files changed, 13 insertions, 6 deletions
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index 4999b870..85f796bc 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -2169,8 +2169,7 @@ compMatchAlternative(sn,sm,pat,stmt,m,e) ==
stackAndThrow('"could not compile %1b under mode %2pb",[stmt,m])
body :=
null inits => stmtT.expr
- atom sn => ["LET",inits,stmtT.expr]
- ["%bind",inits,stmtT.expr]
+ ['%bind,inits,stmtT.expr]
[[guard,body],stmtT.mode,stmtT.env,eF]
++ Analyze and generate code for `is case'-pattern where the
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index a42dc1ac..ccde3eb8 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -590,10 +590,18 @@ optLET_* form ==
optLET form
optBind 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 isnt ['%bind,inits,.] => form -- accept only simple bodies
+ ok := true
+ while ok and inits ~= nil repeat
+ [var,expr] := first inits
+ usedSymbol?(var,rest inits) => ok := false -- no dependency, please.
+ body := third form
+ canInlineVarDefinition(var,expr,body) and isSimpleVMForm expr =>
+ third(form) := substitute_!(expr,var,body)
+ inits := rest inits
+ ok := false
+ null inits => third form -- no local var left
+ second(form) := inits
form
optLIST form ==