[pypy-svn] r5334 - in pypy/trunk/src/pypy: interpreter interpreter/test objspace objspace/flow/test

arigo at codespeak.net arigo at codespeak.net
Fri Jun 25 22:17:21 CEST 2004


Author: arigo
Date: Fri Jun 25 22:17:20 2004
New Revision: 5334

Modified:
   pypy/trunk/src/pypy/interpreter/function.py
   pypy/trunk/src/pypy/interpreter/gateway.py
   pypy/trunk/src/pypy/interpreter/test/test_function.py
   pypy/trunk/src/pypy/objspace/flow/test/test_objspace.py
   pypy/trunk/src/pypy/objspace/trivial.py
Log:
Replaced the gateway's direct call to the Function with space.call_function().  
Now FlowObjSpace works on code using app-level helpers!  Each one shows up in
the flow graph as a function call.


Modified: pypy/trunk/src/pypy/interpreter/function.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/function.py	(original)
+++ pypy/trunk/src/pypy/interpreter/function.py	Fri Jun 25 22:17:20 2004
@@ -32,9 +32,6 @@
         frame.setfastscope(scope_w)
         return frame.run()
 
-    def interplevel_call(self, *args_w):
-        return self.call_args(Arguments(self.space, list(args_w)))
-
     def getdict(self):
         return self.w_func_dict
 
@@ -104,9 +101,6 @@
                                      self.space.wrap(msg))
         return self.space.call_args(self.w_function, args)
 
-    def interplevel_call(self, *args_w):
-        return self.call_args(Arguments(self.space, list(args_w)))
-
     def descr_method_call(self, __args__):
         return self.call_args(__args__)
 

Modified: pypy/trunk/src/pypy/interpreter/gateway.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/gateway.py	(original)
+++ pypy/trunk/src/pypy/interpreter/gateway.py	Fri Jun 25 22:17:20 2004
@@ -207,14 +207,17 @@
         # to call the Gateway as a non-method, 'space' must be explicitely
         # supplied. We build the Function object and call it.
         fn = self.get_function(space)
-        return fn.interplevel_call(*args_w)
+        return space.call_function(space.wrap(fn), *args_w)
 
     def __get__(self, obj, cls=None):
         if obj is None:
             return self
         else:
-            method = self.get_method(obj)
-            return method.interplevel_call
+            space = obj.space
+            w_method = space.wrap(self.get_method(obj))
+            def helper_method_caller(*args_w):
+                return space.call_function(w_method, *args_w)
+            return helper_method_caller
 
 class interp2app(Gateway):
     """Build a Gateway that calls 'f' at interp-level."""

Modified: pypy/trunk/src/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/test/test_function.py	(original)
+++ pypy/trunk/src/pypy/interpreter/test/test_function.py	Fri Jun 25 22:17:20 2004
@@ -4,6 +4,7 @@
 import unittest
 from pypy.interpreter.function import Function, Method
 from pypy.interpreter.pycode import PyCode
+from pypy.interpreter.argument import Arguments
 
 
 class AppTestFunctionIntrospection(testit.AppTestCase):
@@ -148,16 +149,15 @@
         space = self.space
         w_meth = self.fn.descr_function_get(space.wrap(5), space.type(space.wrap(5)))
         meth = space.unwrap(w_meth)
-        w_result = meth.interplevel_call(space.wrap(42))
+        w_result = meth.call_args(Arguments(space, [space.wrap(42)]))
         self.assertEquals(space.unwrap(w_result), 42)
 
     def test_fail_call(self):
         space = self.space
         w_meth = self.fn.descr_function_get(space.wrap(5), space.type(space.wrap(5)))
         meth = space.unwrap(w_meth)
-        self.assertRaises_w(self.space.w_TypeError,
-                            meth.interplevel_call,
-                            space.wrap("spam"), space.wrap("egg"))
+        args = Arguments(space, [space.wrap("spam"), space.wrap("egg")])
+        self.assertRaises_w(self.space.w_TypeError, meth.call_args, args)
 
 if __name__ == '__main__':
     testit.main()

Modified: pypy/trunk/src/pypy/objspace/flow/test/test_objspace.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/flow/test/test_objspace.py	(original)
+++ pypy/trunk/src/pypy/objspace/flow/test/test_objspace.py	Fri Jun 25 22:17:20 2004
@@ -61,7 +61,7 @@
     def print_(i):
         print i
     
-    def dont_test_print(self):   # app-level helpers confuse replay
+    def test_print(self):
         x = self.codetest(self.print_)
         self.show(x)
 

Modified: pypy/trunk/src/pypy/objspace/trivial.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/trivial.py	(original)
+++ pypy/trunk/src/pypy/objspace/trivial.py	Fri Jun 25 22:17:20 2004
@@ -188,7 +188,8 @@
                         def stuff(w_obj, *args):
                             fn = descr.get_function(space)
                             try:
-                                return fn.interplevel_call(w_obj, *args)
+                                return space.call_function(space.wrap(fn),
+                                                           w_obj, *args)
                             except OperationError, e:
                                 if not hasattr(e.w_type, 'originalex'):
                                     raise # XXX



More information about the Pypy-commit mailing list