[pypy-svn] r65081 - in pypy/branch/pyjitpl5/pypy/jit/metainterp: . test
antocuni at codespeak.net
antocuni at codespeak.net
Wed May 6 11:05:20 CEST 2009
Author: antocuni
Date: Wed May 6 11:05:20 2009
New Revision: 65081
Modified:
pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
Log:
implement oostring for instances
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/support.py Wed May 6 11:05:20 2009
@@ -244,6 +244,9 @@
def _ll_1_oostring_string_foldable(s):
return ootype.oostring(s, -1)
+ def _ll_1_oostring_root_foldable(s):
+ return ootype.oostring(s, -1)
+
def _ll_2_oounicode_signed_foldable(n, base):
return ootype.oounicode(n, base)
@@ -315,6 +318,8 @@
args = op.args[:-1]
else:
args = op.args
+ if isinstance(T, ootype.Instance):
+ T = ootype.ROOT
return '%s_%s_foldable' % (op.opname, T._name.lower()), args
def get_oohash_oopspec(op):
Modified: pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py (original)
+++ pypy/branch/pyjitpl5/pypy/jit/metainterp/test/test_basic.py Wed May 6 11:05:20 2009
@@ -628,6 +628,20 @@
res = self.interp_operations(f, [1])
assert res
+ def test_oostring_instance(self):
+ A = ootype.Instance("A", ootype.ROOT)
+ B = ootype.Instance("B", ootype.ROOT)
+ def f(n):
+ obj1 = ootype.new(A)
+ obj2 = ootype.new(B)
+ s1 = ootype.oostring(obj1, -1)
+ s2 = ootype.oostring(obj2, -1)
+ ch1 = s1.ll_stritem_nonneg(1)
+ ch2 = s2.ll_stritem_nonneg(1)
+ return ord(ch1) + ord(ch2)
+ res = self.interp_operations(f, [0])
+ assert res == ord('A') + ord('B')
+
def test_r_dict(self):
py.test.skip('in-progress')
More information about the Pypy-commit
mailing list