aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog8
-rw-r--r--src/interp/g-opt.boot10
-rw-r--r--src/interp/lisp-backend.boot7
3 files changed, 21 insertions, 4 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f90a83db..38917e91 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,13 @@
2011-12-01 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/g-opt.boot (changeVariableDefinitionToStore): Handle SEQ
+ forms too.
+ (groupVariableDefinitions): Handle %bind and %loop forms.
+ * interp/lisp-backend.boot (expandLoop): Special code for case
+ where there is explicit exit condition, for better pretty-printing.
+
+2011-12-01 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/g-opt.boot (groupVariableDefinitions): Look through
%labelled and %lambda.
(optimizeFunctionDef): Use copyTree, not COPY. Simplify.
diff --git a/src/interp/g-opt.boot b/src/interp/g-opt.boot
index 67b6aca9..066e2097 100644
--- a/src/interp/g-opt.boot
+++ b/src/interp/g-opt.boot
@@ -81,7 +81,7 @@ changeVariableDefinitionToStore(form,vars) ==
form.op is '%when =>
for clause in form.args repeat
-- variable defined in clause predicates are visible
- -- subsequent predicates
+ -- in subsequent predicates
vars := changeVariableDefinitionToStore(first clause,vars)
-- but those defined in branches are local.
changeVariableDefinitionToStore(rest clause,vars)
@@ -97,6 +97,10 @@ changeVariableDefinitionToStore(form,vars) ==
abstractionOperator? form.op =>
changeVariableDefinitionToStore(form.absBody,[:form.absParms,:vars])
vars
+ form is ['SEQ,:stmts,['EXIT,val]] =>
+ for s in stmts repeat
+ vars := changeVariableDefinitionToStore(s,vars)
+ changeVariableDefinitionToStore(val,vars)
for x in form repeat
vars := changeVariableDefinitionToStore(x,vars)
vars
@@ -125,8 +129,12 @@ groupVariableDefinitions form ==
form
form is ['%labelled,tag,expr] =>
[form.op,tag,groupVariableDefinitions expr]
+ form is ['%bind,inits,expr] =>
+ [form.op,inits,groupVariableDefinitions expr]
form is ['%lambda,:.] =>
[form.absKind,form.absParms,groupVariableDefinitions form.absBody]
+ form is ['%loop,:iters,body,val] =>
+ [form.op,:iters,groupVariableDefinitions body,val]
form isnt ['SEQ,:stmts,['EXIT,val]] => form
defs := nil
for x in stmts while nonExitingSingleAssignment? x repeat
diff --git a/src/interp/lisp-backend.boot b/src/interp/lisp-backend.boot
index 61d53837..316a4ef9 100644
--- a/src/interp/lisp-backend.boot
+++ b/src/interp/lisp-backend.boot
@@ -168,9 +168,10 @@ expandLoop ['%loop,:iters,body,ret] ==
body := mkpf([:filters,body],"AND")
-- If there is any body-wide initialization, now is the time.
body := massageFreeVarInits(body,bodyInits)
- exits := ["COND",
- [mkpf(exits,"OR"),["RETURN",expandToVMForm ret]],
- [true,body]]
+ exits :=
+ exits = nil => body
+ ["COND",[mkpf(exits,"OR"),["RETURN",expandToVMForm ret]],
+ [true,body]]
body := ["LOOP",exits,:cont]
-- Finally, set up loop-wide initializations.
massageFreeVarInits(body,loopInits)