[pypy-svn] r32891 - in pypy/dist/pypy: annotation rpython/ootypesystem rpython/ootypesystem/test
fijal at codespeak.net
fijal at codespeak.net
Wed Oct 4 21:09:05 CEST 2006
Author: fijal
Date: Wed Oct 4 21:09:03 2006
New Revision: 32891
Modified:
pypy/dist/pypy/annotation/bookkeeper.py
pypy/dist/pypy/rpython/ootypesystem/bltregistry.py
pypy/dist/pypy/rpython/ootypesystem/test/test_bltann.py
Log:
(arigo, fijal) - Fix keeping cache of ExternalType's in class. Instead keep it in bookkeeper. Taking advantage of having bookkeeper as field for ExternalType.
Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py (original)
+++ pypy/dist/pypy/annotation/bookkeeper.py Wed Oct 4 21:09:03 2006
@@ -173,6 +173,7 @@
self.emulated_pbc_calls = {}
self.all_specializations = {} # {FuncDesc: specialization-info}
self.pending_specializations = [] # list of callbacks
+ self.external_class_cache = {} # cache of ExternalType classes
self.needs_hash_support = {}
self.needs_generic_instantiate = {}
@@ -687,6 +688,15 @@
except KeyError:
access_sets = map[attrname] = UnionFind(description.ClassAttrFamily)
return access_sets
+
+ def getexternaldesc(self, class_):
+ try:
+ return self.external_class_cache[class_]
+ except KeyError:
+ from pypy.rpython.ootypesystem.bltregistry import ExternalType
+ next = ExternalType(class_)
+ self.external_class_cache[class_] = next
+ return next
def pbc_getattr(self, pbc, s_attr):
assert s_attr.is_constant()
Modified: pypy/dist/pypy/rpython/ootypesystem/bltregistry.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/bltregistry.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/bltregistry.py Wed Oct 4 21:09:03 2006
@@ -168,14 +168,6 @@
def __hash__(self):
# FIXME: for now
return hash(self._name)
-
- def get(class_):
- try:
- return ExternalType.class_dict[class_]
- except KeyError:
- next = ExternalType(class_)
- ExternalType.class_dict[class_] = next
- return next
def set_field(self, attr, knowntype):
self.check_update()
@@ -210,7 +202,6 @@
## def _example(self):
## raise AttributeError()return new(self)
##
- get = staticmethod(get)
class _external_type(object):
@@ -221,7 +212,9 @@
_metatype_ = BasicMetaExternal
def compute_annotation(self):
- return annmodel.SomeExternalBuiltin(ExternalType.get(self.instance.__class__))
+ return annmodel.SomeExternalBuiltin(self.bookkeeper.getexternaldesc\
+ (self.instance.__class__))
+ #return annmodel.SomeExternalBuiltin(ExternalType.get(self.instance.__class__))
def get_field_annotation(self, ext_obj, attr):
return ext_obj.get_field(attr)
@@ -241,15 +234,16 @@
# return annmodel.SomeOOInstance(ootype=BasicExternal)
def compute_result_annotation(self):
- return annmodel.SomeExternalBuiltin(ExternalType.get(self.instance))
+ #return annmodel.SomeExternalBuiltin(ExternalType.get(self.instance))
+ return annmodel.SomeExternalBuiltin(self.bookkeeper.getexternaldesc(self.instance))
#Ereturn annmodel.SomeOOInstance(ExternalType.get(self.instance))
def specialize_call(self, hop):
#assert isinstance(hop.args_s[0], annmodel.SomeOOInstance)\
# and hop.args_s[0].ootype is Externaltype
- _class = hop.r_result.lowleveltype._class_
- return hop.genop('new', [Constant(ExternalType.get(_class), concretetype=ootype.Void)], \
- resulttype = ExternalType.get(_class))
+ value = hop.r_result.lowleveltype
+ return hop.genop('new', [Constant(value, concretetype=ootype.Void)], \
+ resulttype = value)
def rebuild_basic_external():
ExternalType.class_dict = {}
Modified: pypy/dist/pypy/rpython/ootypesystem/test/test_bltann.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/test/test_bltann.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/test/test_bltann.py Wed Oct 4 21:09:03 2006
@@ -86,7 +86,7 @@
return 3
def test_flowin():
- import py; py.test.skip("something is missing somewhere")
+ import py; py.test.skip("Indirect call is missing")
def set_callback():
a = CB()
a.m = some_int
More information about the Pypy-commit
mailing list