[pypy-svn] r24311 - in pypy/dist/pypy/rpython/lltypesystem: . test

pedronis at codespeak.net pedronis at codespeak.net
Mon Mar 13 17:11:27 CET 2006


Author: pedronis
Date: Mon Mar 13 17:11:25 2006
New Revision: 24311

Modified:
   pypy/dist/pypy/rpython/lltypesystem/lltype.py
   pypy/dist/pypy/rpython/lltypesystem/test/test_lltype.py
Log:
allow cast_pointer between identical array types. (It was disallowed before, now with the jit code we
are emitting much more generic code)



Modified: pypy/dist/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/lltype.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/lltype.py	Mon Mar 13 17:11:25 2006
@@ -555,6 +555,8 @@
     if CURTYPE._needsgc() != PTRTYPE._needsgc():
         raise TypeError("cast_pointer() cannot change the gc status: %s to %s"
                         % (CURTYPE, PTRTYPE))
+    if CURTYPE == PTRTYPE:
+        return 0
     if (not isinstance(CURTYPE.TO, Struct) or
         not isinstance(PTRTYPE.TO, Struct)):
         raise InvalidCast(CURTYPE, PTRTYPE)

Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_lltype.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_lltype.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_lltype.py	Mon Mar 13 17:11:25 2006
@@ -507,6 +507,12 @@
          res = cast_primitive(TGT, orig_val)
          assert typeOf(res) == TGT
          assert res == expect
+
+def test_cast_identical_array_ptr_types():
+    A = GcArray(Signed)
+    PA = Ptr(A)
+    a = malloc(A, 2)
+    assert cast_pointer(PA, a) == a
         
 def test_array_with_no_length():
     A = GcArray(Signed, hints={'nolength': True})



More information about the Pypy-commit mailing list