[pypy-commit] pypy annotator: Kill FlowObjSpace.call_function() and FlowObjSpace.call_method()

rlamy noreply at buildbot.pypy.org
Fri Jan 17 22:02:23 CET 2014


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: annotator
Changeset: r68747:0d9f33903c87
Date: 2014-01-17 20:21 +0000
http://bitbucket.org/pypy/pypy/changeset/0d9f33903c87/

Log:	Kill FlowObjSpace.call_function() and FlowObjSpace.call_method()

diff --git a/rpython/annotator/test/test_annrpython.py b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -14,7 +14,8 @@
 from rpython.rlib.rarithmetic import r_uint, base_int, r_longlong, r_ulonglong
 from rpython.rlib.rarithmetic import r_singlefloat
 from rpython.rlib import objectmodel
-from rpython.flowspace.objspace import build_flow, FlowingError
+from rpython.flowspace.objspace import build_flow
+from rpython.flowspace.flowcontext import FlowingError
 from rpython.flowspace.operation import op
 
 from rpython.translator.test import snippet
diff --git a/rpython/flowspace/flowcontext.py b/rpython/flowspace/flowcontext.py
--- a/rpython/flowspace/flowcontext.py
+++ b/rpython/flowspace/flowcontext.py
@@ -664,12 +664,12 @@
 
         Returns an FSException object whose w_value is an instance of w_type.
         """
-        if self.guessbool(self.space.call_function(const(isinstance), w_arg1,
-                const(type))):
+        w_is_type = op.simple_call(const(isinstance), w_arg1, const(type)).eval(self)
+        if self.guessbool(w_is_type):
             # this is for all cases of the form (Class, something)
             if self.guessbool(op.is_(w_arg2, w_None).eval(self)):
                 # raise Type: we assume we have to instantiate Type
-                w_value = self.space.call_function(w_arg1)
+                w_value = op.simple_call(w_arg1).eval(self)
             else:
                 w_valuetype = op.type(w_arg2).eval(self)
                 if self.guessbool(op.issubtype(w_valuetype, w_arg1).eval(self)):
@@ -677,7 +677,7 @@
                     w_value = w_arg2
                 else:
                     # raise Type, X: assume X is the constructor argument
-                    w_value = self.space.call_function(w_arg1, w_arg2)
+                    w_value = op.simple_call(w_arg1, w_arg2).eval(self)
         else:
             # the only case left here is (inst, None), from a 'raise inst'.
             if not self.guessbool(op.is_(w_arg2, const(None)).eval(self)):
@@ -868,7 +868,8 @@
         w_manager = self.peekvalue()
         w_exit = op.getattr(w_manager, const("__exit__")).eval(self)
         self.settopvalue(w_exit)
-        w_result = self.space.call_method(w_manager, "__enter__")
+        w_enter = op.getattr(w_manager, const('__enter__')).eval(self)
+        w_result = op.simple_call(w_enter).eval(self)
         block = WithBlock(self, target)
         self.blockstack.append(block)
         self.pushvalue(w_result)
@@ -889,10 +890,10 @@
             w_exc = unroller.w_exc
             # The annotator won't allow to merge exception types with None.
             # Replace it with the exception value...
-            self.space.call_function(w_exitfunc,
-                    w_exc.w_value, w_exc.w_value, w_None)
+            op.simple_call(w_exitfunc, w_exc.w_value, w_exc.w_value, w_None
+                           ).eval(self)
         else:
-            self.space.call_function(w_exitfunc, w_None, w_None, w_None)
+            op.simple_call(w_exitfunc, w_None, w_None, w_None).eval(self)
 
     def LOAD_FAST(self, varindex):
         w_value = self.locals_stack_w[varindex]
@@ -1138,12 +1139,13 @@
         self.deleteslice(w_start, w_end)
 
     def LIST_APPEND(self, oparg):
-        w = self.popvalue()
+        w_value = self.popvalue()
         if sys.version_info < (2, 7):
-            v = self.popvalue()
+            w_list = self.popvalue()
         else:
-            v = self.peekvalue(oparg - 1)
-        self.space.call_method(v, 'append', w)
+            w_list = self.peekvalue(oparg - 1)
+        w_append_meth = op.getattr(w_list, const('append')).eval(self)
+        op.simple_call(w_append_meth, w_value).eval(self)
 
     def DELETE_FAST(self, varindex):
         if self.locals_stack_w[varindex] is None:
diff --git a/rpython/flowspace/objspace.py b/rpython/flowspace/objspace.py
--- a/rpython/flowspace/objspace.py
+++ b/rpython/flowspace/objspace.py
@@ -4,16 +4,13 @@
 
 from inspect import CO_NEWLOCALS
 
-from rpython.flowspace.argument import CallSpec
-from rpython.flowspace.model import Constant, Variable, checkgraph, const
+from rpython.flowspace.model import Constant, Variable, checkgraph
 from rpython.flowspace.bytecode import HostCode
 from rpython.flowspace.operation import op
-from rpython.flowspace.flowcontext import (FlowSpaceFrame, fixeggblocks,
-    FlowingError, Raise)
+from rpython.flowspace.flowcontext import (FlowSpaceFrame, fixeggblocks)
 from rpython.flowspace.generator import (tweak_generator_graph,
         bootstrap_generator)
 from rpython.flowspace.pygraph import PyGraph
-from rpython.flowspace.specialcase import SPECIAL_CASES
 
 
 def _assert_rpythonic(func):
@@ -37,14 +34,6 @@
     def build_flow(self, func):
         return build_flow(func, self)
 
-    def call_method(self, w_obj, methname, *arg_w):
-        w_meth = op.getattr(w_obj, const(methname)).eval(self.frame)
-        return self.call_function(w_meth, *arg_w)
-
-    def call_function(self, w_func, *args_w):
-        args = CallSpec(list(args_w))
-        return self.call(w_func, args)
-
     def call(self, w_callable, args):
         if args.keywords or isinstance(args.w_stararg, Variable):
             shape, args_w = args.flatten()


More information about the pypy-commit mailing list