1. Pypy
  2. Untitled project
  3. pypy

Commits

Maciej Fijalkowski  committed 32c1224

return offsets as well

  • Participants
  • Parent commits b0aa1fc
  • Branches dynamic-specialized-tuple

Comments (0)

Files changed (2)

File pypy/rlib/rerased_raw.py

View file
  • Ignore whitespace
 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)
 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

File pypy/rlib/test/test_rerased_raw.py

View file
  • Ignore whitespace
 
         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