[pypy-commit] pypy faster-nested-scopes: fix flow space. needs a slightly annoying hack
cfbolz
noreply at buildbot.pypy.org
Sat Jul 16 11:40:23 CEST 2011
Author: Carl Friedrich Bolz <cfbolz at gmx.de>
Branch: faster-nested-scopes
Changeset: r45658:c6b24da7b2b9
Date: 2011-07-16 11:33 +0200
http://bitbucket.org/pypy/pypy/changeset/c6b24da7b2b9/
Log: fix flow space. needs a slightly annoying hack
diff --git a/pypy/objspace/flow/flowcontext.py b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -184,7 +184,7 @@
class FlowExecutionContext(ExecutionContext):
- def __init__(self, space, code, globals, constargs={}, closure=None,
+ def __init__(self, space, code, globals, constargs={}, outer_func=None,
name=None):
ExecutionContext.__init__(self, space)
self.code = code
@@ -193,11 +193,11 @@
self.crnt_offset = -1
self.crnt_frame = None
- if closure is None:
+ if outer_func and outer_func.closure:
+ self.closure = [nestedscope.Cell(Constant(value))
+ for value in outer_func.closure]
+ else:
self.closure = None
- else:
- self.closure = [nestedscope.Cell(Constant(value))
- for value in closure]
frame = self.create_frame()
formalargcount = code.getformalargcount()
arg_list = [Variable() for i in range(formalargcount)]
@@ -216,7 +216,7 @@
# while ignoring any operation like the creation of the locals dict
self.recorder = []
frame = FlowSpaceFrame(self.space, self.code,
- self.w_globals, self.closure)
+ self.w_globals, self)
frame.last_instr = 0
return frame
diff --git a/pypy/objspace/flow/objspace.py b/pypy/objspace/flow/objspace.py
--- a/pypy/objspace/flow/objspace.py
+++ b/pypy/objspace/flow/objspace.py
@@ -252,9 +252,9 @@
raise TypeError("%r is a generator" % (func,))
code = PyCode._from_code(self, code)
if func.func_closure is None:
- closure = None
+ cl = None
else:
- closure = [extract_cell_content(c) for c in func.func_closure]
+ cl = [extract_cell_content(c) for c in func.func_closure]
# CallableFactory.pycall may add class_ to functions that are methods
name = func.func_name
class_ = getattr(func, 'class_', None)
@@ -262,8 +262,10 @@
name = '%s.%s' % (class_.__name__, name)
for c in "<>&!":
name = name.replace(c, '_')
+ class outerfunc: # hack
+ closure = cl
ec = flowcontext.FlowExecutionContext(self, code, func.func_globals,
- constargs, closure, name)
+ constargs, outerfunc, name)
graph = ec.graph
graph.func = func
# attach a signature and defaults to the graph
More information about the pypy-commit
mailing list