Author: Ronan Lamy <ronan.l...@gmail.com> Branch: ClassRepr Changeset: r73935:189f16644e3a Date: 2014-10-14 00:04 +0100 http://bitbucket.org/pypy/pypy/changeset/189f16644e3a/
Log: store repr and extra_access_sets on the ClassDef object diff --git a/rpython/annotator/classdef.py b/rpython/annotator/classdef.py --- a/rpython/annotator/classdef.py +++ b/rpython/annotator/classdef.py @@ -154,6 +154,8 @@ self.subdefs = [] self.attr_sources = {} # {name: list-of-sources} self.read_locations_of__class__ = {} + self.repr = None + self.extra_access_sets = {} if classdesc.basedesc: self.basedef = classdesc.basedesc.getuniqueclassdef() diff --git a/rpython/rtyper/normalizecalls.py b/rpython/rtyper/normalizecalls.py --- a/rpython/rtyper/normalizecalls.py +++ b/rpython/rtyper/normalizecalls.py @@ -236,9 +236,8 @@ if commonbase is None: raise TyperError("reading attribute %r: no common base " "class for %r" % (attrname, descs.keys())) - extra_access_sets = rtyper.class_pbc_attributes.setdefault( - commonbase, {}) - if commonbase in rtyper.class_reprs: + extra_access_sets = commonbase.extra_access_sets + if commonbase.repr is not None: assert access_set in extra_access_sets # minimal sanity check continue access_set.commonbase = commonbase diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py --- a/rpython/rtyper/rclass.py +++ b/rpython/rtyper/rclass.py @@ -65,11 +65,9 @@ def getclassrepr(rtyper, classdef): if classdef is None: return rtyper.rootclass_repr - try: - result = rtyper.class_reprs[classdef] - except KeyError: - result = ClassRepr(rtyper, classdef) - rtyper.class_reprs[classdef] = result + result = classdef.repr + if result is None: + result = classdef.repr = ClassRepr(rtyper, classdef) rtyper.add_pendingsetup(result) return result @@ -266,8 +264,7 @@ clsfields[name] = mangled_name, r llfields.append((mangled_name, r.lowleveltype)) # attributes showing up in getattrs done on the class as a PBC - extra_access_sets = self.rtyper.class_pbc_attributes.get( - self.classdef, {}) + extra_access_sets = self.classdef.extra_access_sets for access_set, (attr, counter) in extra_access_sets.items(): r = self.rtyper.getrepr(access_set.s_value) mangled_name = mangle('pbc%d' % counter, attr) diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py --- a/rpython/rtyper/rtyper.py +++ b/rpython/rtyper/rtyper.py @@ -44,7 +44,6 @@ self._reprs_must_call_setup = [] self._seen_reprs_must_call_setup = {} self._dict_traits = {} - self.class_reprs = {} self.rootclass_repr = RootClassRepr(self) self.rootclass_repr.setup() self.instance_reprs = {} @@ -54,7 +53,6 @@ self.wrapper_context = None # or add an extra arg to convertvar? self.classdef_to_pytypeobject = {} self.concrete_calltables = {} - self.class_pbc_attributes = {} self.cache_dummy_values = {} self.lltype2vtable = {} self.typererrors = [] _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit