[pypy-svn] r17062 - in pypy/dist/pypy/rpython: . memory/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Mon Aug 29 20:26:22 CEST 2005
Author: cfbolz
Date: Mon Aug 29 20:26:20 2005
New Revision: 17062
Modified:
pypy/dist/pypy/rpython/memory/test/test_address.py
pypy/dist/pypy/rpython/raddress.py
Log:
rtyping for inplace ops for addresses
Modified: pypy/dist/pypy/rpython/memory/test/test_address.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_address.py (original)
+++ pypy/dist/pypy/rpython/memory/test/test_address.py Mon Aug 29 20:26:20 2005
@@ -238,6 +238,18 @@
res = interpret(f, [12, "x"])
assert res == "x"
+ def test_pointer_arithmetic_inplace(self):
+ def f(offset, char):
+ addr = raw_malloc(10000)
+ addr += offset
+ addr.char[-offset] = char
+ addr -= offset
+ return addr.char[0]
+ res = interpret(f, [10, "c"])
+ assert res == "c"
+ res = interpret(f, [12, "x"])
+ assert res == "x"
+
def test_address_comparison(self):
def f(offset):
return NULL < NULL + offset or NULL == NULL + offset
Modified: pypy/dist/pypy/rpython/raddress.py
==============================================================================
--- pypy/dist/pypy/rpython/raddress.py (original)
+++ pypy/dist/pypy/rpython/raddress.py Mon Aug 29 20:26:20 2005
@@ -69,6 +69,7 @@
return hop.genop('adr_add', [v_addr, v_offs], resulttype=Address)
return NotImplemented
+ rtype_inplace_add = rtype_add
def rtype_sub((r_addr, r_int), hop):
if r_int.lowleveltype == lltype.Signed:
@@ -76,6 +77,7 @@
return hop.genop('adr_sub', [v_addr, v_offs], resulttype=Address)
return NotImplemented
+ rtype_inplace_sub = rtype_sub
class __extend__(pairtype(AddressRepr, AddressRepr)):
More information about the Pypy-commit
mailing list