aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
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 ==