[pypy-svn] r26881 - in pypy/dist/pypy: annotation rpython rpython/test
arigo at codespeak.net
arigo at codespeak.net
Sat May 6 19:23:49 CEST 2006
Author: arigo
Date: Sat May 6 19:23:48 2006
New Revision: 26881
Modified:
pypy/dist/pypy/annotation/builtin.py
pypy/dist/pypy/rpython/rbuiltin.py
pypy/dist/pypy/rpython/test/test_rptr.py
Log:
Support for Ptr() calls in ll functions.
Modified: pypy/dist/pypy/annotation/builtin.py
==============================================================================
--- pypy/dist/pypy/annotation/builtin.py (original)
+++ pypy/dist/pypy/annotation/builtin.py Sat May 6 19:23:48 2006
@@ -455,6 +455,10 @@
assert isinstance(s_p, SomePtr), "runtime_type_info of non-pointer: %r" % s_p
return SomePtr(lltype.typeOf(lltype.runtime_type_info(s_p.ll_ptrtype._example())))
+def constPtr(T):
+ assert T.is_constant()
+ return immutablevalue(lltype.Ptr(T.const))
+
BUILTIN_ANALYZERS[lltype.malloc] = malloc
BUILTIN_ANALYZERS[lltype.typeOf] = typeOf
BUILTIN_ANALYZERS[lltype.cast_primitive] = cast_primitive
@@ -467,6 +471,7 @@
BUILTIN_ANALYZERS[lltype.cast_int_to_ptr] = cast_int_to_ptr
BUILTIN_ANALYZERS[lltype.getRuntimeTypeInfo] = getRuntimeTypeInfo
BUILTIN_ANALYZERS[lltype.runtime_type_info] = runtime_type_info
+BUILTIN_ANALYZERS[lltype.Ptr] = constPtr
# ootype
from pypy.annotation.model import SomeOOInstance, SomeOOClass
Modified: pypy/dist/pypy/rpython/rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/rbuiltin.py (original)
+++ pypy/dist/pypy/rpython/rbuiltin.py Sat May 6 19:23:48 2006
@@ -404,6 +404,7 @@
BUILTIN_TYPER[lltype.typeOf] = rtype_const_result
BUILTIN_TYPER[lltype.nullptr] = rtype_const_result
BUILTIN_TYPER[lltype.getRuntimeTypeInfo] = rtype_const_result
+BUILTIN_TYPER[lltype.Ptr] = rtype_const_result
BUILTIN_TYPER[lltype.runtime_type_info] = rtype_runtime_type_info
BUILTIN_TYPER[rarithmetic.intmask] = rtype_intmask
BUILTIN_TYPER[rarithmetic.r_uint] = rtype_r_uint
Modified: pypy/dist/pypy/rpython/test/test_rptr.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rptr.py (original)
+++ pypy/dist/pypy/rpython/test/test_rptr.py Sat May 6 19:23:48 2006
@@ -109,3 +109,12 @@
assert s == cast_pointer(PS, t)
interpret(fn, [11521])
+
+
+def test_Ptr():
+ S = GcStruct('s')
+ def ll_example():
+ return malloc(Ptr(S).TO)
+
+ p = interpret(ll_example, [])
+ assert typeOf(p) == Ptr(S)
More information about the Pypy-commit
mailing list