Author: Ronan Lamy <[email protected]>
Branch: framestate
Changeset: r75805:c984486d36dc
Date: 2015-02-10 06:39 +0000
http://bitbucket.org/pypy/pypy/changeset/c984486d36dc/

Log:    find the actual target of break statements during analyze_signals()
        phase

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -146,7 +146,6 @@
             if self.offset in self.pending_blocks:
                 next_block = self.pending_blocks[self.offset]
                 if not self.curr_block.operations:
-                    import pdb; pdb.set_trace
                     self.blocks.pop()
                 self.enter_next_block(next_block)
             elif self.needs_new_block:
@@ -222,6 +221,12 @@
             for exit in block._exits:
                 exit.set_blockstack(self.blockstack)
 
+    def unroll(self, signal):
+        while self.blockstack:
+            block = self.blockstack.pop()
+            if isinstance(signal, block.handles):
+                return block
+
     def check_graph(self):
         for b in self.blocks:
             if not b._exits:
@@ -527,6 +532,15 @@
 
 @bc_reader.register_opcode
 class BREAK_LOOP(BCInstruction):
+    def bc_flow(self, reader):
+        reader.curr_block.operations.append(self)
+        reader.end_block()
+
+    def do_signals(self, reader):
+        from rpython.flowspace.flowcontext import Break
+        frameblock = reader.unroll(Break())
+        reader.curr_block.set_exits([frameblock.handler])
+
     def eval(self, ctx):
         from rpython.flowspace.flowcontext import Break
         return ctx.unroll(Break())
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to