Author: Armin Rigo <[email protected]>
Branch:
Changeset: r50263:391271fcc7f9
Date: 2011-12-07 15:27 +0100
http://bitbucket.org/pypy/pypy/changeset/391271fcc7f9/
Log: Still more progress.
diff --git a/pypy/objspace/fake/objspace.py b/pypy/objspace/fake/objspace.py
--- a/pypy/objspace/fake/objspace.py
+++ b/pypy/objspace/fake/objspace.py
@@ -1,5 +1,6 @@
-from pypy.interpreter.baseobjspace import W_Root, ObjSpace
+from pypy.interpreter.baseobjspace import W_Root, ObjSpace, SpaceCache
from pypy.interpreter import argument, gateway
+from pypy.interpreter.typedef import TypeDef
from pypy.annotation.model import SomeInstance, s_None
from pypy.rpython.extregistry import ExtRegistryEntry
from pypy.rpython.lltypesystem import lltype
@@ -106,11 +107,11 @@
def _see_interp2app(self, interp2app):
"NOT_RPYTHON"
activation = interp2app._code.activation
- scopelen = interp2app._code.sig.scope_length()
- scope_w = [W_Root()] * scopelen
def check():
+ scope_w = [W_Root()] * NonConstant(42)
w_result = activation._run(self, scope_w)
is_root(w_result)
+ check = func_with_new_name(check, 'check__' + interp2app.name)
self._seen_extras.append(check)
def call_args(self, w_func, args):
@@ -119,8 +120,10 @@
return W_Root()
def gettypefor(self, cls):
- assert issubclass(cls, W_Root)
- return W_Root()
+ return self.gettypeobject(cls.typedef)
+
+ def gettypeobject(self, typedef):
+ return self.fromcache(TypeCache).getorbuild(typedef)
def unpackiterable(self, w_iterable, expected_length=-1):
is_root(w_iterable)
@@ -137,11 +140,17 @@
argtypes = [W_Root] * nb_args
#
t = TranslationContext()
+ self.t = t # for debugging
ann = t.buildannotator()
if func is not None:
ann.build_types(func, argtypes)
- for check in self._seen_extras:
- ann.build_types(check, [])
+ # annotate all _seen_extras, knowing that annotating some may
+ # grow the list
+ i = 0
+ while i < len(self._seen_extras):
+ print self._seen_extras
+ ann.build_types(self._seen_extras[i], [])
+ i += 1
#t.viewcg()
t.buildrtyper().specialize()
t.checkgraphs()
@@ -170,3 +179,12 @@
assert hasattr(FakeObjSpace, name) # missing?
setup()
+
+# ____________________________________________________________
+
+class TypeCache(SpaceCache):
+ def build(cache, typedef):
+ assert isinstance(typedef, TypeDef)
+ for value in typedef.rawdict.values():
+ cache.space.wrap(value)
+ return W_Root()
diff --git a/pypy/objspace/fake/test/test_checkmodule.py
b/pypy/objspace/fake/test/test_checkmodule.py
--- a/pypy/objspace/fake/test/test_checkmodule.py
+++ b/pypy/objspace/fake/test/test_checkmodule.py
@@ -37,15 +37,20 @@
def test_gettypefor_untranslated():
- py.test.skip("in-progress")
+ see, check = make_checker()
class W_Foo(Wrappable):
- pass
+ def do_it(self, space, w_x):
+ is_root(w_x)
+ see()
+ return W_Root()
W_Foo.typedef = TypeDef('foo',
__module__ = 'barmod',
do_it = interp2app(W_Foo.do_it))
- see, check = make_checker()
space = FakeObjSpace()
space.gettypefor(W_Foo)
+ assert not check
+ space.translates()
+ assert check
def test_itertools_module():
checkmodule('itertools')
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit