aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
Diffstat (limited to 'src/interp')
-rw-r--r--src/interp/compiler.boot17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index 16222b24..6323bf51 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -329,24 +329,23 @@ finishLambdaExpression(expr is ["LAMBDA",vars,.],env) ==
frees is [[var,:.]] =>
vec := var
["LAMBDA",[:vars,var],:CDDR expandedFunction]
- scode := nil
+ scode := nil -- list of multiple used variables, need local bindings.
slist := nil -- list of single used variables, no local bindings.
- locals := nil -- list of multiple used variables, need local bindings.
i := -1
for v in frees repeat
i := i+1
vec := [first v,:vec]
rest v = 1 => slist := [[first v,"getShellEntry","$$",i],:slist]
- scode := [['SETQ,first v,["getShellEntry","$$",i]],:scode]
- locals := [first v,:locals]
+ scode := [[first v,["getShellEntry","$$",i]],:scode]
body :=
slist => SUBLISNQ(slist,CDDR expandedFunction)
CDDR expandedFunction
- if locals then
- if body is [["DECLARE",:.],:.] then
- body := [first body,["PROG",locals,:scode,
- ["RETURN",["PROGN",:rest body]]]]
- else body := [["PROG",locals,:scode,["RETURN",["PROGN",:body]]]]
+ if scode ~= nil then
+ body :=
+ body is [["DECLARE",:.],:.] =>
+ [first body,["PROG",nreverse scode,
+ ["RETURN",["PROGN",:rest body]]]]
+ [["LET",nreverse scode,:body]]
vec := ["VECTOR",:nreverse vec]
["LAMBDA",[:vars,"$$"],:body]
fname := ["CLOSEDFN",expandedFunction] --Like QUOTE, but gets compiled