[pypy-svn] r32203 - in pypy/branch/more-gckinds/pypy/rpython: lltypesystem memory
mwh at codespeak.net
mwh at codespeak.net
Tue Sep 12 11:53:01 CEST 2006
Author: mwh
Date: Tue Sep 12 11:53:00 2006
New Revision: 32203
Modified:
pypy/branch/more-gckinds/pypy/rpython/lltypesystem/llmemory.py
pypy/branch/more-gckinds/pypy/rpython/lltypesystem/lltype.py
pypy/branch/more-gckinds/pypy/rpython/memory/convertlltype.py
Log:
add rawTypeOf that returns a real Ptr for _interior_ptrs.
use it in a few places, including fixing up that smelly fix to llmemory.
Modified: pypy/branch/more-gckinds/pypy/rpython/lltypesystem/llmemory.py
==============================================================================
--- pypy/branch/more-gckinds/pypy/rpython/lltypesystem/llmemory.py (original)
+++ pypy/branch/more-gckinds/pypy/rpython/lltypesystem/llmemory.py Tue Sep 12 11:53:00 2006
@@ -47,7 +47,7 @@
def ref(self, firstitemref):
assert isinstance(firstitemref, _arrayitemref)
array = firstitemref.array
- assert array._T.OF == self.TYPE
+ assert lltype.rawTypeOf(array).TO.OF == self.TYPE
index = firstitemref.index + self.repeat
return _arrayitemref(array, index)
@@ -76,7 +76,7 @@
def ref(self, containerref):
struct = containerref.get()
- if struct._T != self.TYPE:
+ if lltype.rawTypeOf(struct).TO != self.TYPE:
struct = lltype.cast_pointer(lltype.Ptr(self.TYPE), struct)
return _structfieldref(struct, self.fldname)
@@ -136,7 +136,7 @@
def ref(self, arrayref):
array = arrayref.get()
- assert array._T == self.TYPE
+ assert lltype.rawTypeOf(array).TO == self.TYPE
return _arrayitemref(array, index=0)
def raw_malloc(self, rest, parenttype=None):
@@ -164,7 +164,7 @@
def ref(self, arrayref):
array = arrayref.get()
- assert array._T == self.TYPE
+ assert lltype.rawTypeOf(array).TO == self.TYPE
return _arraylenref(array)
Modified: pypy/branch/more-gckinds/pypy/rpython/lltypesystem/lltype.py
==============================================================================
--- pypy/branch/more-gckinds/pypy/rpython/lltypesystem/lltype.py (original)
+++ pypy/branch/more-gckinds/pypy/rpython/lltypesystem/lltype.py Tue Sep 12 11:53:00 2006
@@ -678,6 +678,12 @@
return val.lltype()
raise TypeError("typeOf(%r object)" % (tp.__name__,))
+def rawTypeOf(val):
+ if isinstance(val, _interior_ptr):
+ return Ptr(val._T)
+ else:
+ return typeOf(val)
+
_to_primitive = {
Char: chr,
UniChar: unichr,
Modified: pypy/branch/more-gckinds/pypy/rpython/memory/convertlltype.py
==============================================================================
--- pypy/branch/more-gckinds/pypy/rpython/memory/convertlltype.py (original)
+++ pypy/branch/more-gckinds/pypy/rpython/memory/convertlltype.py Tue Sep 12 11:53:00 2006
@@ -34,7 +34,7 @@
self.query_types = qt
def convert(self, val_or_ptr, inline_to_ptr=None):
- TYPE = lltype.typeOf(val_or_ptr)
+ TYPE = lltype.rawTypeOf(val_or_ptr)
if isinstance(TYPE, lltype.Primitive):
assert inline_to_ptr is None
return get_real_value(val_or_ptr)
@@ -58,7 +58,7 @@
ptr = self.converted[_array]
assert inline_to_ptr is None or ptr == inline_to_ptr
return ptr
- TYPE = lltype.typeOf(_array)
+ TYPE = lltype.rawTypeOf(_array)
arraylength = len(_array.items)
size = sizeof(TYPE, arraylength)
if inline_to_ptr is not None:
@@ -95,7 +95,7 @@
return getattr(ptr, _struct._parent_index)
else:
return ptr[_struct._parent_index]
- TYPE = lltype.typeOf(_struct)
+ TYPE = lltype.rawTypeOf(_struct)
if TYPE._arrayfld is not None:
inlinedarraylength = len(getattr(_struct, TYPE._arrayfld).items)
size = sizeof(TYPE, inlinedarraylength)
@@ -127,7 +127,7 @@
def convert_pointer(self, _ptr, inline_to_ptr):
assert inline_to_ptr is None, "can't inline pointer"
- TYPE = lltype.typeOf(_ptr)
+ TYPE = lltype.rawTypeOf(_ptr)
if _ptr._obj is not None:
return self.convert(_ptr._obj)
else:
@@ -135,7 +135,7 @@
def convert_object(self, _obj, inline_to_ptr):
assert inline_to_ptr is None, "can't inline function or pyobject"
- return simulatorptr(lltype.Ptr(lltype.typeOf(_obj)),
+ return simulatorptr(lltype.Ptr(lltype.rawTypeOf(_obj)),
lladdress.get_address_of_object(_obj))
def collect_constants_and_types(graphs):
constants = {}
@@ -190,7 +190,7 @@
continue
elif isinstance(cand, str):
continue
- elif isinstance(lltype.typeOf(cand), lltype.Primitive):
+ elif isinstance(lltype.rawTypeOf(cand), lltype.Primitive):
continue
elif cand in seen:
continue
More information about the Pypy-commit
mailing list