[pypy-svn] r34118 - in pypy/dist/pypy/rpython: . lltypesystem
arigo at codespeak.net
arigo at codespeak.net
Fri Nov 3 16:27:22 CET 2006
Author: arigo
Date: Fri Nov 3 16:27:21 2006
New Revision: 34118
Modified:
pypy/dist/pypy/rpython/lltypesystem/opimpl.py
pypy/dist/pypy/rpython/rlist.py
Log:
(Re-)introduce asserts in rlist.py.
Modified: pypy/dist/pypy/rpython/lltypesystem/opimpl.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/opimpl.py (original)
+++ pypy/dist/pypy/rpython/lltypesystem/opimpl.py Fri Nov 3 16:27:21 2006
@@ -362,7 +362,12 @@
def op_debug_assert(expr, *ll_args):
if not isinstance(expr, str):
- expr = ''.join(expr.chars)
+ if hasattr(expr, 'chars'): # for lltypesystem
+ expr = ''.join(expr.chars)
+ elif hasattr(expr, '_str'): # for ootypesystem
+ expr = expr._str
+ else:
+ raise TypeError("what is %r??" % (expr,))
names = ['v%d' % i for i in range(len(ll_args))]
d = dict(zip(names, ll_args))
names = tuple(names)
Modified: pypy/dist/pypy/rpython/rlist.py
==============================================================================
--- pypy/dist/pypy/rpython/rlist.py (original)
+++ pypy/dist/pypy/rpython/rlist.py Fri Nov 3 16:27:21 2006
@@ -6,6 +6,7 @@
from pypy.rpython.rslice import AbstractSliceRepr
from pypy.rpython.lltypesystem.lltype import typeOf, Ptr, Void, Signed, Bool
from pypy.rpython.lltypesystem.lltype import nullptr, Char, UniChar
+from pypy.rpython.lltypesystem.lloperation import llop
from pypy.rpython import robject
from pypy.rlib.objectmodel import malloc_zero_filled
from pypy.rpython.annlowlevel import ADTInterface
@@ -639,7 +640,8 @@
def ll_listslice_minusone(RESLIST, l1):
newlength = l1.ll_length() - 1
- #assert newlength >= 0 # XXX assert doesn't work in ootypesystem
+ llop.debug_assert(Void, "%s >= 0 # empty list is sliced with [:-1]",
+ newlength)
l = RESLIST.ll_newlist(newlength)
j = 0
while j < newlength:
@@ -680,8 +682,9 @@
def ll_listsetslice(l1, slice, l2):
count = l2.ll_length()
- # XXX: assert doesn't work in ootypesystem
- #assert count == slice.stop - slice.start, "setslice cannot resize lists in RPython")
+ llop.debug_assert(Void,
+ "%s == %s - %s # setslice cannot resize lists in RPython",
+ count, slice.stop, slice.start)
# XXX but it should be easy enough to support, soon
start = slice.start
j = start
More information about the pypy-svn
mailing list