Ronan Lamy committed a3a0e4f

Kill FlowObjSpace. Finally!

  • Participants
  • Parent commits 082ef34
  • Branches annotator

Comments (0)

Files changed (7)

File rpython/flowspace/

 class FlowSpaceFrame(object):
     opcode_method_names = host_bytecode_spec.method_names
-    def __init__(self, space, graph, code):
+    def __init__(self, graph, code):
         self.graph = graph
         func = graph.func
         self.pycode = code
- = space
         self.w_globals = Constant(func.func_globals)
         self.blockstack = []

File rpython/flowspace/

 from inspect import CO_NEWLOCALS
-from rpython.flowspace.model import Constant, Variable, checkgraph
+from rpython.flowspace.model import Variable, checkgraph
 from rpython.flowspace.bytecode import HostCode
-from rpython.flowspace.operation import op
 from rpython.flowspace.flowcontext import (FlowSpaceFrame, fixeggblocks)
 from rpython.flowspace.generator import (tweak_generator_graph,
                 "the flag CO_NEWLOCALS set.")
-# ______________________________________________________________________
-class FlowObjSpace(object):
-    """NOT_RPYTHON.
-    The flow objspace space is used to produce a flow graph by recording
-    the space operations that the interpreter generates when it interprets
-    (the bytecode of) some function.
-    """
-    def build_flow(self, func):
-        return build_flow(func, self)
-def build_flow(func, space=FlowObjSpace()):
+def build_flow(func):
     Create the flow graph for the function.
         return bootstrap_generator(graph)
     graph = PyGraph(func, code)
-    frame = space.frame = FlowSpaceFrame(space, graph, code)
+    frame = FlowSpaceFrame(graph, code)

File rpython/flowspace/

     def make_sc(cls):
-        def sc_operator(space, *args_w):
-            return cls(*args_w).eval(space.frame)
+        def sc_operator(frame, *args_w):
+            return cls(*args_w).eval(frame)
         return sc_operator
     def eval(self, frame):
             except (KeyError, TypeError):
-                return sc(, *args_w)
+                return sc(frame, *args_w)
         return frame.do_op(self)
             except (KeyError, TypeError):
+                from rpython.flowspace.flowcontext import FlowingError
                 raise FlowingError(
                     "should not call %r with keyword arguments" % (fn,))
         return frame.do_op(self)

File rpython/flowspace/

     """Decorator triggering special-case handling of ``func``.
     When the flow graph builder sees ``func``, it calls the decorated function
-    with ``decorated_func(space, *args_w)``, where ``args_w`` is a sequence of
+    with ``decorated_func(frame, *args_w)``, where ``args_w`` is a sequence of
     flow objects (Constants or Variables).
     def decorate(sc_func):
     return decorate
-def sc_import(space, *args_w):
-    assert len(args_w) > 0 and len(args_w) <= 5, 'import needs 1 to 5 arguments'
+def sc_import(frame, *args_w):
     assert all(isinstance(arg, Constant) for arg in args_w)
     args = [arg.value for arg in args_w]
-    return space.frame.import_name(*args)
+    return frame.import_name(*args)
 def sc_locals(_, *args):
         "own project.")
-def sc_isinstance(space, w_instance, w_type):
+def sc_isinstance(frame, w_instance, w_type):
     if w_instance.foldable() and w_type.foldable():
         return const(isinstance(w_instance.value, w_type.value))
-    return space.frame.appcall(isinstance, w_instance, w_type)
+    return frame.appcall(isinstance, w_instance, w_type)
-def sc_getattr(space, w_obj, w_index, w_default=None):
+def sc_getattr(frame, w_obj, w_index, w_default=None):
     if w_default is not None:
-        return space.frame.appcall(getattr, w_obj, w_index, w_default)
+        return frame.appcall(getattr, w_obj, w_index, w_default)
         from rpython.flowspace.operation import op
-        return op.getattr(w_obj, w_index).eval(space.frame)
+        return op.getattr(w_obj, w_index).eval(frame)
-def sc_open(space, *args_w):
+def sc_open(frame, *args_w):
     from rpython.rlib.rfile import create_file
-    return space.frame.appcall(create_file, *args_w)
+    return frame.appcall(create_file, *args_w)
-def sc_os_tmpfile(space):
+def sc_os_tmpfile(frame):
     from rpython.rlib.rfile import create_temp_rfile
-    return space.frame.appcall(create_temp_rfile)
+    return frame.appcall(create_temp_rfile)
-def sc_os_remove(space, *args_w):
+def sc_os_remove(frame, *args_w):
     # on top of PyPy only: 'os.remove != os.unlink'
     # (on CPython they are '==', but not identical either)
-    return space.frame.appcall(os.unlink, *args_w)
+    return frame.appcall(os.unlink, *args_w)
 # _________________________________________________________________________
 # a simplified version of the basic printing routines, for RPython programs

File rpython/flowspace/test/

 from rpython.flowspace.model import *
 from rpython.rlib.unroll import SpecTag
-from rpython.flowspace.objspace import FlowObjSpace
 from rpython.flowspace.flowcontext import FlowSpaceFrame
 from rpython.flowspace.bytecode import HostCode
 from rpython.flowspace.pygraph import PyGraph
         code = HostCode._from_code(func.func_code)
         graph = PyGraph(func, code)
-        frame = FlowSpaceFrame(FlowObjSpace(), graph, code)
+        frame = FlowSpaceFrame(graph, code)
         # hack the frame
         frame.locals_stack_w[frame.pycode.co_nlocals-1] = Constant(None)

File rpython/rlib/

     return False
-def sc_we_are_translated(space):
+def sc_we_are_translated(frame):
     return Constant(True)
 class r_ordereddict(r_dict):
     def _newdict(self):
         from collections import OrderedDict
         return OrderedDict()
 class _r_dictkey(object):

File rpython/rlib/

 r_uint = build_int('r_uint', False, LONG_BIT)
-def sc_r_uint(space, w_value):
+def sc_r_uint(frame, w_value):
     # (normally, the 32-bit constant is a long, and is not allowed to
     # show up in the flow graphs at all)
     if isinstance(w_value, Constant):
         return Constant(r_uint(w_value.value))
-    return space.frame.appcall(r_uint, w_value)
+    return frame.appcall(r_uint, w_value)
 r_longlong = build_int('r_longlong', True, 64)