[pypy-svn] r14561 - in pypy/dist/pypy/rpython: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Jul 12 19:52:43 CEST 2005
Author: arigo
Date: Tue Jul 12 19:52:42 2005
New Revision: 14561
Modified:
pypy/dist/pypy/rpython/rpbc.py
pypy/dist/pypy/rpython/test/test_rpbc.py
Log:
Calling memo functions with a PBC argument that is a ClassesPBCRepr (as
opposed to a MultipleFrozenPBCRepr).
Modified: pypy/dist/pypy/rpython/rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/rpbc.py (original)
+++ pypy/dist/pypy/rpython/rpbc.py Tue Jul 12 19:52:42 2005
@@ -517,8 +517,10 @@
else:
attr = hop.args_s[1].const
vcls, vattr = hop.inputargs(self, Void)
- return self.class_repr.getpbcfield(vcls, self.access_set, attr,
- hop.llops)
+ return self.getfield(vcls, attr, hop.llops)
+
+ def getfield(self, vcls, attr, llops):
+ return self.class_repr.getpbcfield(vcls, self.access_set, attr, llops)
# ____________________________________________________________
@@ -528,6 +530,6 @@
assert hop.nb_args == 2, "XXX"
r_pbc = hop.args_r[1]
- assert isinstance(r_pbc, MultipleFrozenPBCRepr)
+ assert isinstance(r_pbc, (MultipleFrozenPBCRepr, ClassesPBCRepr))
v_table, v_pbc = hop.inputargs(Void, r_pbc)
return r_pbc.getfield(v_pbc, fieldname, hop.llops)
Modified: pypy/dist/pypy/rpython/test/test_rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rpbc.py (original)
+++ pypy/dist/pypy/rpython/test/test_rpbc.py Tue Jul 12 19:52:42 2005
@@ -250,6 +250,25 @@
res = interpret(f1, [1])
assert res == 7
+def test_call_memo_with_class():
+ class A: pass
+ class FooBar(A): pass
+ def memofn(cls):
+ return len(cls.__name__)
+ memofn._annspecialcase_ = "specialize:memo"
+
+ def f1(i):
+ if i == 1:
+ cls = A
+ else:
+ cls = FooBar
+ FooBar() # make sure we have ClassDefs
+ return memofn(cls)
+ res = interpret(f1, [1])
+ assert res == 1
+ res = interpret(f1, [2])
+ assert res == 6
+
def test_rpbc_bound_method_static_call():
class R:
def meth(self):
More information about the Pypy-commit
mailing list