aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/interp/lisp-backend.boot22
2 files changed, 25 insertions, 2 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f278102d..1898d80a 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,10 @@
2011-12-03 Gabriel Dos Reis <gdr@cs.tamu.edu>
+ * interp/lisp-backend.boot (hasNoExit?): New.
+ (expandSeq): Likewise. Use it. Expand %seq forms.
+
+2011-12-03 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
* interp/compiler.boot: Use %seq in lieu of PROGN.
* interp/g-util.boot (spliceSeqArgs): New.
* interp/g-opt.boot (changeVariableDefinitionToStore): Call it
diff --git a/src/interp/lisp-backend.boot b/src/interp/lisp-backend.boot
index 3cd7524e..2c801bed 100644
--- a/src/interp/lisp-backend.boot
+++ b/src/interp/lisp-backend.boot
@@ -206,6 +206,24 @@ expandReturn(x is ['%return,.,y]) ==
$FUNNAME = nil => systemErrorHere ['expandReturn,x]
['RETURN_-FROM,$FUNNAME,expandToVMForm y]
+
+++ Subroutine of expandSeq.
+++ Return true if the form `x' contains no %exit form.
+hasNoExit? x ==
+ atomic? x => true
+ x is ['%exit,:.] => false
+ and/[hasNoExit? s for s in x]
+
+++ Expand a sequence of statements with possible non-local
+++ lexical control transfer. Attempt to recognize those with
+++ normal lexical exit.
+expandSeq(x is ['%seq,:stmts]) ==
+ [:stmts',val] := stmts
+ and/[hasNoExit? s for s in stmts'] and
+ val is ['%exit,val'] and hasNoExit? val' =>
+ ['PROGN,:[expandToVMForm s for s in stmts'],expandToVMForm val']
+ ['SEQ,:[expandToVMForm s for s in stmts]]
+
-- Pointer operations
expandPeq ['%peq,x,y] ==
x = '%nil => ['NULL,expandToVMForm y]
@@ -637,7 +655,6 @@ for x in [
['%funcall, :'FUNCALL],
['%function, :'FUNCTION],
['%lambda, :'LAMBDA],
- ['%seq, :'SEQ],
['%exit, :'EXIT],
['%when, :'COND],
@@ -653,7 +670,8 @@ for x in [
['%collect, :function expandCollect],
['%loop, :function expandLoop],
['%return, :function expandReturn],
- ['%leave, :function expandLeave],
+ ['%leave, :function expandLeave],
+ ['%seq, :function expandSeq],
['%bcompl, :function expandBcompl],