[pypy-svn] r64777 - in pypy/branch/pyjitpl5/pypy/rpython: ootypesystem test

antocuni at codespeak.net antocuni at codespeak.net
Tue Apr 28 16:13:23 CEST 2009


Author: antocuni
Date: Tue Apr 28 16:13:23 2009
New Revision: 64777

Modified:
   pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/ooopimpl.py
   pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/rootype.py
   pypy/branch/pyjitpl5/pypy/rpython/test/test_rclass.py
Log:
merge r54816 from oo-jit/
      svn merge svn+ssh://codespeak.net/svn/pypy/branch/oo-jit/pypy/ -r54815:54816

      implement rtype_is_true for ootype.Object



Modified: pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/ooopimpl.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/ooopimpl.py	(original)
+++ pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/ooopimpl.py	Tue Apr 28 16:13:23 2009
@@ -53,7 +53,10 @@
 
 
 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/pyjitpl5/pypy/rpython/ootypesystem/rootype.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/rootype.py	(original)
+++ pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/rootype.py	Tue Apr 28 16:13:23 2009
@@ -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/pyjitpl5/pypy/rpython/test/test_rclass.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/test/test_rclass.py	(original)
+++ pypy/branch/pyjitpl5/pypy/rpython/test/test_rclass.py	Tue Apr 28 16:13:23 2009
@@ -870,3 +870,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-commit mailing list