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

arigo at codespeak.net arigo at codespeak.net
Wed Apr 12 20:21:10 CEST 2006


Author: arigo
Date: Wed Apr 12 20:21:09 2006
New Revision: 25734

Modified:
   pypy/dist/pypy/rpython/lltypesystem/llmemory.py
   pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py
Log:
Fix for addresses involved in FixedSizeArray-to-FixedSizeArray slicing.


Modified: pypy/dist/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/llmemory.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/llmemory.py	Wed Apr 12 20:21:09 2006
@@ -218,7 +218,8 @@
         ref = self.ref()
         if (isinstance(ref, _arrayitemref) and
             isinstance(EXPECTED_TYPE.TO, lltype.FixedSizeArray) and
-            isinstance(lltype.typeOf(ref.array).TO, lltype.Array)):
+            isinstance(lltype.typeOf(ref.array).TO, (lltype.FixedSizeArray,
+                                                     lltype.Array))):
             # special case that requires cast_subarray_pointer
             return lltype.cast_subarray_pointer(EXPECTED_TYPE,
                                                 ref.array,

Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_llmemory.py	Wed Apr 12 20:21:09 2006
@@ -162,13 +162,14 @@
     assert adr1 == adr2
 
 def test_cast_subarray_pointer():
-    A = lltype.GcArray(lltype.Signed)
-    a = lltype.malloc(A, 5)
-    a[3] = 132
-
-    SUBARRAY = lltype.FixedSizeArray(lltype.Signed, 1)
-    adr = cast_ptr_to_adr(a) + itemoffsetof(A, 3)
-    subarray = cast_adr_to_ptr(adr, lltype.Ptr(SUBARRAY))
-    assert subarray[0] == 132
-    subarray[0] += 2
-    assert a[3] == 134
+    for a in [lltype.malloc(lltype.GcArray(lltype.Signed), 5),
+              lltype.malloc(lltype.FixedSizeArray(lltype.Signed, 5),
+                            immortal=True)]:
+        A = lltype.typeOf(a).TO
+        SUBARRAY = lltype.FixedSizeArray(lltype.Signed, 1)
+        a[3] = 132
+        adr = cast_ptr_to_adr(a) + itemoffsetof(A, 3)
+        subarray = cast_adr_to_ptr(adr, lltype.Ptr(SUBARRAY))
+        assert subarray[0] == 132
+        subarray[0] += 2
+        assert a[3] == 134



More information about the Pypy-commit mailing list