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

antocuni at codespeak.net antocuni at codespeak.net
Tue May 5 13:44:08 CEST 2009


Author: antocuni
Date: Tue May  5 13:44:06 2009
New Revision: 65050

Modified:
   pypy/branch/pyjitpl5/pypy/annotation/builtin.py
   pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/rbuiltin.py
   pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/test/test_oortype.py
Log:
test&fix


Modified: pypy/branch/pyjitpl5/pypy/annotation/builtin.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/annotation/builtin.py	(original)
+++ pypy/branch/pyjitpl5/pypy/annotation/builtin.py	Tue May  5 13:44:06 2009
@@ -569,7 +569,8 @@
         raise AnnotatorError, 'Cannot cast %s to %s' % (i.ootype, I.const)
 
 def cast_to_object(obj):
-    assert isinstance(obj.ootype, ootype.OOType)
+    assert isinstance(obj.ootype, ootype.OOType) or \
+        (isinstance(obj, SomeOOClass) and obj.ootype is None)
     return SomeOOObject()
 
 def cast_from_object(T, obj):

Modified: pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/rbuiltin.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/rbuiltin.py	(original)
+++ pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/rbuiltin.py	Tue May  5 13:44:06 2009
@@ -60,7 +60,8 @@
     return hop.genop('oodowncast', [v_inst], resulttype = hop.r_result.lowleveltype)
 
 def rtype_cast_to_object(hop):
-    assert isinstance(hop.args_s[0].ootype, ootype.OOType)
+    assert isinstance(hop.args_s[0].ootype, ootype.OOType) or \
+        isinstance(hop.args_s[0], annmodel.SomeOOClass)
     v_inst = hop.inputarg(hop.args_r[0], arg=0)
     return hop.genop('cast_to_object', [v_inst], resulttype = hop.r_result.lowleveltype)
 

Modified: pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/test/test_oortype.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/test/test_oortype.py	(original)
+++ pypy/branch/pyjitpl5/pypy/rpython/ootypesystem/test/test_oortype.py	Tue May  5 13:44:06 2009
@@ -464,3 +464,10 @@
     assert not res
     res = interpret(fn, [1], type_system='ootype')
     assert res
+
+def test_cast_to_object_nullruntimeclass():
+    def fn():
+        return cast_to_object(nullruntimeclass)
+
+    res = interpret(fn, [], type_system='ootype')
+    assert cast_from_object(Class, res) == nullruntimeclass



More information about the Pypy-commit mailing list