[pypy-svn] r53209 - in pypy/branch/jit-hotpath/pypy/rpython/ootypesystem: . test

antocuni at codespeak.net antocuni at codespeak.net
Mon Mar 31 21:05:46 CEST 2008


Author: antocuni
Date: Mon Mar 31 21:05:44 2008
New Revision: 53209

Modified:
   pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/ootype.py
   pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/test/test_ootype.py
Log:
add a way to fish the class of a method given an ootype.Meth type
(only works for BuiltinADTType so far)




Modified: pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/ootype.py	Mon Mar 31 21:05:44 2008
@@ -266,6 +266,8 @@
 
 class Meth(StaticMethod):
 
+    SELFTYPE = None
+
     def __init__(self, args, result):
         StaticMethod.__init__(self, args, result)
 
@@ -330,7 +332,9 @@
         for name, meth in self._GENERIC_METHODS.iteritems():
             args = [self._specialize_type(arg, generic_types) for arg in meth.ARGS]
             result = self._specialize_type(meth.RESULT, generic_types)
-            methods[name] = Meth(args, result)
+            METH = Meth(args, result)
+            METH.SELFTYPE = self
+            methods[name] = METH
         self._METHODS = frozendict(methods)
         self._can_raise = tuple(can_raise)
 

Modified: pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/test/test_ootype.py
==============================================================================
--- pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/test/test_ootype.py	(original)
+++ pypy/branch/jit-hotpath/pypy/rpython/ootypesystem/test/test_ootype.py	Mon Mar 31 21:05:44 2008
@@ -207,6 +207,11 @@
     c = new(C)
     assert c.foo(c) == 42
 
+def test_method_selftype():
+    LIST = List(Signed)
+    _, meth = LIST._lookup('ll_setitem_fast')
+    METH = typeOf(meth)
+    assert METH.SELFTYPE is LIST
 
 def test_explicit_name_clash():
     C = Instance("test", ROOT, {})


More information about the pypy-svn mailing list