[pypy-svn] pypy default: (arigo, mfoord, fijal) Add a checker for annotation of data

fijal commits-noreply at bitbucket.org
Tue Jan 18 14:25:03 CET 2011


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r40850:a14b1db84378
Date: 2011-01-18 15:14 +0200
http://bitbucket.org/pypy/pypy/changeset/a14b1db84378/

Log:	(arigo, mfoord, fijal) Add a checker for annotation of data

diff --git a/pypy/jit/metainterp/test/test_optimizeopt.py b/pypy/jit/metainterp/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/test/test_optimizeopt.py
@@ -552,21 +552,46 @@
         """
         self.optimize_loop(ops, expected, preamble)
 
+    def test_bound_int_is_true(self):
+        ops = """
+        [i0]
+        i1 = int_add(i0, 1)
+        i2 = int_gt(i1, 0)
+        guard_true(i2) []
+        i3 = int_is_true(i1)
+        guard_true(i3) []
+        jump(i1)
+        """
+        expected = """
+        [i0]
+        i1 = int_add(i0, 1)
+        jump(i1)
+        """
+        preamble = """
+        [i0]
+        i1 = int_add(i0, 1)
+        i2 = int_gt(i1, 0)
+        guard_true(i2) []
+        jump(i1)
+        """
+        self.optimize_loop(ops, expected, preamble)
+
     def test_int_is_true_is_zero(self):
-        py.test.skip("XXX implement me")
         ops = """
         [i0]
-        i1 = int_is_true(i0)
-        guard_true(i1) []
-        i2 = int_is_zero(i0)
-        guard_false(i2) []
-        jump(i0)
+        i1 = int_add(i0, 1)
+        i2 = int_is_true(i1)
+        guard_true(i2) []
+        i3 = int_is_zero(i1)
+        guard_false(i3) []
+        jump(i1)
         """
         expected = """
         [i0]
-        i1 = int_is_true(i0)
-        guard_true(i1) []
-        jump(i0)
+        i1 = int_add(i0, 1)
+        i2 = int_is_true(i1)
+        guard_true(i2) []
+        jump(i1)
         """
         self.optimize_loop(ops, expected)
 

diff --git a/pypy/objspace/std/bytearrayobject.py b/pypy/objspace/std/bytearrayobject.py
--- a/pypy/objspace/std/bytearrayobject.py
+++ b/pypy/objspace/std/bytearrayobject.py
@@ -5,6 +5,7 @@
 from pypy.objspace.std.multimethod import FailedToImplement
 from pypy.rlib.rarithmetic import intmask
 from pypy.rlib.rstring import StringBuilder
+from pypy.rlib.debug import check_annotation
 from pypy.objspace.std.intobject import W_IntObject
 from pypy.objspace.std.listobject import _delitem_slice_helper, _setitem_slice_helper
 from pypy.objspace.std.listtype import get_list_index
@@ -18,11 +19,17 @@
 from pypy.tool.sourcetools import func_with_new_name
 
 
+def bytearray_checker(s_arg, bookkeeper):
+    from pypy.annotation.model import SomeList, SomeChar, SomeImpossibleValue
+    assert isinstance(s_arg, SomeList)
+    assert isinstance(s_arg.listdef.listitem.s_value, (SomeChar, SomeImpossibleValue))
+
 class W_BytearrayObject(W_Object):
     from pypy.objspace.std.bytearraytype import bytearray_typedef as typedef
 
     def __init__(w_self, data):
         w_self.data = data
+        check_annotation(w_self.data, bytearray_checker)
 
     def __repr__(w_self):
         """ representation for debugging purposes """


More information about the Pypy-commit mailing list