[pypy-commit] pypy dynamic-specialized-tuple: return offsets as well

fijal noreply at buildbot.pypy.org
Mon Apr 23 18:31:43 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: dynamic-specialized-tuple
Changeset: r54686:32c12242fbb2
Date: 2012-04-23 18:31 +0200
http://bitbucket.org/pypy/pypy/changeset/32c12242fbb2/

Log:	return offsets as well

diff --git a/pypy/rlib/rerased_raw.py b/pypy/rlib/rerased_raw.py
--- a/pypy/rlib/rerased_raw.py
+++ b/pypy/rlib/rerased_raw.py
@@ -24,6 +24,9 @@
 STRING = "s"
 UNICODE = "u"
 
+# all the same size for now
+WORD = rffi.sizeof(llmemory.Address)
+
 class UntypedStorage(object):
     def __init__(self, shape):
         self.storage = [None] * len(shape)
@@ -304,12 +307,12 @@
 def ll_enumerate_elements(storage):
     for i, elem in enumerate(storage.shape.chars):
         if elem in [INSTANCE, STRING, UNICODE]:
-            yield storage.data.items[i].ptr
+            yield WORD * i, storage.data.items[i].ptr
         elif elem == INT:
-            yield rffi.cast(lltype.Signed, storage.data.items[i])
+            yield WORD * i, rffi.cast(lltype.Signed, storage.data.items[i])
         elif elem == FLOAT:
-            yield longlong2float.longlong2float(rffi.cast(lltype.Signed, storage.data.items[i]))
+            yield WORD * i, longlong2float.longlong2float(rffi.cast(lltype.Signed, storage.data.items[i]))
         elif elem == BOOL:
-            yield rffi.cast(lltype.Bool, storage.data.items[i])
+            yield WORD * i, rffi.cast(lltype.Bool, storage.data.items[i])
         else:
             assert False
diff --git a/pypy/rlib/test/test_rerased_raw.py b/pypy/rlib/test/test_rerased_raw.py
--- a/pypy/rlib/test/test_rerased_raw.py
+++ b/pypy/rlib/test/test_rerased_raw.py
@@ -195,8 +195,10 @@
 
         llres = self.interpret(f, [])._obj
         lst = list(rerased_raw.ll_enumerate_elements(llres))
-        assert hlstr(lst[0]) == "abc"
-        assert lst[1:] == [13, True, 3.5]
+        assert hlstr(lst[0][1]) == "abc"
+        assert lst[0][0] == 0
+        WORD = rerased_raw.WORD
+        assert lst[1:] == [(WORD, 13), (WORD * 2, True), (WORD * 3, 3.5)]
 
 class TestUntypedStorageLLtype(LLRtypeMixin, BaseTestUntypedStorage):
     pass


More information about the pypy-commit mailing list