[pypy-svn] r48890 - in pypy/dist/pypy: rpython rpython/lltypesystem rpython/ootypesystem translator

antocuni at codespeak.net antocuni at codespeak.net
Wed Nov 21 11:50:18 CET 2007


Author: antocuni
Date: Wed Nov 21 11:50:17 2007
New Revision: 48890

Modified:
   pypy/dist/pypy/rpython/exceptiondata.py
   pypy/dist/pypy/rpython/lltypesystem/exceptiondata.py
   pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py
   pypy/dist/pypy/translator/exceptiontransform.py
Log:
fix exceptiontransformer to work with ootype



Modified: pypy/dist/pypy/rpython/exceptiondata.py
==============================================================================
--- pypy/dist/pypy/rpython/exceptiondata.py	(original)
+++ pypy/dist/pypy/rpython/exceptiondata.py	Wed Nov 21 11:50:17 2007
@@ -36,3 +36,9 @@
         helper_fn = rtyper.annotate_helper_fn(ll_raise_OSError, [annmodel.SomeInteger()])
         return helper_fn
 
+    def get_standard_ll_exc_instance(self, rtyper, clsdef):
+        rclass = rtyper.type_system.rclass
+        r_inst = rclass.getinstancerepr(rtyper, clsdef)
+        example = r_inst.get_reusable_prebuilt_instance()
+        example = self.cast_exception(self.lltype_of_exception_value, example)
+        return example

Modified: pypy/dist/pypy/rpython/lltypesystem/exceptiondata.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/exceptiondata.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/exceptiondata.py	Wed Nov 21 11:50:17 2007
@@ -105,8 +105,5 @@
         helper_fn = rtyper.annotate_helper_fn(ll_pyexcclass2exc, [s_pyobj])
         return helper_fn
 
-    def get_standard_ll_exc_instance(self, rtyper, clsdef):
-        r_inst = rclass.getinstancerepr(rtyper, clsdef)
-        example = r_inst.get_reusable_prebuilt_instance()
-        example = rclass.ll_cast_to_object(example)
-        return example
+    def cast_exception(self, TYPE, value):
+        return rclass.ll_cast_to_object(value)

Modified: pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/exceptiondata.py	Wed Nov 21 11:50:17 2007
@@ -56,9 +56,7 @@
                     is_standard = (cls.__module__ == 'exceptions'
                                    and not clsdef.attrs)
                 if is_standard:
-                    r_inst = rclass.getinstancerepr(rtyper, clsdef)
-                    example = r_inst.get_reusable_prebuilt_instance()
-                    example = ootype.ooupcast(self.lltype_of_exception_value, example)
+                    example = self.get_standard_ll_exc_instance(rtyper, clsdef)
                     table[cls] = example
         r_inst = rclass.getinstancerepr(rtyper, None)
         r_inst.setup()
@@ -99,3 +97,6 @@
                 self._TYPE = FakeCallableType
                 self._callable = fn
         return fake_callable(pyexcclass2exc)
+
+    def cast_exception(self, TYPE, value):
+        return ootype.ooupcast(TYPE, value)

Modified: pypy/dist/pypy/translator/exceptiontransform.py
==============================================================================
--- pypy/dist/pypy/translator/exceptiontransform.py	(original)
+++ pypy/dist/pypy/translator/exceptiontransform.py	Wed Nov 21 11:50:17 2007
@@ -55,9 +55,10 @@
         self.mixlevelannotator  = MixLevelHelperAnnotator(translator.rtyper)
         exc_data, null_type, null_value = self.setup_excdata()
 
+        rclass = translator.rtyper.type_system.rclass
         runtime_error_def = translator.annotator.bookkeeper.getuniqueclassdef(RuntimeError)
         runtime_error_ll_exc = edata.get_standard_ll_exc_instance(translator.rtyper, runtime_error_def)
-        runtime_error_ll_exc_type = runtime_error_ll_exc.typeptr
+        runtime_error_ll_exc_type = rclass.ll_inst_type(runtime_error_ll_exc)
 
         def rpyexc_occured():
             exc_type = exc_data.exc_type



More information about the Pypy-commit mailing list