[pypy-svn] r22788 - in pypy/branch/genc-gc-refactoring: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Sat Jan 28 15:09:35 CET 2006


Author: cfbolz
Date: Sat Jan 28 15:09:32 2006
New Revision: 22788

Modified:
   pypy/branch/genc-gc-refactoring/database.py
   pypy/branch/genc-gc-refactoring/funcgen.py
   pypy/branch/genc-gc-refactoring/gc.py
   pypy/branch/genc-gc-refactoring/test/test_newgc.py
Log:
(mwh, cfbolz):
attach the transformer to the gcpolicy, make funcgen call transformer on all
graphs


Modified: pypy/branch/genc-gc-refactoring/database.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/database.py	(original)
+++ pypy/branch/genc-gc-refactoring/database.py	Sat Jan 28 15:09:32 2006
@@ -14,7 +14,7 @@
 
 # ____________________________________________________________
 
-class LowLevelDatabase:
+class LowLevelDatabase(object):
 
     def __init__(self, translator=None, standalone=False, gcpolicy=None, thread_enabled=False):
         self.translator = translator
@@ -34,6 +34,7 @@
             from pypy.translator.c import gc
             gcpolicy = gc.RefcountingGcPolicy
         self.gcpolicy = gcpolicy(self, thread_enabled)
+        self.gctransformer = gcpolicy.transformerclass()
         self.completed = False
 
     def gettypedefnode(self, T, varlength=1):

Modified: pypy/branch/genc-gc-refactoring/funcgen.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/funcgen.py	(original)
+++ pypy/branch/genc-gc-refactoring/funcgen.py	Sat Jan 28 15:09:32 2006
@@ -32,6 +32,9 @@
         self.gcpolicy = db.gcpolicy
         self.cpython_exc = cpython_exc
         self.functionname = functionname
+        # apply the gc transformation
+        self.db.gctransformer.transform_graph(self.graph)
+        
         #
         # collect all variables and constants used in the body,
         # and get their types now
@@ -165,7 +168,6 @@
             if line:
                 yield line
 
-
         # collect all blocks
         for block in graph.iterblocks():
             allblocks.append(block)

Modified: pypy/branch/genc-gc-refactoring/gc.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/gc.py	(original)
+++ pypy/branch/genc-gc-refactoring/gc.py	Sat Jan 28 15:09:32 2006
@@ -4,6 +4,7 @@
 from pypy.rpython.lltypesystem.lltype import \
      typeOf, Ptr, PyObject, ContainerType, GcArray, GcStruct, \
      RuntimeTypeInfo, getRuntimeTypeInfo
+from pypy.rpython.memory import gctransform
 
 PyObjPtr = Ptr(PyObject)
 
@@ -87,6 +88,7 @@
     destructor = None
 
 class RefcountingGcPolicy(BasicGcPolicy):
+    transformerclass = gctransform.GCTransformer
 
     def push_alive_nopyobj(self, expr, T):
         defnode = self.db.gettypedefnode(T.TO)

Modified: pypy/branch/genc-gc-refactoring/test/test_newgc.py
==============================================================================
--- pypy/branch/genc-gc-refactoring/test/test_newgc.py	(original)
+++ pypy/branch/genc-gc-refactoring/test/test_newgc.py	Sat Jan 28 15:09:32 2006
@@ -14,15 +14,12 @@
     t = TranslationContext()
     t.buildannotator().build_types(fn, inputtypes)
     t.buildrtyper().specialize()
-    GCTransformer(t.graphs).transform()
-    
     builder = genc.CExtModuleBuilder(t, fn, gcpolicy=gc.RefcountingGcPolicy)
     builder.generate_source()
     skip_missing_compiler(builder.compile)
     builder.import_module()
     return builder.get_entry_point()
 
-
 def test_something():
     def f():
         return 1



More information about the Pypy-commit mailing list