Author: Ronan Lamy <ronan.l...@gmail.com>
Branch: ClassRepr
Changeset: r73920:e1ac0c1a34be
Date: 2014-10-13 17:46 +0100
http://bitbucket.org/pypy/pypy/changeset/e1ac0c1a34be/

Log:    replace RootClassRepr.setup_vtable() with
        ClassRepr.fill_vtable_root()

diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -306,7 +306,7 @@
             r_parentcls.setup_vtable(vtable_part, self)
             vtable_part = vtable_part.super
             r_parentcls = r_parentcls.rbase
-        r_parentcls.setup_vtable(vtable_part, self)
+        self.fill_vtable_root(vtable_part)
 
     def setup_vtable(self, vtable, rsubcls):
         """Initialize the 'self' portion of the 'vtable' belonging to the
@@ -337,6 +337,32 @@
             if attrvalue is not None:
                 assign(mangled_name, attrvalue)
 
+    def fill_vtable_root(rsubcls, vtable):
+        """Initialize the head of the vtable."""
+        vtable.hash = hash(rsubcls)
+        # initialize the 'subclassrange_*' and 'name' fields
+        if rsubcls.classdef is not None:
+            #vtable.parenttypeptr = rsubcls.rbase.getvtable()
+            vtable.subclassrange_min = rsubcls.classdef.minid
+            vtable.subclassrange_max = rsubcls.classdef.maxid
+        else:  # for the root class
+            vtable.subclassrange_min = 0
+            vtable.subclassrange_max = sys.maxint
+        rinstance = getinstancerepr(rsubcls.rtyper, rsubcls.classdef)
+        rinstance.setup()
+        if rinstance.gcflavor == 'gc':
+            vtable.rtti = getRuntimeTypeInfo(rinstance.object_type)
+        if rsubcls.classdef is None:
+            name = 'object'
+        else:
+            name = rsubcls.classdef.shortname
+        vtable.name = alloc_array_name(name)
+        if hasattr(rsubcls.classdef, 'my_instantiate_graph'):
+            graph = rsubcls.classdef.my_instantiate_graph
+            vtable.instantiate = rsubcls.rtyper.getcallable(graph)
+        #else: the classdef was created recently, so no instantiate()
+        #      could reach it
+
     def fromtypeptr(self, vcls, llops):
         """Return the type pointer cast to self's vtable type."""
         self.setup()
@@ -410,29 +436,7 @@
     def setup_vtable(self, vtable, rsubcls):
         """Initialize the 'self' portion of the 'vtable' belonging to the
         given subclass."""
-        vtable.hash = hash(rsubcls)
-        # initialize the 'subclassrange_*' and 'name' fields
-        if rsubcls.classdef is not None:
-            #vtable.parenttypeptr = rsubcls.rbase.getvtable()
-            vtable.subclassrange_min = rsubcls.classdef.minid
-            vtable.subclassrange_max = rsubcls.classdef.maxid
-        else:  # for the root class
-            vtable.subclassrange_min = 0
-            vtable.subclassrange_max = sys.maxint
-        rinstance = getinstancerepr(self.rtyper, rsubcls.classdef)
-        rinstance.setup()
-        if rinstance.gcflavor == 'gc':
-            vtable.rtti = getRuntimeTypeInfo(rinstance.object_type)
-        if rsubcls.classdef is None:
-            name = 'object'
-        else:
-            name = rsubcls.classdef.shortname
-        vtable.name = alloc_array_name(name)
-        if hasattr(rsubcls.classdef, 'my_instantiate_graph'):
-            graph = rsubcls.classdef.my_instantiate_graph
-            vtable.instantiate = self.rtyper.getcallable(graph)
-        #else: the classdef was created recently, so no instantiate()
-        #      could reach it
+        raise RuntimeError('should not be called')
 
 def get_type_repr(rtyper):
     return getclassrepr(rtyper, None)
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to