[pypy-svn] r14111 - pypy/dist/pypy/rpython

ericvrp at codespeak.net ericvrp at codespeak.net
Sat Jul 2 20:26:42 CEST 2005


Author: ericvrp
Date: Sat Jul  2 20:26:41 2005
New Revision: 14111

Modified:
   pypy/dist/pypy/rpython/lltype.py
Log:
Added helper function to get rid of Voids in struct (for llvm2 now)
note: no testcase for this yet!


Modified: pypy/dist/pypy/rpython/lltype.py
==============================================================================
--- pypy/dist/pypy/rpython/lltype.py	(original)
+++ pypy/dist/pypy/rpython/lltype.py	Sat Jul  2 20:26:41 2005
@@ -4,6 +4,8 @@
 from pypy.tool.uid import Hashable
 from pypy.tool.tls import tlsobject
 
+log = py.log.Producer('lltype')
+
 TLS = tlsobject()
 
 def saferecursive(func, defl):
@@ -141,6 +143,30 @@
             raise AttributeError, 'struct %s has no field %r' % (self._name,
                                                                  name)
 
+
+
+
+    def _names_without_voids(self, at_root=True):
+        if at_root:  #XXX debug stuff
+            log('_names_without_voids: ' + self._str_without_voids())
+        names_without_voids = [name for name in self._names if self._flds[name] is not Void]
+        if names_without_voids != list(self._names):
+            log('_names_without_voids: removed Void(s) _names=%s, return=%s' % (str(list(self._names)), str(names_without_voids)))
+        #return self._names
+        return names_without_voids
+    
+    def _str_fields_without_voids(self):
+        return ', '.join(['%s: %s' % (name, self._flds[name])
+                          for name in self._names_without_voids(False)])
+    _str_fields_without_voids = saferecursive(_str_fields_without_voids, '...')
+
+    def _str_without_voids(self):
+        return "%s %s { %s }" % (self.__class__.__name__,
+                                 self._name, self._str_fields_without_voids())
+
+
+
+
     def _str_fields(self):
         return ', '.join(['%s: %s' % (name, self._flds[name])
                           for name in self._names])



More information about the Pypy-commit mailing list