[pypy-commit] pypy framestate: Move PyGraph creation inside FlowContext.__init__
rlamy
noreply at buildbot.pypy.org
Tue Nov 25 15:47:28 CET 2014
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: framestate
Changeset: r74717:d8f08299732a
Date: 2014-11-25 06:18 +0000
http://bitbucket.org/pypy/pypy/changeset/d8f08299732a/
Log: Move PyGraph creation inside FlowContext.__init__
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -7,7 +7,6 @@
import __builtin__
from rpython.tool.error import source_lines
-from rpython.translator.simplify import eliminate_empty_blocks
from rpython.rlib import rstackovf
from rpython.flowspace.argument import CallSpec
from rpython.flowspace.model import (Constant, Variable, Block, Link,
@@ -15,9 +14,10 @@
from rpython.flowspace.framestate import FrameState
from rpython.flowspace.specialcase import (rpython_print_item,
rpython_print_newline)
-from rpython.flowspace.bytecode import BytecodeBlock
from rpython.flowspace.operation import op
-from rpython.flowspace.bytecode import BytecodeCorruption
+from rpython.flowspace.bytecode import (
+ BytecodeBlock, BytecodeCorruption, bc_reader)
+from rpython.flowspace.pygraph import PyGraph
w_None = const(None)
@@ -227,9 +227,10 @@
class FlowContext(object):
- def __init__(self, graph, code):
+ def __init__(self, func):
+ code = bc_reader.build_code(func.func_code)
+ graph = PyGraph(func, code)
self.graph = graph
- func = graph.func
self.pycode = code
self.w_globals = Constant(func.func_globals)
self.blockstack = []
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -3,12 +3,9 @@
from inspect import CO_NEWLOCALS, isgeneratorfunction
-from rpython.flowspace.model import checkgraph
-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)
-from rpython.flowspace.pygraph import PyGraph
def _assert_rpythonic(func):
@@ -36,11 +33,10 @@
if (isgeneratorfunction(func) and
not hasattr(func, '_generator_next_method_of_')):
return make_generator_entry_graph(func)
- code = bc_reader.build_code(func.func_code)
- graph = PyGraph(func, code)
- ctx = FlowContext(graph, code)
+ ctx = FlowContext(func)
ctx.build_flow()
+ graph = ctx.graph
fixeggblocks(graph)
- if code.is_generator:
+ if ctx.pycode.is_generator:
tweak_generator_graph(graph)
return graph
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
@@ -10,9 +10,9 @@
func = func.im_func
except AttributeError:
pass
- code = bc_reader.build_code(func.func_code)
- graph = PyGraph(func, code)
- ctx = FlowContext(graph, code)
+ ctx = FlowContext(func)
+ ctx.build_flow()
+ graph = ctx.graph
# hack the frame
ctx.setstate(graph.startblock.framestate)
ctx.locals_w[-1] = Constant(None)
More information about the pypy-commit
mailing list