aboutsummaryrefslogtreecommitdiff
path: root/src/interp
diff options
context:
space:
mode:
authordos-reis <gdr@axiomatics.org>2010-06-07 18:15:49 +0000
committerdos-reis <gdr@axiomatics.org>2010-06-07 18:15:49 +0000
commit6aca99e6211a8fe97a8bb84d2bc85f9900f35315 (patch)
tree286e2d41adb25c0e1fdfb25aaddb5267e7ef1dc7 /src/interp
parent7422a29157bf7de1742eade45590dbed7d0d4a12 (diff)
downloadopen-axiom-6aca99e6211a8fe97a8bb84d2bc85f9900f35315.tar.gz
* interp/compiler.boot (finishLambdaExpression): Bind escaped
variables with LET-form instead of assignment.
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