[pypy-svn] r54268 - in pypy/branch/oo-jit/pypy/rpython: ootypesystem test
antocuni at codespeak.net
antocuni at codespeak.net
Wed Apr 30 13:46:48 CEST 2008
Author: antocuni
Date: Wed Apr 30 13:46:47 2008
New Revision: 54268
Modified:
pypy/branch/oo-jit/pypy/rpython/ootypesystem/ooopimpl.py
pypy/branch/oo-jit/pypy/rpython/ootypesystem/rootype.py
pypy/branch/oo-jit/pypy/rpython/test/test_rclass.py
Log:
implement rtype_is_true for ootype.Object
Modified: pypy/branch/oo-jit/pypy/rpython/ootypesystem/ooopimpl.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/ootypesystem/ooopimpl.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/ootypesystem/ooopimpl.py Wed Apr 30 13:46:47 2008
@@ -56,7 +56,10 @@
return getattr(inst, name)
def is_inst(inst):
- return isinstance(ootype.typeOf(inst), (ootype.Instance, ootype.BuiltinType, ootype.StaticMethod))
+ T = ootype.typeOf(inst)
+ return T is ootype.Object or isinstance(T, (ootype.Instance,
+ ootype.BuiltinType,
+ ootype.StaticMethod,))
def checkinst(inst):
assert is_inst(inst)
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 Apr 30 13:46:47 2008
@@ -38,6 +38,10 @@
class OOObjectRepr(Repr):
lowleveltype = Object
+
+ def rtype_is_true(self, hop):
+ vlist = hop.inputargs(self)
+ return hop.genop('oononnull', vlist, resulttype=ootype.Bool)
ooobject_repr = OOObjectRepr()
Modified: pypy/branch/oo-jit/pypy/rpython/test/test_rclass.py
==============================================================================
--- pypy/branch/oo-jit/pypy/rpython/test/test_rclass.py (original)
+++ pypy/branch/oo-jit/pypy/rpython/test/test_rclass.py Wed Apr 30 13:46:47 2008
@@ -842,3 +842,13 @@
assert ootype.cast_from_object(A, obj1) == a
assert ootype.cast_from_object(B, obj2) == b
self.interpret(fn_null, [])
+
+ def fn_is_true(flag):
+ if flag:
+ a = ootype.new(A)
+ else:
+ a = ootype.null(A)
+ obj = ootype.cast_to_object(a)
+ return bool(obj)
+ assert self.interpret(fn_is_true, [True]) is True
+ assert self.interpret(fn_is_true, [False]) is False
More information about the pypy-svn
mailing list