[pypy-svn] r22925 - in pypy/dist/pypy/rpython/memory: . test

mwh at codespeak.net mwh at codespeak.net
Wed Feb 1 17:33:16 CET 2006


Author: mwh
Date: Wed Feb  1 17:33:15 2006
New Revision: 22925

Modified:
   pypy/dist/pypy/rpython/memory/gctransform.py
   pypy/dist/pypy/rpython/memory/test/test_gctransform.py
Log:
explicitly fail to support structs with destructors


Modified: pypy/dist/pypy/rpython/memory/gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/gctransform.py	(original)
+++ pypy/dist/pypy/rpython/memory/gctransform.py	Wed Feb  1 17:33:15 2006
@@ -216,6 +216,20 @@
         destroy.compute_ll_ops = compute_destroy_ll_ops
         destroy.llresult = lltype.Void
 
+        destrptr = None
+        
+        if isinstance(TYPE, lltype.Struct):
+            rtti = None
+            try:
+                rtti = lltype.getRuntimeTypeInfo(TYPE)
+            except ValueError:
+                pass
+            if rtti is not None:
+                if hasattr(rtti._obj, 'destructor_funcptr'):
+                    destrptr = rtti._obj.destructor_funcptr
+
+        assert destrptr is None
+
         body = '\n'.join(self._deallocator_body_for_type('v', TYPE))
         
         src = 'def deallocator(v):\n' + body + '\n    destroy(v)\n'

Modified: pypy/dist/pypy/rpython/memory/test/test_gctransform.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_gctransform.py	(original)
+++ pypy/dist/pypy/rpython/memory/test/test_gctransform.py	Wed Feb  1 17:33:15 2006
@@ -4,6 +4,7 @@
 from pypy.translator.translator import TranslationContext, graphof
 from pypy.rpython.lltypesystem import lltype
 from pypy.objspace.flow.model import Variable
+import py
 
 def checkblock(block):
     if block.operations == ():
@@ -285,3 +286,20 @@
     assert len(ops['gc_pop_alive']) == 2
     assert len(ops['getfield']) == 2
     assert len(ops['gc_free']) == 1
+
+def test_deallocator_with_destructor():
+    S = lltype.GcStruct("S", ('x', lltype.Signed))
+    def f(s):
+        s.x = 1
+    def type_info_S(p):
+        return lltype.getRuntimeTypeInfo(S)
+    qp = lltype.functionptr(lltype.FuncType([lltype.Ptr(S)],
+                                            lltype.Ptr(lltype.RuntimeTypeInfo)),
+                            "type_info_S", 
+                            _callable=type_info_S)
+    dp = lltype.functionptr(lltype.FuncType([lltype.Ptr(S)],
+                                            lltype.Void), 
+                            "destructor_funcptr", 
+                            _callable=f)
+    pinf = lltype.attachRuntimeTypeInfo(S, qp, destrptr=dp)
+    py.test.raises(AssertionError, "make_deallocator(S)")



More information about the Pypy-commit mailing list