[pypy-svn] r51429 - in pypy/dist/pypy: jit/codegen/cli translator/cli translator/cli/test

antocuni at codespeak.net antocuni at codespeak.net
Wed Feb 13 10:16:45 CET 2008


Author: antocuni
Date: Wed Feb 13 10:16:44 2008
New Revision: 51429

Modified:
   pypy/dist/pypy/jit/codegen/cli/rgenop.py
   pypy/dist/pypy/translator/cli/dotnet.py
   pypy/dist/pypy/translator/cli/test/test_dotnet.py
Log:
make the cli codegen using the new and better interface to handle dynamic delegates



Modified: pypy/dist/pypy/jit/codegen/cli/rgenop.py
==============================================================================
--- pypy/dist/pypy/jit/codegen/cli/rgenop.py	(original)
+++ pypy/dist/pypy/jit/codegen/cli/rgenop.py	Wed Feb 13 10:16:44 2008
@@ -14,6 +14,11 @@
 DUMP_IL = False
 DEBUG = False
 
+SM_INT__INT_1 = ootype.StaticMethod([ootype.Signed], ootype.Signed)
+SM_INT__INT_2 = ootype.StaticMethod([ootype.Signed] * 2, ootype.Signed)
+SM_INT__INT_3 = ootype.StaticMethod([ootype.Signed] * 3, ootype.Signed)
+SM_INT__INT_100 = ootype.StaticMethod([ootype.Signed] * 100, ootype.Signed)
+
 def token2clitype(tok):
     if tok == '<Signed>':
         return typeof(System.Int32)
@@ -22,13 +27,13 @@
 
 def sigtoken2clitype(tok):
     if tok == (['<Signed>'], '<Signed>'):
-        return typeof(CLR.pypy.runtime.DelegateType_int__int_1)
+        return typeof(SM_INT__INT_1)
     elif tok == (['<Signed>', '<Signed>'], '<Signed>'):
-        return typeof(CLR.pypy.runtime.DelegateType_int__int_2)
+        return typeof(SM_INT__INT_2)
     elif tok == (['<Signed>'] * 3, '<Signed>'):
-        return typeof(CLR.pypy.runtime.DelegateType_int__int_3)
+        return typeof(SM_INT__INT_3)
     elif tok == (['<Signed>'] * 100, '<Signed>'):
-        return typeof(CLR.pypy.runtime.DelegateType_int__int_100)
+        return typeof(SM_INT__INT_100)
     else:
         assert False
 
@@ -126,28 +131,11 @@
         il.Emit(OpCodes.Ldsfld, field)
 
 
-SM_INT__INT_1 = ootype.StaticMethod([ootype.Signed], ootype.Signed)
-SM_INT__INT_2 = ootype.StaticMethod([ootype.Signed] * 2, ootype.Signed)
-SM_INT__INT_3 = ootype.StaticMethod([ootype.Signed] * 3, ootype.Signed)
-SM_INT__INT_100 = ootype.StaticMethod([ootype.Signed] * 100, ootype.Signed)
 class FunctionConst(BaseConst):
     
     @specialize.arg(1)
     def revealconst(self, T):
-        if T == SM_INT__INT_1:
-            DelegateType = CLR.pypy.runtime.DelegateType_int__int_1
-            return clidowncast(DelegateType, self.getobj())
-        elif T == SM_INT__INT_2:
-            DelegateType = CLR.pypy.runtime.DelegateType_int__int_2
-            return clidowncast(DelegateType, self.getobj())
-        elif T == SM_INT__INT_3:
-            DelegateType = CLR.pypy.runtime.DelegateType_int__int_3
-            return clidowncast(DelegateType, self.getobj())
-        elif T == SM_INT__INT_100:
-            DelegateType = CLR.pypy.runtime.DelegateType_int__int_100
-            return clidowncast(DelegateType, self.getobj())
-        else:
-            assert False
+        return clidowncast(self.getobj(), T)
 
 class ObjectConst(BaseConst):
 
@@ -382,3 +370,6 @@
         il.MarkLabel(self.label)        
         for op in self.operations:
             op.emit()
+
+global_rgenop = RCliGenOp()
+RCliGenOp.constPrebuiltGlobal = global_rgenop.genconst

Modified: pypy/dist/pypy/translator/cli/dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/dotnet.py	(original)
+++ pypy/dist/pypy/translator/cli/dotnet.py	Wed Feb 13 10:16:44 2008
@@ -589,7 +589,7 @@
             cliClass = s_type.const
             TYPE = cliClass._INSTANCE
         if isinstance(TYPE, ootype.StaticMethod):
-            assert ootype.isSubclass(s_value.ootype, CLR.System.Delegate._INSTANCE)
+            assert ootype.isSubclass(s_value.ootype, CLR.System.Object._INSTANCE)
             return SomeOOStaticMeth(TYPE)
         else:
             assert ootype.isSubclass(TYPE, s_value.ootype)

Modified: pypy/dist/pypy/translator/cli/test/test_dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_dotnet.py	(original)
+++ pypy/dist/pypy/translator/cli/test/test_dotnet.py	Wed Feb 13 10:16:44 2008
@@ -274,6 +274,7 @@
         assert self.interpret(fn, []) == 42+43
 
     def test_array_setitem_None(self):
+        py.test.skip('Mono bug :-(')
         def fn():
             x = init_array(System.Object, box(42), box(43))
             x[0] = None



More information about the Pypy-commit mailing list