diff options
Diffstat (limited to 'src/interp')
-rw-r--r-- | src/interp/lisp-backend.boot | 22 |
1 files changed, 20 insertions, 2 deletions
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], |