[pypy-svn] r15685 - in pypy/dist/pypy/rpython/memory: . test
cfbolz at codespeak.net
cfbolz at codespeak.net
Fri Aug 5 14:45:17 CEST 2005
Author: cfbolz
Date: Fri Aug 5 14:45:16 2005
New Revision: 15685
Modified:
pypy/dist/pypy/rpython/memory/lltypesimulation.py
pypy/dist/pypy/rpython/memory/test/test_lltypesimulation.py
Log:
oops, bug in _expose. Fix plus test (plus change in repr of
simulatorptr, hex address look very memoryly but...).
Modified: pypy/dist/pypy/rpython/memory/lltypesimulation.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/lltypesimulation.py (original)
+++ pypy/dist/pypy/rpython/memory/lltypesimulation.py Fri Aug 5 14:45:16 2005
@@ -72,7 +72,7 @@
elif isinstance(T, lltype.Primitive):
return address._load(primitive_to_fmt[T])[0]
elif isinstance(T, lltype.Ptr):
- return simulatorptr(T, address)
+ return simulatorptr(T, address.address[0])
else:
assert 0, "not implemented yet"
@@ -155,7 +155,7 @@
if T2 != T1:
raise TypeError("%r items:\n"
"expect %r\n"
- " got %r" % (self._T, T1, T2))
+ " got %r" % (self._T, T1, T2))
if not (0 <= i < self._address.signed[0]):
raise IndexError, "array index out of bounds"
if isinstance(T2, lltype.Ptr):
@@ -182,10 +182,7 @@
return self._address == other._address
def __repr__(self):
- addr = self._address.intaddress
- if addr < 0:
- addr += 256 ** struct.calcsize("P")
- return '<simulatorptr %s to 0x%x>' % (self._TYPE.TO, addr)
+ return '<simulatorptr %s to %s>' % (self._TYPE.TO, self._address)
def cast_pointer(PTRTYPE, ptr):
Modified: pypy/dist/pypy/rpython/memory/test/test_lltypesimulation.py
==============================================================================
--- pypy/dist/pypy/rpython/memory/test/test_lltypesimulation.py (original)
+++ pypy/dist/pypy/rpython/memory/test/test_lltypesimulation.py Fri Aug 5 14:45:16 2005
@@ -237,6 +237,19 @@
a[2].v = 3
assert [a[z].v for z in range(3)] == [1, 2, 3]
+def test_array_of_ptr_to_bigger_struct():
+ S = lltype.GcStruct("name", ("v1", lltype.Signed), ("v2", lltype.Signed))
+ A = lltype.GcArray(lltype.Ptr(S))
+ a = malloc(A, 3)
+ assert not a[0]
+ assert not a[1]
+ a[0] = malloc(S)
+ a[0].v1 = 1
+ a[0].v2 = 2
+ assert a[0].v1 == 1
+ assert a[0].v2 == 2
+ assert not a[1]
+
def DONOTtest_getRuntimeTypeInfo():
S = GcStruct('s', ('x', Signed))
py.test.raises(ValueError, "getRuntimeTypeInfo(S)")
More information about the Pypy-commit
mailing list