[pypy-commit] pypy kill-ootype: Remove ootype support from rpython.rtyper.rtyper

rlamy noreply at buildbot.pypy.org
Sat Jul 6 17:42:51 CEST 2013


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: kill-ootype
Changeset: r65232:64eb95059623
Date: 2013-07-06 16:50 +0200
http://bitbucket.org/pypy/pypy/changeset/64eb95059623/

Log:	Remove ootype support from rpython.rtyper.rtyper

diff --git a/rpython/rtyper/rpbc.py b/rpython/rtyper/rpbc.py
--- a/rpython/rtyper/rpbc.py
+++ b/rpython/rtyper/rpbc.py
@@ -824,15 +824,7 @@
                                  "classes with no common base: %r" % (mdescs,))
 
         self.methodname = methodname
-        # for ootype, the right thing to do is to always keep the most precise
-        # type of the instance, while for lltype we want to cast it to the
-        # type where the method is actually defined. See also
-        # test_rclass.test_method_specialized_with_subclass and
-        # rtyper.attach_methods_to_subclasses
-        if self.rtyper.type_system.name == 'ootypesystem':
-            self.classdef = classdef
-        else:
-            self.classdef = classdef.locate_attribute(methodname)
+        self.classdef = classdef.locate_attribute(methodname)
         # the low-level representation is just the bound 'self' argument.
         self.s_im_self = annmodel.SomeInstance(self.classdef, flags=flags)
         self.r_im_self = rclass.getinstancerepr(rtyper, self.classdef)
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -23,9 +23,8 @@
 from rpython.rtyper.lltypesystem.lltype import (Signed, Void, LowLevelType,
     Ptr, ContainerType, FuncType, functionptr, typeOf, RuntimeTypeInfo,
     attachRuntimeTypeInfo, Primitive)
-from rpython.rtyper.ootypesystem import ootype
 from rpython.rtyper.rmodel import Repr, inputconst, BrokenReprTyperError
-from rpython.rtyper.typesystem import LowLevelTypeSystem, ObjectOrientedTypeSystem
+from rpython.rtyper.typesystem import LowLevelTypeSystem
 from rpython.tool.pairtype import pair
 from rpython.translator.unsimplify import insert_empty_block
 
@@ -41,8 +40,6 @@
         if isinstance(type_system, str):
             if type_system == "lltype":
                 self.type_system = LowLevelTypeSystem.instance
-            elif type_system == "ootype":
-                self.type_system = ObjectOrientedTypeSystem.instance
             else:
                 raise TyperError("Unknown type system %r!" % type_system)
         else:
@@ -208,8 +205,6 @@
         if self.exceptiondata is not None:
             self.exceptiondata.make_helpers(self)
             self.specialize_more_blocks()   # for the helpers just made
-        if self.type_system.name == 'ootypesystem':
-            self.attach_methods_to_subclasses()
 
     def getannmixlevel(self):
         if self.annmixlevel is not None:
@@ -275,40 +270,6 @@
         if annmixlevel is not None:
             annmixlevel.finish()
 
-    def attach_methods_to_subclasses(self):
-        # in ootype, it might happen that a method is defined in the
-        # superclass but the annotator discovers that it's always called
-        # through instances of a subclass (e.g. because of specialization, see
-        # test_rclass.test_method_specialized_with_subclass).  In that cases,
-        # we copy the method also in the ootype.Instance of the subclass, so
-        # that the type of v_self coincides with the type returned by
-        # _lookup().
-        assert self.type_system.name == 'ootypesystem'
-        def allclasses(TYPE, seen):
-            '''Yield TYPE and all its subclasses'''
-            if TYPE in seen:
-                return
-            seen.add(TYPE)
-            yield TYPE
-            for SUB in TYPE._subclasses:
-                for T in allclasses(SUB, seen):
-                    yield T
-
-        for TYPE in allclasses(ootype.ROOT, set()):
-            for methname, meth in TYPE._methods.iteritems():
-                try:
-                    graph = meth.graph
-                except AttributeError:
-                    continue
-                SELF = graph.getargs()[0].concretetype
-                if TYPE != SELF and ootype.isSubclass(SELF, TYPE):
-                    # the annotator found that this method has a more precise
-                    # type. Attach it to the proper subclass, so that the type
-                    # of 'self' coincides with the type returned by _lookup(),
-                    # else we might have type errors
-                    if methname not in SELF._methods:
-                        ootype.addMethods(SELF, {methname: meth})
-
     def dump_typererrors(self, num=None, minimize=True, to_log=False):
         c = 0
         bc = 0
@@ -1015,4 +976,3 @@
 from rpython.rtyper import rptr
 from rpython.rtyper import rweakref
 from rpython.rtyper import raddress # memory addresses
-from rpython.rtyper.ootypesystem import rootype


More information about the pypy-commit mailing list