aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog5
-rw-r--r--src/interp/compiler.boot15
2 files changed, 14 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 453830a7..b1d41d6d 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,8 @@
+2010-06-12 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * interp/compiler.boot (compIterate): Rewrite.
+ (compRepeatOrCollect): Tidy. Bind $loopBodyTag.
+
2010-06-11 Gabriel Dos Reis <gdr@cs.tamu.edu>
* algebra/tree.spad.pamphlet (node?$Tree): Fix thinko.
diff --git a/src/interp/compiler.boot b/src/interp/compiler.boot
index 4489cf96..87d07c89 100644
--- a/src/interp/compiler.boot
+++ b/src/interp/compiler.boot
@@ -1101,11 +1101,14 @@ compBreak(x,m,e) ==
compIterate: (%Symbol,%Mode,%Env) -> %Maybe %Triple
compIterate(x,m,e) ==
x ~= "iterate" or not jumpFromLoop("REPEAT",x) => nil
+ index := #$exitModeStack - 1 - ($leaveLevelStack.0 + 1)
$iterateCount := $iterateCount + 1
- -- We don't really produce a value; but we cannot adequately convey
- -- that to the current 'EXIT' structure. So, pretend we have an
- -- undefined value, which is a good enough approximation.
- [["THROW","$loopBodyTag",nil],m,e]
+ u := coerce(['%nil,'$Void,e],$exitModeStack.index) or return nil
+ u := coerce(u,m) or return nil
+ modifyModeStack(u.mode,index)
+ if $loopBodyTag = nil then -- bound in compRepeatOrCollect
+ $loopBodyTag := MKQ gensym()
+ [['THROW,$loopBodyTag,u.expr],u.mode,e]
--% return
@@ -2267,6 +2270,7 @@ compRepeatOrCollect(form,m,e) ==
$until: local := nil
$loopKind: local := nil
$iterateCount: local := 0
+ $loopBodyTag: local := nil
$breakCount: local := 0
oldEnv := e
aggr := nil
@@ -2295,8 +2299,7 @@ compRepeatOrCollect(form,m,e) ==
[body',m',e'] := compOrCroak(body,bodyMode,e) or return nil
-- Massage the loop body if we have a structured jump.
if $iterateCount > 0 then
- bodyTag := quoteForm gensym()
- body' := ["CATCH",bodyTag,NSUBST(bodyTag,"$loopBodyTag",body')]
+ body' := ["CATCH",$loopBodyTag,body']
if $until then
[untilCode,.,e']:= comp($until,$Boolean,e')
itl':= substitute(["UNTIL",untilCode],'$until,itl')