Author: Stephan <[email protected]>
Branch:
Changeset: r238:7c31c0623500
Date: 2012-06-02 10:49 +0200
http://bitbucket.org/pypy/lang-js/changeset/7c31c0623500/
Log: 11.4.1
diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -680,9 +680,14 @@
def do_jump(self, ctx, pos):
from js.jsobj import W_Iterator
+ last_block_value = ctx.stack_pop()
iterator = ctx.stack_top()
assert isinstance(iterator, W_Iterator)
if iterator.empty():
+ # discard the iterator
+ ctx.stack_pop()
+ # put the last block value on the stack
+ ctx.stack_append(last_block_value)
return self.where
return pos + 1
diff --git a/js/operations.py b/js/operations.py
--- a/js/operations.py
+++ b/js/operations.py
@@ -932,8 +932,11 @@
w_object.emit(bytecode)
bytecode.emit('LOAD_ITERATOR')
+ # load the "last" iterations result
+ bytecode.emit('LOAD_UNDEFINED')
precond = bytecode.emit_startloop_label()
finish = bytecode.prealocate_endloop_label()
+
bytecode.emit('JUMP_IF_ITERATOR_EMPTY', finish)
# put next iterator value on stack
@@ -965,13 +968,8 @@
raise JsTypeError('unsupported')
body.emit(bytecode)
- # remove last body statement from stack
- bytecode.emit('POP')
bytecode.emit('JUMP', precond)
bytecode.emit_endloop_label(finish)
- # remove the iterrator from stack
- bytecode.emit('POP')
- bytecode.emit('LOAD_UNDEFINED')
class For(Statement):
def __init__(self, pos, setup, condition, update, body):
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit