[pypy-svn] r54781 - in pypy/branch/oo-jit/pypy: annotation rpython/ootypesystem rpython/ootypesystem/test

antocuni at codespeak.net antocuni at codespeak.net
Fri May 16 11:14:09 CEST 2008


Author: antocuni
Date: Fri May 16 11:14:07 2008
New Revision: 54781

Modified:
   pypy/branch/oo-jit/pypy/annotation/builtin.py
   pypy/branch/oo-jit/pypy/rpython/ootypesystem/rbuiltin.py
   pypy/branch/oo-jit/pypy/rpython/ootypesystem/test/test_oortype.py
Log:
annotator&rtyper support for ooidentityhash on ootype.Object



Modified: pypy/branch/oo-jit/pypy/annotation/builtin.py
==============================================================================
--- pypy/branch/oo-jit/pypy/annotation/builtin.py	(original)
+++ pypy/branch/oo-jit/pypy/annotation/builtin.py	Fri May 16 11:14:07 2008
@@ -551,7 +551,7 @@
         return SomeOOInstance(c.ootype)
 
 def ooidentityhash(i):
-    assert isinstance(i, SomeOOInstance)
+    assert isinstance(i, (SomeOOInstance, SomeOOObject))
     return SomeInteger()
 
 def ooupcast(I, i):

Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/rbuiltin.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/rbuiltin.py	(original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/rbuiltin.py	Fri May 16 11:14:07 2008
@@ -42,7 +42,7 @@
                      resulttype = hop.r_result.lowleveltype)
 
 def rtype_ooidentityhash(hop):
-    assert isinstance(hop.args_s[0], annmodel.SomeOOInstance)
+    assert isinstance(hop.args_s[0], (annmodel.SomeOOInstance, annmodel.SomeOOObject))
     vlist = hop.inputargs(hop.args_r[0])
     return hop.genop('ooidentityhash', vlist,
                      resulttype = ootype.Signed)

Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/test/test_oortype.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/test/test_oortype.py	(original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/test/test_oortype.py	Fri May 16 11:14:07 2008
@@ -350,3 +350,16 @@
     
     res = interpret(fn, [], type_system='ootype')
     assert res == 42
+
+def test_ooidentityhash():
+    L = List(Signed)
+
+    def fn():
+        lst1 = new(L)
+        lst2 = new(L)
+        obj1 = cast_to_object(lst1)
+        obj2 = cast_to_object(lst2)
+        return ooidentityhash(obj1) == ooidentityhash(obj2)
+
+    res = interpret(fn, [], type_system='ootype')
+    assert not res



More information about the Pypy-commit mailing list