[pypy-svn] r77064 - in pypy/branch/better-map-instances/pypy/rlib: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Tue Sep 14 15:57:39 CEST 2010


Author: cfbolz
Date: Tue Sep 14 15:57:38 2010
New Revision: 77064

Modified:
   pypy/branch/better-map-instances/pypy/rlib/rerased.py
   pypy/branch/better-map-instances/pypy/rlib/test/test_rerased.py
Log:
Switch to using GCREF instead of OBJECTPTR, to also support lists and strings
soon.


Modified: pypy/branch/better-map-instances/pypy/rlib/rerased.py
==============================================================================
--- pypy/branch/better-map-instances/pypy/rlib/rerased.py	(original)
+++ pypy/branch/better-map-instances/pypy/rlib/rerased.py	Tue Sep 14 15:57:38 2010
@@ -10,7 +10,7 @@
 from pypy.rpython.rmodel import Repr
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rpython.lltypesystem.rclass import OBJECTPTR
-from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.error import TyperError
 
 
@@ -72,7 +72,7 @@
             c_one = hop.inputconst(lltype.Signed, 1)
             vi = hop.genop('cast_ptr_to_int', [v], resulttype=lltype.Signed)
             return hop.genop('int_rshift', [vi, c_one], resulttype=lltype.Signed)
-        return hop.genop('cast_pointer', [v], resulttype = hop.r_result)
+        return hop.genop('cast_opaque_ptr', [v], resulttype = hop.r_result)
 
 class Entry(ExtRegistryEntry):
     _about_ = is_integer
@@ -119,7 +119,7 @@
 
 
 class ErasedRepr(Repr):
-    lowleveltype = OBJECTPTR
+    lowleveltype = llmemory.GCREF
     def __init__(self, rtyper):
         self.rtyper = rtyper
 
@@ -129,7 +129,9 @@
         if (isinstance(s_arg, annmodel.SomeInstance) or
                 (s_arg.is_constant() and s_arg.const is None)):
             hop.exception_cannot_occur()
-            [v] = hop.inputargs(r_generic_object)   # might generate a cast_pointer
+            [v_instance] = hop.inputargs(r_generic_object)   # might generate a cast_pointer
+            v = hop.genop('cast_opaque_ptr', [v_instance],
+                          resulttype=self.lowleveltype)
             return v
         else:
             assert isinstance(s_arg, annmodel.SomeInteger)
@@ -140,9 +142,11 @@
                            resulttype = lltype.Signed)
             v2p1 = hop.genop('int_add', [v2, c_one],
                              resulttype = lltype.Signed)
-            v_instance =  hop.genop('cast_int_to_ptr', [v2p1],
-                                    resulttype = self.lowleveltype)
-            return v_instance
+            v_instance = hop.genop('cast_int_to_ptr', [v2p1],
+                                   resulttype=self.lowleveltype)
+            v = hop.genop('cast_opaque_ptr', [v_instance],
+                          resulttype=self.lowleveltype)
+            return v
 
 
     def convert_const(self, value):
@@ -151,5 +155,5 @@
         else:
             r_generic_object = getinstancerepr(self.rtyper, None)
             v = r_generic_object.convert_const(value._x)
-            return v
+            return lltype.cast_opaque_ptr(self.lowleveltype, v)
 

Modified: pypy/branch/better-map-instances/pypy/rlib/test/test_rerased.py
==============================================================================
--- pypy/branch/better-map-instances/pypy/rlib/test/test_rerased.py	(original)
+++ pypy/branch/better-map-instances/pypy/rlib/test/test_rerased.py	Tue Sep 14 15:57:38 2010
@@ -5,7 +5,7 @@
 from pypy.annotation.annrpython import RPythonAnnotator
 from pypy.rpython.test.test_llinterp import interpret
 from pypy.rpython.lltypesystem.rclass import OBJECTPTR
-from pypy.rpython.lltypesystem import lltype
+from pypy.rpython.lltypesystem import lltype, llmemory
 
 
 class X(object):
@@ -70,7 +70,7 @@
     def f():
         return erase(X())
     x = interpret(f, [])
-    assert lltype.typeOf(x) == OBJECTPTR
+    assert lltype.typeOf(x) == llmemory.GCREF
 
 def test_rtype_2():
     def f():



More information about the Pypy-commit mailing list