[pypy-svn] r54317 - pypy/branch/oo-jit/pypy/rpython
antocuni at codespeak.net
antocuni at codespeak.net
Fri May 2 14:01:59 CEST 2008
Author: antocuni
Date: Fri May 2 14:01:57 2008
New Revision: 54317
Modified:
pypy/branch/oo-jit/pypy/rpython/annlowlevel.py
Log:
forgot to checkin this in in r54301; make cast_object_to_ptr and
cast_base_ptr_to_instance ootype-friendly
Modified: pypy/branch/oo-jit/pypy/rpython/annlowlevel.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/annlowlevel.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/annlowlevel.py Fri May 2 14:01:57 2008
@@ -472,28 +472,51 @@
return cast_object_to_ptr(base_ptr_lltype(), instance)
cast_instance_to_base_ptr._annspecialcase_ = 'specialize:argtype(0)'
+def cast_instance_to_base_obj(instance):
+ return cast_object_to_ptr(base_obj_ootype(), instance)
+cast_instance_to_base_obj._annspecialcase_ = 'specialize:argtype(0)'
+
def base_ptr_lltype():
from pypy.rpython.lltypesystem.rclass import OBJECTPTR
return OBJECTPTR
+def base_obj_ootype():
+ from pypy.rpython.ootypesystem.rclass import OBJECT
+ return OBJECT
+
class CastObjectToPtrEntry(extregistry.ExtRegistryEntry):
_about_ = cast_object_to_ptr
def compute_result_annotation(self, s_PTR, s_object):
assert s_PTR.is_constant()
- assert isinstance(s_PTR.const, lltype.Ptr)
- return annmodel.SomePtr(s_PTR.const)
+ if isinstance(s_PTR.const, lltype.Ptr):
+ return annmodel.SomePtr(s_PTR.const)
+ elif isinstance(s_PTR.const, ootype.Instance):
+ return annmodel.SomeOOInstance(s_PTR.const)
+ else:
+ assert False
def specialize_call(self, hop):
from pypy.rpython import rpbc
PTR = hop.r_result.lowleveltype
+ if isinstance(PTR, lltype.Ptr):
+ T = lltype.Ptr
+ opname = 'cast_pointer'
+ null = lltype.nullptr(PTR.TO)
+ elif isinstance(PTR, ootype.Instance):
+ T = ootype.Instance
+ opname = 'ooupcast'
+ null = ootype.null(PTR)
+ else:
+ assert False
+
if isinstance(hop.args_r[1], rpbc.NoneFrozenPBCRepr):
- return hop.inputconst(PTR, lltype.nullptr(PTR.TO))
+ return hop.inputconst(PTR, null)
v_arg = hop.inputarg(hop.args_r[1], arg=1)
- assert isinstance(v_arg.concretetype, lltype.Ptr)
+ assert isinstance(v_arg.concretetype, T)
hop.exception_cannot_occur()
- return hop.genop('cast_pointer', [v_arg],
- resulttype = PTR)
+ return hop.genop(opname, [v_arg], resulttype = PTR)
+
# ____________________________________________________________
@@ -510,13 +533,19 @@
def specialize_call(self, hop):
v_arg = hop.inputarg(hop.args_r[1], arg=1)
- assert isinstance(v_arg.concretetype, lltype.Ptr)
+ if isinstance(v_arg.concretetype, lltype.Ptr):
+ opname = 'cast_pointer'
+ elif isinstance(v_arg.concretetype, ootype.Instance):
+ opname = 'ooupcast'
+ else:
+ assert False
hop.exception_cannot_occur()
- return hop.genop('cast_pointer', [v_arg],
+ return hop.genop(opname, [v_arg],
resulttype = hop.r_result.lowleveltype)
# ____________________________________________________________
+
def placeholder_sigarg(s):
if s == "self":
def expand(s_self, *args_s):
More information about the Pypy-commit
mailing list