[pypy-commit] pypy framestate: create bc_graph.iter_instr()

rlamy noreply at buildbot.pypy.org
Wed Nov 26 12:48:44 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: framestate
Changeset: r74731:dc288d5b57c8
Date: 2014-11-26 00:57 +0100
http://bitbucket.org/pypy/pypy/changeset/dc288d5b57c8/

Log:	create bc_graph.iter_instr()

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -251,6 +251,12 @@
         block, i = position
         return block[i].offset
 
+    def iter_instr(self):
+        while True:
+            offset = self.get_offset(self.curr_position)
+            instr = self.read(offset)
+            yield instr
+
     def dump(self):
         all_blocks = set(x[0] for x in self.pos_index.values())
         blocks = sorted(all_blocks, key=lambda b: b.startpos)
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -350,13 +350,13 @@
         self.setstate(block.framestate)
         self.recorder = block.make_recorder()
         bc_graph = self.pycode.graph
-        next_offset = bc_graph.get_offset(block.framestate.position)
+        bc_graph.curr_position = block.framestate.position
         try:
-            while True:
-                instr = bc_graph.read(next_offset)
+            for instr in bc_graph.iter_instr():
                 self.last_offset = instr.offset
                 next_offset = self.handle_bytecode(instr)
                 position = bc_graph.get_position(next_offset)
+                bc_graph.curr_position = position
                 self.recorder.final_state = self.getstate(position)
 
         except RaiseImplicit as e:


More information about the pypy-commit mailing list