[pypy-svn] r23145 - pypy/branch/genc-gc-refactoring

mwh at codespeak.net mwh at codespeak.net
Wed Feb 8 15:11:59 CET 2006


Author: mwh
Date: Wed Feb  8 15:11:57 2006
New Revision: 23145

Modified:
   pypy/branch/genc-gc-refactoring/node.py
Log:
compute the names and types of the gc header of arrays
in setup() not definition().


Modified: pypy/branch/genc-gc-refactoring/node.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/node.py	(original)
+++ pypy/branch/genc-gc-refactoring/node.py	Wed Feb  8 15:11:57 2006
@@ -143,6 +143,8 @@
         self.ARRAY = ARRAY
         self.LLTYPE = ARRAY
         original_varlength = varlength
+        self.gcfields = []
+        
         if ARRAY is STR.chars:
             varlength += 1   # for the NUL char terminator at the end of the string
         self.varlength = varlength
@@ -163,6 +165,9 @@
         ARRAY = self.ARRAY
         self.itemtypename = db.gettype(ARRAY.OF, who_asks=self)
         self.gcinfo    # force it to be computed
+        if needs_gcheader(ARRAY):
+            for fname, T in db.gcpolicy.array_gcheader_definition(self):
+                self.gcfields.append((fname, db.gettype(T, who_asks=self)))
 
     def computegcinfo(self):
         # let the gcpolicy do its own setup
@@ -178,10 +183,8 @@
     def definition(self):
         gcpolicy = self.db.gcpolicy
         yield 'struct %s {' % self.name
-        # gcheader
-        if needs_gcheader(self.ARRAY):
-            for fname, T in gcpolicy.array_gcheader_definition(self):
-                yield '\t' + cdecl(self.db.gettype(T, who_asks=self), fname) + ';'
+        for fname, typename in self.gcfields:
+            yield '\t' + cdecl(typename, fname) + ';'
         yield '\tlong length;'
         line = '%s;' % cdecl(self.itemtypename, 'items[%d]'% self.varlength)
         if self.ARRAY.OF is Void:    # strange



More information about the Pypy-commit mailing list