[pypy-svn] r59517 - in pypy/branch/oo-jit/pypy: annotation jit/rainbow rpython/ootypesystem
antocuni at codespeak.net
antocuni at codespeak.net
Wed Oct 29 13:42:38 CET 2008
Author: antocuni
Date: Wed Oct 29 13:42:36 2008
New Revision: 59517
Modified:
pypy/branch/oo-jit/pypy/annotation/unaryop.py
pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py
pypy/branch/oo-jit/pypy/rpython/ootypesystem/rootype.py
Log:
some rpython fixes, and add support for reading __class__ on a SomeOOInstance;
I'm not really sure that this is the way to go, but seems to work.
test_promote_class still fail, probably because of some other bug.
Modified: pypy/branch/oo-jit/pypy/annotation/unaryop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/annotation/unaryop.py (original)
+++ pypy/branch/oo-jit/pypy/annotation/unaryop.py Wed Oct 29 13:42:36 2008
@@ -658,6 +658,7 @@
# annotation of low-level types
from pypy.annotation.model import SomePtr, SomeLLADTMeth
from pypy.annotation.model import SomeOOInstance, SomeOOBoundMeth, SomeOOStaticMeth
+from pypy.annotation.model import SomeOOClass
from pypy.annotation.model import ll_to_annotation, lltype_to_annotation, annotation_to_lltype
class __extend__(SomePtr):
@@ -704,7 +705,10 @@
from pypy.rpython.ootypesystem import ootype
class __extend__(SomeOOInstance):
def getattr(r, s_attr):
+ from pypy.rpython.ootypesystem.rclass import CLASSTYPE
assert s_attr.is_constant(), "getattr on ref %r with non-constant field-name" % r.ootype
+ if s_attr.const == '__class__':
+ return SomeOOInstance(CLASSTYPE)
v = getattr(r.ootype._example(), s_attr.const)
if isinstance(v, ootype._bound_meth):
return SomeOOBoundMeth(r.ootype, s_attr.const)
Modified: pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py (original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/interpreter.py Wed Oct 29 13:42:36 2008
@@ -632,13 +632,14 @@
@arguments("red", "green", "fielddesc", "fielddesc", returns="red")
def opimpl_assert_class(self, objbox, gv_class, fielddesc, fielddesc2):
+ assert isinstance(objbox, rvalue.AbstractPtrRedBox)
if isinstance(objbox.content, rcontainer.VirtualStruct):
return objbox
classbox = self.PtrRedBox(gv_class)
objbox.remember_field(fielddesc, classbox)
# hack hack, see comments in codewriter.py
- if fielddesc2 != fielddesc:
+ if fielddesc2 is not fielddesc:
objbox.remember_field(fielddesc2, classbox)
return objbox
Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/rootype.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/rootype.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/rootype.py Wed Oct 29 13:42:36 2008
@@ -54,12 +54,21 @@
self.lowleveltype = ootype
def rtype_getattr(self, hop):
+ from pypy.rpython.ootypesystem.rclass import CLASSTYPE
attr = hop.args_s[1].const
s_inst = hop.args_s[0]
_, meth = self.lowleveltype._lookup(attr)
if meth is not None:
# just return instance - will be handled by simple_call
return hop.inputarg(hop.r_result, arg=0)
+ if attr == '__class__':
+ v_inst = hop.inputarg(hop.args_r[0], arg=0)
+ # this will work as soon as we merge the less-meta-instances branch
+ #return hop.genop('classof', [v_obj], resulttype = hop.r_result.lowleveltype)
+ cmeta = hop.inputconst(ootype.Void, "meta")
+ return hop.genop('oogetfield', [v_inst, cmeta],
+ resulttype=CLASSTYPE)
+
self.lowleveltype._check_field(attr)
vlist = hop.inputargs(self, Void)
return hop.genop("oogetfield", vlist,
More information about the Pypy-commit
mailing list