[pypy-commit] pypy ClassRepr: Store the root class repr in rtyper.rootclass_repr
rlamy
noreply at buildbot.pypy.org
Mon Oct 13 16:04:50 CEST 2014
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: ClassRepr
Changeset: r73916:f4139c9bf4e4
Date: 2014-10-13 15:04 +0100
http://bitbucket.org/pypy/pypy/changeset/f4139c9bf4e4/
Log: Store the root class repr in rtyper.rootclass_repr
(having a None key in rtyper.class_reprs was just too weird)
diff --git a/rpython/rtyper/rclass.py b/rpython/rtyper/rclass.py
--- a/rpython/rtyper/rclass.py
+++ b/rpython/rtyper/rclass.py
@@ -63,13 +63,12 @@
def getclassrepr(rtyper, classdef):
+ if classdef is None:
+ return rtyper.rootclass_repr
try:
result = rtyper.class_reprs[classdef]
except KeyError:
- if classdef is None:
- result = RootClassRepr(rtyper)
- else:
- result = ClassRepr(rtyper, classdef)
+ result = ClassRepr(rtyper, classdef)
rtyper.class_reprs[classdef] = result
rtyper.add_pendingsetup(result)
return result
diff --git a/rpython/rtyper/rtyper.py b/rpython/rtyper/rtyper.py
--- a/rpython/rtyper/rtyper.py
+++ b/rpython/rtyper/rtyper.py
@@ -27,6 +27,8 @@
from rpython.rtyper.rmodel import Repr, inputconst, BrokenReprTyperError
from rpython.rtyper.typesystem import LowLevelTypeSystem, getfunctionptr
from rpython.rtyper.normalizecalls import perform_normalizations
+from rpython.rtyper import rclass
+from rpython.rtyper.rclass import RootClassRepr
from rpython.tool.pairtype import pair
from rpython.translator.unsimplify import insert_empty_block
@@ -43,6 +45,8 @@
self._seen_reprs_must_call_setup = {}
self._dict_traits = {}
self.class_reprs = {}
+ self.rootclass_repr = RootClassRepr(self)
+ self.add_pendingsetup(self.rootclass_repr)
self.instance_reprs = {}
self.type_for_typeptr = {}
self.pbc_reprs = {}
@@ -581,7 +585,6 @@
return rtype_newtuple(hop)
def translate_op_instantiate1(self, hop):
- from rpython.rtyper import rclass
if not isinstance(hop.s_result, annmodel.SomeInstance):
raise TyperError("instantiate1 got s_result=%r" % (hop.s_result,))
classdef = hop.s_result.classdef
@@ -944,7 +947,7 @@
from rpython.rtyper import rint, rbool, rfloat, rnone
from rpython.rtyper import rrange
from rpython.rtyper import rstr, rdict, rlist, rbytearray
-from rpython.rtyper import rclass, rbuiltin, rpbc
+from rpython.rtyper import rbuiltin, rpbc
from rpython.rtyper import rptr
from rpython.rtyper import rweakref
from rpython.rtyper import raddress # memory addresses
More information about the pypy-commit
mailing list