Author: Ronan Lamy <[email protected]>
Branch: ClassRepr
Changeset: r73910:712925681a5d
Date: 2014-10-13 01:24 +0100
http://bitbucket.org/pypy/pypy/changeset/712925681a5d/

Log:    Create RootClassRepr for the case where classrepr.classdef is None

diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -66,7 +66,10 @@
     try:
         result = rtyper.class_reprs[classdef]
     except KeyError:
-        result = ClassRepr(rtyper, classdef)
+        if classdef is None:
+            result = RootClassRepr(rtyper)
+        else:
+            result = ClassRepr(rtyper, classdef)
         rtyper.class_reprs[classdef] = result
         rtyper.add_pendingsetup(result)
     return result
@@ -193,11 +196,7 @@
     def __init__(self, rtyper, classdef):
         self.rtyper = rtyper
         self.classdef = classdef
-        if classdef is None:
-            # 'object' root type
-            self.vtable_type = OBJECT_VTABLE
-        else:
-            self.vtable_type = lltype.ForwardReference()
+        self.vtable_type = lltype.ForwardReference()
         self.lowleveltype = Ptr(self.vtable_type)
 
     def __repr__(self):
@@ -420,6 +419,17 @@
             v_cls1, v_cls2 = hop.inputargs(class_repr, class_repr)
             return hop.gendirectcall(ll_issubclass, v_cls1, v_cls2)
 
+
+class RootClassRepr(ClassRepr):
+    """ClassRepr for the root of the class hierarchy"""
+    classdef = None
+
+    def __init__(self, rtyper):
+        self.rtyper = rtyper
+        self.vtable_type = OBJECT_VTABLE
+        self.lowleveltype = Ptr(self.vtable_type)
+
+
 def get_type_repr(rtyper):
     return getclassrepr(rtyper, None)
 
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to