[pypy-commit] pypy dynamic-specialized-tuple: more random progress

fijal noreply at buildbot.pypy.org
Mon Apr 23 19:02:29 CEST 2012


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: dynamic-specialized-tuple
Changeset: r54688:01fb6e09fb86
Date: 2012-04-23 19:02 +0200
http://bitbucket.org/pypy/pypy/changeset/01fb6e09fb86/

Log:	more random progress

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,9 +24,6 @@
 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)
@@ -307,12 +304,12 @@
 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
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
@@ -197,8 +197,7 @@
         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
diff --git a/pypy/translator/c/node.py b/pypy/translator/c/node.py
--- a/pypy/translator/c/node.py
+++ b/pypy/translator/c/node.py
@@ -631,14 +631,19 @@
 
         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:


More information about the pypy-commit mailing list