[pypy-commit] pypy kill-typesystem: kill the lazy import hack in TypeSystem

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


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: kill-typesystem
Changeset: r65882:cc3d8a522a8b
Date: 2013-08-01 18:21 +0100
http://bitbucket.org/pypy/pypy/changeset/cc3d8a522a8b/

Log:	kill the lazy import hack in TypeSystem

diff --git a/rpython/rlib/debug.py b/rpython/rlib/debug.py
--- a/rpython/rlib/debug.py
+++ b/rpython/rlib/debug.py
@@ -127,8 +127,8 @@
         return None
 
     def specialize_call(self, hop):
+        from rpython.rtyper.lltypesystem.rstr import string_repr
         fn = self.instance
-        string_repr = hop.rtyper.type_system.rstr.string_repr
         vlist = hop.inputargs(string_repr)
         hop.exception_cannot_occur()
         t = hop.rtyper.annotator.translator
@@ -190,7 +190,7 @@
 
     def compute_result_annotation(self):
         return None
-    
+
     def specialize_call(self, hop):
         hop.exception_cannot_occur()
         return hop.genop('debug_flush', [])
@@ -278,7 +278,7 @@
             from rpython.annotator.annrpython import log
             log.WARNING('make_sure_not_resized called, but has no effect since list_comprehension is off')
         return s_arg
-    
+
     def specialize_call(self, hop):
         hop.exception_cannot_occur()
         return hop.inputarg(hop.args_r[0], arg=0)
@@ -294,7 +294,7 @@
 
 class DictMarkEntry(ExtRegistryEntry):
     _about_ = mark_dict_non_null
-    
+
     def compute_result_annotation(self, s_dict):
         from rpython.annotator.model import SomeDict
 
diff --git a/rpython/rlib/rstring.py b/rpython/rlib/rstring.py
--- a/rpython/rlib/rstring.py
+++ b/rpython/rlib/rstring.py
@@ -362,7 +362,8 @@
         return SomeString()
 
     def rtyper_makerepr(self, rtyper):
-        return rtyper.type_system.rbuilder.stringbuilder_repr
+        from rpython.rtyper.lltypesystem.rbuilder import stringbuilder_repr
+        return stringbuilder_repr
 
     def rtyper_makekey(self):
         return self.__class__,
@@ -398,7 +399,8 @@
         return SomeUnicodeString()
 
     def rtyper_makerepr(self, rtyper):
-        return rtyper.type_system.rbuilder.unicodebuilder_repr
+        from rpython.rtyper.lltypesystem.rbuilder import unicodebuilder_repr
+        return unicodebuilder_repr
 
     def rtyper_makekey(self):
         return self.__class__,
diff --git a/rpython/rtyper/rbuiltin.py b/rpython/rtyper/rbuiltin.py
--- a/rpython/rtyper/rbuiltin.py
+++ b/rpython/rtyper/rbuiltin.py
@@ -93,7 +93,8 @@
         except (KeyError, TypeError):
             pass
         try:
-            return rtyper.type_system.rbuiltin.BUILTIN_TYPER[self.builtinfunc]
+            from rpython.rtyper.lltypesystem.rbuiltin import BUILTIN_TYPER as ll_BUILTIN_TYPER
+            return ll_BUILTIN_TYPER[self.builtinfunc]
         except (KeyError, TypeError):
             pass
         if extregistry.is_registered(self.builtinfunc):
diff --git a/rpython/rtyper/rbytearray.py b/rpython/rtyper/rbytearray.py
--- a/rpython/rtyper/rbytearray.py
+++ b/rpython/rtyper/rbytearray.py
@@ -57,4 +57,5 @@
         return self.__class__,
 
     def rtyper_makerepr(self, rtyper):
-        return rtyper.type_system.rbytearray.bytearray_repr
+        from rpython.rtyper.lltypesystem.rbytearray import bytearray_repr
+        return bytearray_repr
diff --git a/rpython/rtyper/rdict.py b/rpython/rtyper/rdict.py
--- a/rpython/rtyper/rdict.py
+++ b/rpython/rtyper/rdict.py
@@ -5,23 +5,20 @@
 
 class __extend__(annmodel.SomeDict):
     def rtyper_makerepr(self, rtyper):
-        dictkey   = self.dictdef.dictkey
+        from rpython.rtyper.lltypesystem.rdict import DictRepr
+        dictkey = self.dictdef.dictkey
         dictvalue = self.dictdef.dictvalue
-        s_key     = dictkey  .s_value
-        s_value   = dictvalue.s_value
+        s_key = dictkey.s_value
+        s_value = dictvalue.s_value
         force_non_null = self.dictdef.force_non_null
         if dictkey.custom_eq_hash:
             custom_eq_hash = lambda: (rtyper.getrepr(dictkey.s_rdict_eqfn),
                                       rtyper.getrepr(dictkey.s_rdict_hashfn))
         else:
             custom_eq_hash = None
-        return rtyper.type_system.rdict.DictRepr(rtyper,
-                                                 lambda: rtyper.getrepr(s_key),
-                                                 lambda: rtyper.getrepr(s_value),
-                                                 dictkey,
-                                                 dictvalue,
-                                                 custom_eq_hash,
-                                                 force_non_null)
+        return DictRepr(rtyper, lambda: rtyper.getrepr(s_key),
+                        lambda: rtyper.getrepr(s_value), dictkey, dictvalue,
+                        custom_eq_hash, force_non_null)
 
     def rtyper_makekey(self):
         self.dictdef.dictkey  .dont_change_any_more = True
@@ -29,7 +26,6 @@
         return (self.__class__, self.dictdef.dictkey, self.dictdef.dictvalue)
 
 
-
 class AbstractDictRepr(rmodel.Repr):
 
     def pickrepr(self, item_repr):
@@ -41,7 +37,8 @@
     pickkeyrepr = pickrepr
 
     def compact_repr(self):
-        return 'DictR %s %s' % (self.key_repr.compact_repr(), self.value_repr.compact_repr())
+        return 'DictR %s %s' % (self.key_repr.compact_repr(),
+                                self.value_repr.compact_repr())
 
     def recast_value(self, llops, v):
         return llops.convertvar(v, self.value_repr, self.external_value_repr)
@@ -51,10 +48,11 @@
 
 
 def rtype_newdict(hop):
+    from rpython.rtyper.lltypesystem.rdict import ll_newdict
     hop.inputargs()    # no arguments expected
     r_dict = hop.r_result
     cDICT = hop.inputconst(lltype.Void, r_dict.DICT)
-    v_result = hop.gendirectcall(hop.rtyper.type_system.rdict.ll_newdict, cDICT)
+    v_result = hop.gendirectcall(ll_newdict, cDICT)
     return v_result
 
 
diff --git a/rpython/rtyper/rfloat.py b/rpython/rtyper/rfloat.py
--- a/rpython/rtyper/rfloat.py
+++ b/rpython/rtyper/rfloat.py
@@ -77,8 +77,8 @@
 
 class __extend__(pairtype(AbstractStringRepr, FloatRepr)):
     def rtype_mod(_, hop):
-        rstr = hop.rtyper.type_system.rstr
-        return rstr.do_stringformat(hop, [(hop.args_v[1], hop.args_r[1])])
+        from rpython.rtyper.lltypesystem.rstr import do_stringformat
+        return do_stringformat(hop, [(hop.args_v[1], hop.args_r[1])])
 
 #Helpers FloatRepr,FloatRepr
 
@@ -90,7 +90,6 @@
     vlist = hop.inputargs(Float, Float)
     return hop.genop('float_'+func, vlist, resulttype=Bool)
 
-#
 
 class __extend__(FloatRepr):
 
diff --git a/rpython/rtyper/rint.py b/rpython/rtyper/rint.py
--- a/rpython/rtyper/rint.py
+++ b/rpython/rtyper/rint.py
@@ -371,18 +371,18 @@
         return ll_int2dec(i)
 
     def rtype_hex(self, hop):
+        from rpython.rtyper.lltypesystem.ll_str import ll_int2hex
         self = self.as_int
         varg = hop.inputarg(self, 0)
         true = inputconst(Bool, True)
-        fn = hop.rtyper.type_system.ll_str.ll_int2hex
-        return hop.gendirectcall(fn, varg, true)
+        return hop.gendirectcall(ll_int2hex, varg, true)
 
     def rtype_oct(self, hop):
+        from rpython.rtyper.lltypesystem.ll_str import ll_int2oct
         self = self.as_int
         varg = hop.inputarg(self, 0)
         true = inputconst(Bool, True)
-        fn = hop.rtyper.type_system.ll_str.ll_int2oct
-        return hop.gendirectcall(fn, varg, true)
+        return hop.gendirectcall(ll_int2oct, varg, true)
 
 def ll_hash_int(n):
     return intmask(n)
diff --git a/rpython/rtyper/rlist.py b/rpython/rtyper/rlist.py
--- a/rpython/rtyper/rlist.py
+++ b/rpython/rtyper/rlist.py
@@ -41,17 +41,18 @@
         listitem = self.listdef.listitem
         s_value = listitem.s_value
         if (listitem.range_step is not None and not listitem.mutated and
-            not isinstance(s_value, annmodel.SomeImpossibleValue)):
-            return rtyper.type_system.rrange.RangeRepr(listitem.range_step)
+                not isinstance(s_value, annmodel.SomeImpossibleValue)):
+            from rpython.rtyper.lltypesystem.rrange import RangeRepr
+            return RangeRepr(listitem.range_step)
         else:
             # cannot do the rtyper.getrepr() call immediately, for the case
             # of recursive structures -- i.e. if the listdef contains itself
-            rlist = rtyper.type_system.rlist
+            from rpython.rtyper.lltypesystem.rlist import ListRepr, FixedSizeListRepr
             item_repr = lambda: rtyper.getrepr(listitem.s_value)
             if self.listdef.listitem.resized:
-                return rlist.ListRepr(rtyper, item_repr, listitem)
+                return ListRepr(rtyper, item_repr, listitem)
             else:
-                return rlist.FixedSizeListRepr(rtyper, item_repr, listitem)
+                return FixedSizeListRepr(rtyper, item_repr, listitem)
 
     def rtyper_makekey(self):
         self.listdef.listitem.dont_change_any_more = True
@@ -339,12 +340,12 @@
 
 
 def rtype_newlist(hop, v_sizehint=None):
+    from rpython.rtyper.lltypesystem.rlist import newlist
     nb_args = hop.nb_args
     r_list = hop.r_result
     r_listitem = r_list.item_repr
     items_v = [hop.inputarg(r_listitem, arg=i) for i in range(nb_args)]
-    return hop.rtyper.type_system.rlist.newlist(hop.llops, r_list, items_v,
-                                                v_sizehint=v_sizehint)
+    return newlist(hop.llops, r_list, items_v, v_sizehint=v_sizehint)
 
 def rtype_alloc_and_set(hop):
     r_list = hop.r_result
@@ -382,10 +383,10 @@
         return v_lst1
 
     def rtype_extend_with_str_slice((r_lst1, r_str2), hop):
+        from rpython.rtyper.lltypesystem.rstr import string_repr
         if r_lst1.item_repr.lowleveltype not in (Char, UniChar):
             raise TyperError('"lst += string" only supported with a list '
                              'of chars or unichars')
-        string_repr = r_lst1.rtyper.type_system.rstr.string_repr
         v_lst1 = hop.inputarg(r_lst1, arg=0)
         v_str2 = hop.inputarg(string_repr, arg=3)
         kind, vlist = hop.decompose_slice_args()
@@ -398,10 +399,10 @@
 class __extend__(pairtype(AbstractListRepr, AbstractCharRepr)):
 
     def rtype_extend_with_char_count((r_lst1, r_chr2), hop):
+        from rpython.rtyper.lltypesystem.rstr import char_repr
         if r_lst1.item_repr.lowleveltype not in (Char, UniChar):
             raise TyperError('"lst += string" only supported with a list '
                              'of chars or unichars')
-        char_repr = r_lst1.rtyper.type_system.rstr.char_repr
         v_lst1, v_chr, v_count = hop.inputargs(r_lst1, char_repr, Signed)
         hop.gendirectcall(ll_extend_with_char_count, v_lst1, v_chr, v_count)
         return v_lst1
diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -12,8 +12,7 @@
 
 
 def small_cand(rtyper, s_pbc):
-    if 1 < len(s_pbc.descriptions) < rtyper.getconfig().translation.withsmallfuncsets and \
-           hasattr(rtyper.type_system.rpbc, 'SmallFunctionSetPBCRepr'):
+    if 1 < len(s_pbc.descriptions) < rtyper.getconfig().translation.withsmallfuncsets:
         callfamily = s_pbc.any_description().getcallfamily()
         concretetable, uniquerows = get_concrete_calltable(rtyper, callfamily)
         if len(uniquerows) == 1 and (not s_pbc.subset_of or small_cand(rtyper, s_pbc.subset_of)):
@@ -22,6 +21,9 @@
 
 class __extend__(annmodel.SomePBC):
     def rtyper_makerepr(self, rtyper):
+        from rpython.rtyper.lltypesystem.rpbc import (FunctionsPBCRepr,
+            SmallFunctionSetPBCRepr, ClassesPBCRepr, MethodsPBCRepr,
+            MethodOfFrozenPBCRepr)
         if self.isNone():
             return none_frozen_pbc_repr
         kind = self.getKind()
@@ -32,20 +34,20 @@
                 if sample.overridden:
                     getRepr = OverriddenFunctionPBCRepr
                 else:
-                    getRepr = rtyper.type_system.rpbc.FunctionsPBCRepr
+                    getRepr = FunctionsPBCRepr
                     if small_cand(rtyper, self):
-                        getRepr = rtyper.type_system.rpbc.SmallFunctionSetPBCRepr
+                        getRepr = SmallFunctionSetPBCRepr
             else:
                 getRepr = getFrozenPBCRepr
         elif issubclass(kind, description.ClassDesc):
             # user classes
-            getRepr = rtyper.type_system.rpbc.ClassesPBCRepr
+            getRepr = ClassesPBCRepr
         elif issubclass(kind, description.MethodDesc):
-            getRepr = rtyper.type_system.rpbc.MethodsPBCRepr
+            getRepr = MethodsPBCRepr
         elif issubclass(kind, description.FrozenDesc):
             getRepr = getFrozenPBCRepr
         elif issubclass(kind, description.MethodOfFrozenDesc):
-            getRepr = rtyper.type_system.rpbc.MethodOfFrozenPBCRepr
+            getRepr = MethodOfFrozenPBCRepr
         else:
             raise TyperError("unexpected PBC kind %r" % (kind,))
 
@@ -350,6 +352,8 @@
         return rtype_call_specialcase(hop)
 
 def getFrozenPBCRepr(rtyper, s_pbc):
+    from rpython.rtyper.lltypesystem.rpbc import (
+        MultipleUnrelatedFrozenPBCRepr, MultipleFrozenPBCRepr)
     descs = list(s_pbc.descriptions)
     assert len(descs) >= 1
     if len(descs) == 1 and not s_pbc.can_be_None:
@@ -362,15 +366,13 @@
                 try:
                     return rtyper.pbc_reprs['unrelated']
                 except KeyError:
-                    rpbc = rtyper.type_system.rpbc
-                    result = rpbc.MultipleUnrelatedFrozenPBCRepr(rtyper)
+                    result = MultipleUnrelatedFrozenPBCRepr(rtyper)
                     rtyper.pbc_reprs['unrelated'] = result
                     return result
         try:
             return rtyper.pbc_reprs[access]
         except KeyError:
-            result = rtyper.type_system.rpbc.MultipleFrozenPBCRepr(rtyper,
-                                                                   access)
+            result = MultipleFrozenPBCRepr(rtyper, access)
             rtyper.pbc_reprs[access] = result
             rtyper.add_pendingsetup(result)
             return result
@@ -612,9 +614,10 @@
         return inputconst(Void, None)
 
     def rtype_is_((robj1, rnone2), hop):
+        from rpython.rtyper.lltypesystem.rpbc import rtype_is_None
         if hop.s_result.is_constant():
             return hop.inputconst(Bool, hop.s_result.const)
-        return hop.rtyper.type_system.rpbc.rtype_is_None(robj1, rnone2, hop)
+        return rtype_is_None(robj1, rnone2, hop)
 
 class __extend__(pairtype(NoneFrozenPBCRepr, Repr)):
 
@@ -622,10 +625,10 @@
         return inputconst(r_to, None)
 
     def rtype_is_((rnone1, robj2), hop):
+        from rpython.rtyper.lltypesystem.rpbc import rtype_is_None
         if hop.s_result.is_constant():
             return hop.inputconst(Bool, hop.s_result.const)
-        return hop.rtyper.type_system.rpbc.rtype_is_None(
-                                                robj2, rnone1, hop, pos=1)
+        return rtype_is_None(robj2, rnone1, hop, pos=1)
 
 # ____________________________________________________________
 
diff --git a/rpython/rtyper/rstr.py b/rpython/rtyper/rstr.py
--- a/rpython/rtyper/rstr.py
+++ b/rpython/rtyper/rstr.py
@@ -88,26 +88,33 @@
 
 class __extend__(annmodel.SomeString):
     def rtyper_makerepr(self, rtyper):
-        return rtyper.type_system.rstr.string_repr
+        from rpython.rtyper.lltypesystem.rstr import string_repr
+        return string_repr
+
     def rtyper_makekey(self):
         return self.__class__,
 
 class __extend__(annmodel.SomeUnicodeString):
     def rtyper_makerepr(self, rtyper):
-        return rtyper.type_system.rstr.unicode_repr
+        from rpython.rtyper.lltypesystem.rstr import unicode_repr
+        return unicode_repr
 
     def rtyper_makekey(self):
         return self.__class__,
 
 class __extend__(annmodel.SomeChar):
     def rtyper_makerepr(self, rtyper):
-        return rtyper.type_system.rstr.char_repr
+        from rpython.rtyper.lltypesystem.rstr import char_repr
+        return char_repr
+
     def rtyper_makekey(self):
         return self.__class__,
 
 class __extend__(annmodel.SomeUnicodeCodePoint):
     def rtyper_makerepr(self, rtyper):
-        return rtyper.type_system.rstr.unichar_repr
+        from rpython.rtyper.lltypesystem.rstr import unichar_repr
+        return unichar_repr
+
     def rtyper_makekey(self):
         return self.__class__,
 
@@ -271,12 +278,14 @@
         raise NotImplementedError
 
     def rtype_method_join(self, hop):
+        from rpython.rtyper.lltypesystem.rlist import BaseListRepr
+        from rpython.rtyper.lltypesystem.rstr import char_repr, unichar_repr
         hop.exception_cannot_occur()
         rstr = hop.args_r[0]
         if hop.s_result.is_constant():
             return inputconst(rstr.repr, hop.s_result.const)
         r_lst = hop.args_r[1]
-        if not isinstance(r_lst, hop.rtyper.type_system.rlist.BaseListRepr):
+        if not isinstance(r_lst, BaseListRepr):
             raise TyperError("string.join of non-list: %r" % r_lst)
         v_str, v_lst = hop.inputargs(rstr.repr, r_lst)
         v_length, v_items = self._list_length_items(hop, v_lst, r_lst.lowleveltype)
@@ -284,8 +293,8 @@
         if hop.args_s[0].is_constant() and hop.args_s[0].const == '':
             if r_lst.item_repr == rstr.repr:
                 llfn = self.ll.ll_join_strs
-            elif (r_lst.item_repr == hop.rtyper.type_system.rstr.char_repr or
-                  r_lst.item_repr == hop.rtyper.type_system.rstr.unichar_repr):
+            elif (r_lst.item_repr == char_repr or
+                  r_lst.item_repr == unichar_repr):
                 v_tp = hop.inputconst(Void, self.lowleveltype)
                 return hop.gendirectcall(self.ll.ll_join_chars, v_length,
                                          v_items, v_tp)
@@ -655,8 +664,8 @@
 #Helper functions for comparisons
 
 def _rtype_compare_template(hop, func):
-    rstr = hop.rtyper.type_system.rstr
-    vlist = hop.inputargs(rstr.char_repr, rstr.char_repr)
+    from rpython.rtyper.lltypesystem.rstr import char_repr
+    vlist = hop.inputargs(char_repr, char_repr)
     return hop.genop('char_' + func, vlist, resulttype=Bool)
 
 class __extend__(AbstractUniCharRepr):
@@ -677,8 +686,8 @@
     get_ll_fasthash_function = get_ll_hash_function
 
     def rtype_ord(_, hop):
-        rstr = hop.rtyper.type_system.rstr
-        vlist = hop.inputargs(rstr.unichar_repr)
+        from rpython.rtyper.lltypesystem.rstr import unichar_repr
+        vlist = hop.inputargs(unichar_repr)
         return hop.genop('cast_unichar_to_int', vlist, resulttype=Signed)
 
 
@@ -691,8 +700,8 @@
 #Helper functions for comparisons
 
 def _rtype_unchr_compare_template(hop, func):
-    rstr = hop.rtyper.type_system.rstr
-    vlist = hop.inputargs(rstr.unichar_repr, rstr.unichar_repr)
+    from rpython.rtyper.lltypesystem.rstr import unichar_repr
+    vlist = hop.inputargs(unichar_repr, unichar_repr)
     return hop.genop('unichar_' + func, vlist, resulttype=Bool)
 
 
@@ -702,16 +711,17 @@
 class __extend__(pairtype(AbstractCharRepr, AbstractStringRepr),
                  pairtype(AbstractUniCharRepr, AbstractUnicodeRepr)):
     def convert_from_to((r_from, r_to), v, llops):
-        rstr = llops.rtyper.type_system.rstr
-        if (r_from == rstr.char_repr and r_to == rstr.string_repr) or\
-           (r_from == rstr.unichar_repr and r_to == rstr.unicode_repr):
+        from rpython.rtyper.lltypesystem.rstr import (
+            string_repr, unicode_repr, char_repr, unichar_repr)
+        if (r_from == char_repr and r_to == string_repr) or\
+           (r_from == unichar_repr and r_to == unicode_repr):
             return llops.gendirectcall(r_from.ll.ll_chr2str, v)
         return NotImplemented
 
 class __extend__(pairtype(AbstractStringRepr, AbstractCharRepr)):
     def convert_from_to((r_from, r_to), v, llops):
-        rstr = llops.rtyper.type_system.rstr
-        if r_from == rstr.string_repr and r_to == rstr.char_repr:
+        from rpython.rtyper.lltypesystem.rstr import string_repr, char_repr
+        if r_from == string_repr and r_to == char_repr:
             c_zero = inputconst(Signed, 0)
             return llops.gendirectcall(r_from.ll.ll_stritem_nonneg, v, c_zero)
         return NotImplemented
diff --git a/rpython/rtyper/rtuple.py b/rpython/rtyper/rtuple.py
--- a/rpython/rtyper/rtuple.py
+++ b/rpython/rtyper/rtuple.py
@@ -13,8 +13,8 @@
 
 class __extend__(annmodel.SomeTuple):
     def rtyper_makerepr(self, rtyper):
-        repr_class = rtyper.type_system.rtuple.TupleRepr
-        return repr_class(rtyper, [rtyper.getrepr(s_item) for s_item in self.items])
+        from rpython.rtyper.lltypesystem.rtuple import TupleRepr
+        return TupleRepr(rtyper, [rtyper.getrepr(s_item) for s_item in self.items])
 
     def rtyper_makekey_ex(self, rtyper):
         keys = [rtyper.makekey(s_item) for s_item in self.items]
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -578,7 +578,8 @@
         return pair(r_arg1, r_arg2).rtype_extend_with_char_count(hop)
 
     def translate_op_newtuple(self, hop):
-        return self.type_system.rtuple.rtype_newtuple(hop)
+        from rpython.rtyper.lltypesystem.rtuple import rtype_newtuple
+        return rtype_newtuple(hop)
 
     def translate_op_instantiate1(self, hop):
         from rpython.rtyper.lltypesystem import rclass
diff --git a/rpython/rtyper/typesystem.py b/rpython/rtyper/typesystem.py
--- a/rpython/rtyper/typesystem.py
+++ b/rpython/rtyper/typesystem.py
@@ -9,24 +9,6 @@
 class TypeSystem(object):
     __metaclass__ = extendabletype
 
-    def __getattr__(self, name):
-        """Lazy import to avoid circular dependencies."""
-        def load(modname):
-            try:
-                return __import__("rpython.rtyper.%s.%s" % (self.name, modname),
-                                  None, None, ['__doc__'])
-            except ImportError:
-                return None
-        if name in ('rclass', 'rpbc', 'rbuiltin', 'rtuple', 'rlist',
-                    'rslice', 'rdict', 'rrange', 'rstr',
-                    'll_str', 'rbuilder', 'rbytearray'):
-            mod = load(name)
-            if mod is not None:
-                setattr(self, name, mod)
-                return mod
-
-        raise AttributeError(name)
-
     def derefType(self, T):
         raise NotImplementedError()
 
diff --git a/rpython/translator/exceptiontransform.py b/rpython/translator/exceptiontransform.py
--- a/rpython/translator/exceptiontransform.py
+++ b/rpython/translator/exceptiontransform.py
@@ -6,6 +6,7 @@
     c_last_exception, SpaceOperation, FunctionGraph, mkentrymap
 from rpython.rtyper.lltypesystem import lltype, llmemory, rffi
 from rpython.rtyper.lltypesystem import lloperation
+from rpython.rtyper.lltypesystem.rclass import ll_inst_type
 from rpython.rtyper import rtyper
 from rpython.rtyper.rmodel import inputconst
 from rpython.rlib.rarithmetic import r_uint, r_longlong, r_ulonglong
@@ -55,7 +56,6 @@
         self.mixlevelannotator = MixLevelHelperAnnotator(translator.rtyper)
         exc_data, null_type, null_value = self.setup_excdata()
 
-        rclass = translator.rtyper.type_system.rclass
         (assertion_error_ll_exc_type,
          assertion_error_ll_exc) = self.get_builtin_exception(AssertionError)
         (n_i_error_ll_exc_type,
@@ -105,7 +105,7 @@
 
         def rpyexc_restore_exception(evalue):
             if evalue:
-                exc_data.exc_type = rclass.ll_inst_type(evalue)
+                exc_data.exc_type = ll_inst_type(evalue)
                 exc_data.exc_value = evalue
 
         self.rpyexc_occured_ptr = self.build_func(
@@ -170,12 +170,11 @@
 
     def get_builtin_exception(self, Class):
         edata = self.translator.rtyper.exceptiondata
-        rclass = self.translator.rtyper.type_system.rclass
         bk = self.translator.annotator.bookkeeper
         error_def = bk.getuniqueclassdef(Class)
         error_ll_exc = edata.get_standard_ll_exc_instance(
             self.translator.rtyper, error_def)
-        error_ll_exc_type = rclass.ll_inst_type(error_ll_exc)
+        error_ll_exc_type = ll_inst_type(error_ll_exc)
         return error_ll_exc_type, error_ll_exc
 
     def transform_completely(self):


More information about the pypy-commit mailing list