[pypy-commit] pypy framestate: Use (bc_block, index-in-block) as position

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


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: framestate
Changeset: r74730:84a74ea27d86
Date: 2014-11-25 19:21 +0100
http://bitbucket.org/pypy/pypy/changeset/84a74ea27d86/

Log:	Use (bc_block, index-in-block) as position

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -245,10 +245,11 @@
             return block.operations[i].offset
 
     def get_position(self, offset):
-        return offset
+        return self.pos_index[offset]
 
     def get_offset(self, position):
-        return position
+        block, i = position
+        return block[i].offset
 
     def dump(self):
         all_blocks = set(x[0] for x in self.pos_index.values())
diff --git a/rpython/flowspace/pygraph.py b/rpython/flowspace/pygraph.py
--- a/rpython/flowspace/pygraph.py
+++ b/rpython/flowspace/pygraph.py
@@ -1,7 +1,7 @@
 """
 Implements flow graphs for Python callables
 """
-from rpython.flowspace.model import FunctionGraph, Constant, Variable
+from rpython.flowspace.model import FunctionGraph, Variable
 from rpython.flowspace.framestate import FrameState
 
 class PyGraph(FunctionGraph):
@@ -14,7 +14,9 @@
         locals = [None] * code.co_nlocals
         for i in range(code.formalargcount):
             locals[i] = Variable(code.co_varnames[i])
-        state = FrameState(locals, [], None, [], 0)
+        bc_graph = code.graph
+        start_pos = bc_graph.entry._exits[0], 0
+        state = FrameState(locals, [], None, [], start_pos)
         initialblock = SpamBlock(state)
         super(PyGraph, self).__init__(self._sanitize_funcname(func), initialblock)
         self.func = func


More information about the pypy-commit mailing list