Пример #1
0
    def __init__(self, rtyper, classdef):
        AbstractClassRepr.__init__(self, rtyper, classdef)
        # This is the Repr for a reference to the class 'classdef' or
        # any subclass.  In the simple case, the lowleveltype is just
        # ootype.Class.  If we need to store class attributes, we use a
        # "meta" class where the attributes are defined, and the class
        # reference is a reference to an instance of this meta class.
        extra_access_sets = self.rtyper.class_pbc_attributes.get(
            classdef, {})
        has_class_attributes = bool(extra_access_sets)
        if self.classdef is not None:
            self.rbase = getclassrepr(self.rtyper, self.classdef.basedef)
            meta_base_type = self.rbase.lowleveltype
            baseclass_has_meta = meta_base_type != ootype.Class
        else:
            baseclass_has_meta = False

        if not has_class_attributes and not baseclass_has_meta:
            self.lowleveltype = ootype.Class   # simple case
        else:
            if self.classdef is None:
                raise TyperError("the root 'object' class should not have"
                                 " class attributes")
            if self.classdef.classdesc.pyobj in standardexceptions:
                raise TyperError("Standard exception class %r should not have"
                                 " class attributes" % (self.classdef.name,))
            if not baseclass_has_meta:
                meta_base_type = META
            self.lowleveltype = ootype.Instance(
                    self.classdef.name + "_meta", meta_base_type)
Пример #2
0
    def __init__(self, rtyper, classdef):
        AbstractClassRepr.__init__(self, rtyper, classdef)
        # This is the Repr for a reference to the class 'classdef' or
        # any subclass.  In the simple case, the lowleveltype is just
        # ootype.Class.  If we need to store class attributes, we use a
        # "meta" class where the attributes are defined, and the class
        # reference is a reference to an instance of this meta class.
        extra_access_sets = self.rtyper.class_pbc_attributes.get(classdef, {})
        has_class_attributes = bool(extra_access_sets)
        if self.classdef is not None:
            self.rbase = getclassrepr(self.rtyper, self.classdef.basedef)
            meta_base_type = self.rbase.lowleveltype
            baseclass_has_meta = meta_base_type != ootype.Class
        else:
            baseclass_has_meta = False

        if not has_class_attributes and not baseclass_has_meta:
            self.lowleveltype = ootype.Class  # simple case
        else:
            if self.classdef is None:
                raise TyperError("the root 'object' class should not have"
                                 " class attributes")
            if self.classdef.classdesc.pyobj in standardexceptions:
                raise TyperError("Standard exception class %r should not have"
                                 " class attributes" % (self.classdef.name, ))
            if not baseclass_has_meta:
                meta_base_type = META
            self.lowleveltype = ootype.Instance(self.classdef.name + "_meta",
                                                meta_base_type)
Пример #3
0
 def __init__(self, rtyper, classdef):
     AbstractClassRepr.__init__(self, rtyper, classdef)
     if classdef is None:
         # 'object' root type
         self.vtable_type = OBJECT_VTABLE
     else:
         self.vtable_type = lltype.ForwardReference()
     self.lowleveltype = Ptr(self.vtable_type)
Пример #4
0
 def __init__(self, rtyper, classdef):
     AbstractClassRepr.__init__(self, rtyper, classdef)
     if classdef is None:
         # 'object' root type
         self.vtable_type = OBJECT_VTABLE
     else:
         self.vtable_type = lltype.ForwardReference()
     self.lowleveltype = Ptr(self.vtable_type)
Пример #5
0
    def __init__(self, rtyper, classdef):
        AbstractClassRepr.__init__(self, rtyper, classdef)

        if self.classdef is not None:
            self.rbase = getclassrepr(self.rtyper, self.classdef.basedef)
            base_type = self.rbase.lowleveltype
            self.lowleveltype = ootype.Instance(
                    self.classdef.name + "_meta", base_type)
        else:
            # we are ROOT
            self.lowleveltype = CLASSTYPE
Пример #6
0
    def __init__(self, rtyper, classdef):
        AbstractClassRepr.__init__(self, rtyper, classdef)

        if self.classdef is not None:
            self.rbase = getclassrepr(self.rtyper, self.classdef.basedef)
            base_type = self.rbase.lowleveltype
            self.lowleveltype = ootype.Instance(self.classdef.name + "_meta",
                                                base_type)
        else:
            # we are ROOT
            self.lowleveltype = CLASSTYPE