[pypy-commit] pypy default: Progress.
arigo
noreply at buildbot.pypy.org
Wed Dec 7 17:39:59 CET 2011
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r50256:ac541142ddcd
Date: 2011-12-07 12:57 +0100
http://bitbucket.org/pypy/pypy/changeset/ac541142ddcd/
Log: 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
@@ -3,6 +3,7 @@
from pypy.annotation.model import SomeInstance, s_None
from pypy.rpython.extregistry import ExtRegistryEntry
from pypy.rpython.lltypesystem import lltype
+from pypy.tool.sourcetools import compile2, func_with_new_name
def is_root(w_obj):
@@ -12,7 +13,8 @@
_about_ = is_root
def compute_result_annotation(self, s_w_obj):
- s_inst = SomeInstance(self.bookkeeper.getuniqueclassdef(W_Root))
+ s_inst = SomeInstance(self.bookkeeper.getuniqueclassdef(W_Root),
+ can_be_None=True)
assert s_inst.contains(s_w_obj)
return s_None
@@ -33,7 +35,19 @@
driver.setup(func, argtypes)
driver.proceed(['rtype_lltype'])
- def add(self, w_x, w_y):
- is_root(w_x)
- is_root(w_y)
- return W_Root()
+
+def setup():
+ for (name, _, arity, _) in ObjSpace.MethodTable:
+ args = ['w_%d' % i for i in range(arity)]
+ d = {'is_root': is_root,
+ 'W_Root': W_Root}
+ exec compile2("""\
+ def meth(self, %s):
+ %s
+ return W_Root()
+ """ % (', '.join(args),
+ '; '.join(['is_root(%s)' % arg for arg in args]))) in d
+ meth = func_with_new_name(d['meth'], name)
+ setattr(FakeObjSpace, name, meth)
+
+setup()
diff --git a/pypy/objspace/fake/test/test_objspace.py b/pypy/objspace/fake/test/test_objspace.py
--- a/pypy/objspace/fake/test/test_objspace.py
+++ b/pypy/objspace/fake/test/test_objspace.py
@@ -1,4 +1,5 @@
-from pypy.objspace.fake.objspace import FakeObjSpace
+from pypy.objspace.fake.objspace import FakeObjSpace, W_Root
+from pypy.rlib.unroll import unrolling_iterable
def test_create():
FakeObjSpace()
@@ -11,3 +12,18 @@
def test_simple(self):
space = self.space
space.translates(lambda w_x, w_y: space.add(w_x, w_y))
+
+ def test_methodtable(self):
+ space = self.space
+ for fixed_arity in [1, 2, 3, 4]:
+ #
+ methodtable = [name for (name, _, arity, _) in space.MethodTable
+ if arity == fixed_arity]
+ methodtable = unrolling_iterable(methodtable)
+ args_w = (W_Root(),) * fixed_arity
+ #
+ def f():
+ for name in methodtable:
+ getattr(space, name)(*args_w)
+ #
+ space.translates(f)
More information about the pypy-commit
mailing list