[pypy-svn] r23142 - pypy/branch/genc-gc-refactoring
mwh at codespeak.net
mwh at codespeak.net
Wed Feb 8 13:22:48 CET 2006
Author: mwh
Date: Wed Feb 8 13:22:46 2006
New Revision: 23142
Modified:
pypy/branch/genc-gc-refactoring/gc.py
pypy/branch/genc-gc-refactoring/node.py
Log:
supply the gcheader in a lltype-y way, not a string-y way.
Modified: pypy/branch/genc-gc-refactoring/gc.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/gc.py (original)
+++ pypy/branch/genc-gc-refactoring/gc.py Wed Feb 8 13:22:46 2006
@@ -57,8 +57,7 @@
transformerclass = gctransform.RefcountingGCTransformer
def common_gcheader_definition(self, defnode):
-# return ('refcount', lltype.Signed)
- return 'long refcount;'
+ return [('refcount', lltype.Signed)]
def common_after_definition(self, defnode):
return ''
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 13:22:46 2006
@@ -67,6 +67,9 @@
else:
typename = db.gettype(T, who_asks=self)
self.fields.append((self.c_struct_field_name(name), typename))
+ if needs_gcheader(self.STRUCT):
+ for fname, T in db.gcpolicy.struct_gcheader_definition(self):
+ self.fields.insert(0, (fname, db.gettype(T, who_asks=self)))
self.gcinfo # force it to be computed
def computegcinfo(self):
@@ -95,15 +98,8 @@
return '%s.%s' % (baseexpr, fldname)
def definition(self):
- gcpolicy = self.db.gcpolicy
yield 'struct %s {' % self.name
- # gcheader
is_empty = True
- if needs_gcheader(self.STRUCT):
- line = gcpolicy.struct_gcheader_definition(self)
- if line:
- yield '\t' + line
- is_empty = False
for name, typename in self.fields:
line = '%s;' % cdecl(typename, name)
@@ -116,7 +112,7 @@
yield '\t' + 'int _dummy; /* this struct is empty */'
yield '};'
- for line in gcpolicy.struct_after_definition(self):
+ for line in self.db.gcpolicy.struct_after_definition(self):
yield line
def visitor_lines(self, prefix, on_field):
@@ -184,9 +180,8 @@
yield 'struct %s {' % self.name
# gcheader
if needs_gcheader(self.ARRAY):
- line = gcpolicy.array_gcheader_definition(self)
- if line:
- yield '\t' + line
+ for fname, T in gcpolicy.array_gcheader_definition(self):
+ yield '\t' + cdecl(self.db.gettype(T, who_asks=self), 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