[pypy-commit] pypy framestate: create bc_reader.build_code()

rlamy noreply at buildbot.pypy.org
Mon Nov 24 17:29:57 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: framestate
Changeset: r74686:1eb9dc57448a
Date: 2014-11-18 15:19 +0000
http://bitbucket.org/pypy/pypy/changeset/1eb9dc57448a/

Log:	create bc_reader.build_code()

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -169,6 +169,9 @@
             op = GenericOpcode(self.opnames[opnum], opnum, oparg, offset)
         return next_offset, op
 
+    def build_code(self, code):
+        return HostCode._from_code(code)
+
 bc_reader = BytecodeReader(host_bytecode_spec.method_names)
 
 class BytecodeGraph(object):
diff --git a/rpython/flowspace/generator.py b/rpython/flowspace/generator.py
--- a/rpython/flowspace/generator.py
+++ b/rpython/flowspace/generator.py
@@ -1,7 +1,7 @@
 """Flow graph building for generators"""
 
 from rpython.flowspace.argument import Signature
-from rpython.flowspace.bytecode import HostCode
+from rpython.flowspace.bytecode import bc_reader
 from rpython.flowspace.pygraph import PyGraph
 from rpython.flowspace.model import (Block, Link, Variable,
     Constant, checkgraph, const)
@@ -18,7 +18,7 @@
 def make_generator_entry_graph(func):
     # This is the first copy of the graph.  We replace it with
     # a small bootstrap graph.
-    code = HostCode._from_code(func.func_code)
+    code = bc_reader.build_code(func.func_code)
     graph = PyGraph(func, code)
     block = graph.startblock
     for name, w_value in zip(code.co_varnames, block.framestate.mergeable):
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -4,7 +4,7 @@
 from inspect import CO_NEWLOCALS, isgeneratorfunction
 
 from rpython.flowspace.model import checkgraph
-from rpython.flowspace.bytecode import HostCode
+from rpython.flowspace.bytecode import bc_reader
 from rpython.flowspace.flowcontext import (FlowContext, fixeggblocks)
 from rpython.flowspace.generator import (tweak_generator_graph,
         make_generator_entry_graph)
@@ -36,7 +36,7 @@
     if (isgeneratorfunction(func) and
             not hasattr(func, '_generator_next_method_of_')):
         return make_generator_entry_graph(func)
-    code = HostCode._from_code(func.func_code)
+    code = bc_reader.build_code(func.func_code)
     graph = PyGraph(func, code)
     ctx = FlowContext(graph, code)
     ctx.build_flow()
diff --git a/rpython/flowspace/test/test_framestate.py b/rpython/flowspace/test/test_framestate.py
--- a/rpython/flowspace/test/test_framestate.py
+++ b/rpython/flowspace/test/test_framestate.py
@@ -1,7 +1,7 @@
-from rpython.flowspace.model import *
+from rpython.flowspace.model import Constant, Variable
 from rpython.rlib.unroll import SpecTag
 from rpython.flowspace.flowcontext import FlowContext
-from rpython.flowspace.bytecode import HostCode
+from rpython.flowspace.bytecode import bc_reader
 from rpython.flowspace.pygraph import PyGraph
 
 class TestFrameState:
@@ -10,7 +10,7 @@
             func = func.im_func
         except AttributeError:
             pass
-        code = HostCode._from_code(func.func_code)
+        code = bc_reader.build_code(func.func_code)
         graph = PyGraph(func, code)
         ctx = FlowContext(graph, code)
         # hack the frame


More information about the pypy-commit mailing list