[pypy-commit] pypy kill-typesystem: merge lltypesystem.exceptiondata into rtyper.exceptiondata

rlamy noreply at buildbot.pypy.org
Thu Aug 1 19:31:26 CEST 2013


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: kill-typesystem
Changeset: r65879:1d43382f86dd
Date: 2013-07-29 13:16 +0100
http://bitbucket.org/pypy/pypy/changeset/1d43382f86dd/

Log:	merge lltypesystem.exceptiondata into rtyper.exceptiondata

diff --git a/rpython/rtyper/exceptiondata.py b/rpython/rtyper/exceptiondata.py
--- a/rpython/rtyper/exceptiondata.py
+++ b/rpython/rtyper/exceptiondata.py
@@ -1,7 +1,8 @@
 from rpython.annotator import model as annmodel
 from rpython.rlib import rstackovf
 from rpython.rtyper import rclass
-
+from rpython.rtyper.lltypesystem.rclass import (ll_issubclass, ll_type,
+        ll_cast_to_object)
 
 # the exceptions that can be implicitely raised by some operations
 standardexceptions = {
@@ -27,7 +28,7 @@
     pass
 
 
-class AbstractExceptionData:
+class ExceptionData(object):
     """Public information for the code generators to help with exceptions."""
     standardexceptions = standardexceptions
 
@@ -75,3 +76,24 @@
         clsdef = self.rtyper.annotator.bookkeeper.getuniqueclassdef(
             exceptionclass)
         return self.get_standard_ll_exc_instance(self.rtyper, clsdef)
+
+    def make_helpers(self, rtyper):
+        # create helper functionptrs
+        self.fn_exception_match  = self.make_exception_matcher(rtyper)
+        self.fn_type_of_exc_inst = self.make_type_of_exc_inst(rtyper)
+        self.fn_raise_OSError    = self.make_raise_OSError(rtyper)
+
+    def make_exception_matcher(self, rtyper):
+        # ll_exception_matcher(real_exception_vtable, match_exception_vtable)
+        s_typeptr = annmodel.SomePtr(self.lltype_of_exception_type)
+        helper_fn = rtyper.annotate_helper_fn(ll_issubclass, [s_typeptr, s_typeptr])
+        return helper_fn
+
+    def make_type_of_exc_inst(self, rtyper):
+        # ll_type_of_exc_inst(exception_instance) -> exception_vtable
+        s_excinst = annmodel.SomePtr(self.lltype_of_exception_value)
+        helper_fn = rtyper.annotate_helper_fn(ll_type, [s_excinst])
+        return helper_fn
+
+    def cast_exception(self, TYPE, value):
+        return ll_cast_to_object(value)
diff --git a/rpython/rtyper/lltypesystem/exceptiondata.py b/rpython/rtyper/lltypesystem/exceptiondata.py
deleted file mode 100644
--- a/rpython/rtyper/lltypesystem/exceptiondata.py
+++ /dev/null
@@ -1,31 +0,0 @@
-from rpython.annotator import model as annmodel
-from rpython.rtyper.lltypesystem import rclass
-from rpython.rtyper.lltypesystem.lltype import (Array, malloc, Ptr, FuncType,
-    functionptr, Signed)
-from rpython.rtyper.exceptiondata import AbstractExceptionData
-from rpython.annotator.classdef import FORCE_ATTRIBUTES_INTO_CLASSES
-
-
-class ExceptionData(AbstractExceptionData):
-    """Public information for the code generators to help with exceptions."""
-
-    def make_helpers(self, rtyper):
-        # create helper functionptrs
-        self.fn_exception_match  = self.make_exception_matcher(rtyper)
-        self.fn_type_of_exc_inst = self.make_type_of_exc_inst(rtyper)
-        self.fn_raise_OSError    = self.make_raise_OSError(rtyper)
-
-    def make_exception_matcher(self, rtyper):
-        # ll_exception_matcher(real_exception_vtable, match_exception_vtable)
-        s_typeptr = annmodel.SomePtr(self.lltype_of_exception_type)
-        helper_fn = rtyper.annotate_helper_fn(rclass.ll_issubclass, [s_typeptr, s_typeptr])
-        return helper_fn
-
-    def make_type_of_exc_inst(self, rtyper):
-        # ll_type_of_exc_inst(exception_instance) -> exception_vtable
-        s_excinst = annmodel.SomePtr(self.lltype_of_exception_value)
-        helper_fn = rtyper.annotate_helper_fn(rclass.ll_type, [s_excinst])
-        return helper_fn
-
-    def cast_exception(self, TYPE, value):
-        return rclass.ll_cast_to_object(value)
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -20,6 +20,7 @@
 from rpython.flowspace.model import Variable, Constant, SpaceOperation, c_last_exception
 from rpython.rtyper.annlowlevel import annotate_lowlevel_helper, LowLevelAnnotatorPolicy
 from rpython.rtyper.error import TyperError
+from rpython.rtyper.exceptiondata import ExceptionData
 from rpython.rtyper.lltypesystem.lltype import (Signed, Void, LowLevelType,
     Ptr, ContainerType, FuncType, functionptr, typeOf, RuntimeTypeInfo,
     attachRuntimeTypeInfo, Primitive)
@@ -56,10 +57,7 @@
         self.typererror_count = 0
         # make the primitive_to_repr constant mapping
         self.primitive_to_repr = {}
-        if self.type_system.offers_exceptiondata:
-            self.exceptiondata = self.type_system.exceptiondata.ExceptionData(self)
-        else:
-            self.exceptiondata = None
+        self.exceptiondata = ExceptionData(self)
 
         try:
             self.seed = int(os.getenv('RTYPERSEED'))
diff --git a/rpython/rtyper/typesystem.py b/rpython/rtyper/typesystem.py
--- a/rpython/rtyper/typesystem.py
+++ b/rpython/rtyper/typesystem.py
@@ -9,8 +9,6 @@
 class TypeSystem(object):
     __metaclass__ = extendabletype
 
-    offers_exceptiondata = True
-
     def __getattr__(self, name):
         """Lazy import to avoid circular dependencies."""
         def load(modname):
@@ -21,7 +19,7 @@
                 return None
         if name in ('rclass', 'rpbc', 'rbuiltin', 'rtuple', 'rlist',
                     'rslice', 'rdict', 'rrange', 'rstr',
-                    'll_str', 'rbuilder', 'rbytearray', 'exceptiondata'):
+                    'll_str', 'rbuilder', 'rbytearray'):
             mod = load(name)
             if mod is not None:
                 setattr(self, name, mod)


More information about the pypy-commit mailing list