Commits

Maciej Fijalkowski committed 01fb6e0

more random progress

Comments (0)

Files changed (3)

pypy/rlib/rerased_raw.py

 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 WORD * i, storage.data.items[i].ptr
+            yield i, storage.data.items[i].ptr
         elif elem == INT:
-            yield WORD * i, rffi.cast(lltype.Signed, storage.data.items[i])
+            yield i, rffi.cast(lltype.Signed, storage.data.items[i])
         elif elem == FLOAT:
-            yield WORD * i, longlong2float.longlong2float(rffi.cast(lltype.Signed, storage.data.items[i]))
+            yield i, longlong2float.longlong2float(rffi.cast(lltype.Signed, storage.data.items[i]))
         elif elem == BOOL:
-            yield WORD * i, rffi.cast(lltype.Bool, storage.data.items[i])
+            yield i, rffi.cast(lltype.Bool, storage.data.items[i])
         else:
             assert False

pypy/rlib/test/test_rerased_raw.py

         lst = list(rerased_raw.ll_enumerate_elements(llres))
         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)]
+        assert lst[1:] == [(1, 13), (2, True), (3, 3.5)]
 
 class TestUntypedStorageLLtype(LLRtypeMixin, BaseTestUntypedStorage):
     pass

pypy/translator/c/node.py

 
         if T._hints.get('untyped_storage'):
             arrayfld = T._arrayfld
-            shapefld = [fld for fld in T._flds if fld != arrayfld]
             c_expr = defnode.access_expr(self.name, 'shape')
             lines = generic_initializationexpr(self.db, self.obj.shape,
                                                c_expr, decoration + 'shape')
             for line in lines:
                 yield "\t" + line
-            for i, obj in enumerate(ll_enumerate_elements(self.obj)):
-                xxx
+            arraydef = self.db.gettypedefnode(getattr(T, arrayfld))
+            for i, obj in ll_enumerate_elements(self.obj):
+                c_expr = '(void*)' + arraydef.access_expr(
+                    self.name + '.' + arrayfld, i)
+                lines = generic_initializationexpr(self.db, obj, c_expr,
+                                                   '%s[%d]' % (name, i))
+                for line in lines:
+                    yield '\t' + line
             is_empty = False
         else:
             for name, value in data:
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.