[pypy-svn] r54879 - in pypy/branch/oo-jit/pypy: annotation jit/codegen/cli jit/codegen/test

antocuni at codespeak.net antocuni at codespeak.net
Sun May 18 10:53:47 CEST 2008


Author: antocuni
Date: Sun May 18 10:53:47 2008
New Revision: 54879

Modified:
   pypy/branch/oo-jit/pypy/annotation/builtin.py
   pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py
   pypy/branch/oo-jit/pypy/jit/codegen/test/rgenop_tests.py
Log:
fix the annotation of cast_from_object; simplify the various
revealconst().  More steps toward making
test_gencli_portal.test_very_simple passing.



Modified: pypy/branch/oo-jit/pypy/annotation/builtin.py
==============================================================================
--- pypy/branch/oo-jit/pypy/annotation/builtin.py	(original)
+++ pypy/branch/oo-jit/pypy/annotation/builtin.py	Sun May 18 10:53:47 2008
@@ -575,7 +575,7 @@
 def cast_from_object(T, obj):
     TYPE = T.const
     if TYPE is ootype.Object:
-        return T
+        return SomeOOObject()
     elif isinstance(TYPE, ootype.Instance):
         return SomeOOInstance(TYPE)
     elif isinstance(TYPE, ootype.Record):

Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py	Sun May 18 10:53:47 2008
@@ -1,6 +1,7 @@
 from pypy.tool.pairtype import extendabletype
 from pypy.rlib.rarithmetic import intmask
 from pypy.rpython.ootypesystem import ootype
+from pypy.rpython.lltypesystem import lltype
 from pypy.rlib.objectmodel import specialize
 from pypy.jit.codegen.model import AbstractRGenOp, GenBuilder, GenLabel
 from pypy.jit.codegen.model import GenVarOrConst, GenVar, GenConst, CodeGenSwitch
@@ -96,14 +97,9 @@
 
     @specialize.arg(1)
     def revealconst(self, T):
-        if T is ootype.Signed:
-            return self.value
-        elif T is ootype.Bool:
-            return bool(self.value)
-        elif T is ootype.Char:
-            return chr(self.value)
-        else:
-            assert False
+        if T is ootype.Object:
+            return ootype.NULL # XXX?
+        return lltype.cast_primitive(T, self.value)
 
     def getCliType(self):
         return class2type(self.cliclass)
@@ -122,8 +118,9 @@
 
     @specialize.arg(1)
     def revealconst(self, T):
-        assert T is ootype.Float
-        return self.value
+        if T is ootype.Object:
+            return ootype.NULL # XXX?
+        return lltype.cast_primitive(T, self.value)
 
     def getCliType(self):
         return typeof(System.Double)
@@ -161,7 +158,7 @@
 
     def getCliType(self):
         if self.obj == ootype.NULL:
-            return cObject
+            return class2type(cObject)
         cliobj = dotnet.cast_to_native_object(self.obj)
         return cliobj.GetType()
 
@@ -169,21 +166,22 @@
         return self.obj
 
     def load(self, builder):
-        import pdb;pdb.set_trace()
-        index = self._get_index(builder)
-        if self.obj is None:
-            t = typeof(System.Object)
-        else:
-            t = self.obj.GetType()
-        self._load_from_array(builder, index, t)
+        assert False, 'XXX'
+##        import pdb;pdb.set_trace()
+##        index = self._get_index(builder)
+##        if self.obj is None:
+##            t = typeof(System.Object)
+##        else:
+##            t = self.obj.GetType()
+##        self._load_from_array(builder, index, t)
 
     @specialize.arg(1)
     def revealconst(self, T):
-        if T is ootype.Signed:
-            return ootype.ooidentityhash(self.obj)
-        elif T is ootype.Unsigned:
-            return intmask(ootype.ooidentityhash(self.obj))
-        return ootype.cast_from_object(T, self.obj)
+        if isinstance(T, ootype.OOType):
+            return ootype.cast_from_object(T, self.obj)
+        else:
+            h = ootype.ooidentityhash(self.obj)
+            return lltype.cast_primitive(T, h)
 
 
 OBJECT = System.Object._INSTANCE

Modified: pypy/branch/oo-jit/pypy/jit/codegen/test/rgenop_tests.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/test/rgenop_tests.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/test/rgenop_tests.py	Sun May 18 10:53:47 2008
@@ -2242,7 +2242,7 @@
         if self.T.__name__ == 'LLType':
             assert gv.revealconst(llmemory.Address) == llmemory.NULL
         else:
-            assert gv.revealconst(ootype.ROOT) == ootype.null(ootype.ROOT)
+            assert gv.revealconst(ootype.Object) == ootype.null(ootype.Object)
 
     def test_ovfcheck_adder_direct(self):
         rgenop = self.RGenOp()



More information about the Pypy-commit mailing list