[pypy-svn] r57709 - in pypy/branch/oo-jit/pypy: annotation jit/codegen/cli translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Mon Sep 1 10:47:25 CEST 2008


Author: antocuni
Date: Mon Sep  1 10:47:23 2008
New Revision: 57709

Modified:
   pypy/branch/oo-jit/pypy/annotation/binaryop.py
   pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py
   pypy/branch/oo-jit/pypy/jit/codegen/cli/rgenop.py
   pypy/branch/oo-jit/pypy/translator/cli/constant.py
   pypy/branch/oo-jit/pypy/translator/cli/database.py
Log:
use the ootype.Class of the Records to get their CLI type, as we did for instances



Modified: pypy/branch/oo-jit/pypy/annotation/binaryop.py
==============================================================================
--- pypy/branch/oo-jit/pypy/annotation/binaryop.py	(original)
+++ pypy/branch/oo-jit/pypy/annotation/binaryop.py	Mon Sep  1 10:47:23 2008
@@ -951,6 +951,8 @@
             common = r2.ootype
         elif r2.ootype is None:
             common = r1.ootype
+        elif r1.ootype is ootype.Object or r2.ootype is ootype.Object:
+            common = ootype.Object
         elif isinstance(r1.ootype, ootype.Record) or isinstance(r2.ootype, ootype.Record):
             common = ootype.Object
         else:

Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/operation.py	Mon Sep  1 10:47:23 2008
@@ -180,10 +180,7 @@
         from pypy.jit.codegen.cli.rgenop import class2type
         self.meth = meth
         self.gv_obj = gv_obj
-        if fieldtoken.cls is None:
-            clitype = gv_obj.getCliType() # XXX: it's a Record, need to think how to fix
-        else:
-            clitype = class2type(fieldtoken.cls)
+        clitype = class2type(fieldtoken.ooclass)
         self.fieldinfo = clitype.GetField(str(fieldtoken.name))
 
     def restype(self):
@@ -202,10 +199,7 @@
         self.meth = meth
         self.gv_obj = gv_obj
         self.gv_value = gv_value
-        if fieldtoken.cls is None:
-            clitype = gv_obj.getCliType() # XXX: it's a Record, need to think how to fix
-        else:
-            clitype = class2type(fieldtoken.cls)
+        clitype = class2type(fieldtoken.ooclass)
         self.fieldinfo = clitype.GetField(str(fieldtoken.name))
 
     def restype(self):

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	Mon Sep  1 10:47:23 2008
@@ -35,8 +35,8 @@
         self.funcclass = funcclass
 
 class FieldToken:
-    def __init__(self, cls, name):
-        self.cls = cls
+    def __init__(self, ooclass, name):
+        self.ooclass = ooclass
         self.name = name
 
 class AllocToken:
@@ -335,11 +335,8 @@
     @staticmethod
     @specialize.memo()
     def fieldToken(T, name):
-        if isinstance(T, ootype.Record):
-            cls = ootype.nullruntimeclass
-        else:
-            cls = ootype.runtimeClass(T)
-        return FieldToken(cls, name)
+        ooclass = ootype.runtimeClass(T)
+        return FieldToken(ooclass, name)
 
     @staticmethod
     @specialize.memo()

Modified: pypy/branch/oo-jit/pypy/translator/cli/constant.py
==============================================================================
--- pypy/branch/oo-jit/pypy/translator/cli/constant.py	(original)
+++ pypy/branch/oo-jit/pypy/translator/cli/constant.py	Mon Sep  1 10:47:23 2008
@@ -348,8 +348,8 @@
                 FUNC = self.value._FUNC
                 classname = self.db.record_delegate(FUNC)
             else:
-                INSTANCE = self.value._INSTANCE
-                classname = self.db.class_name(INSTANCE)
+                TYPE = self.value._INSTANCE
+                classname = self.db.class_or_record_name(TYPE)
             gen.ilasm.opcode('ldtoken', classname)
             gen.ilasm.call('class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)')
             return

Modified: pypy/branch/oo-jit/pypy/translator/cli/database.py
==============================================================================
--- pypy/branch/oo-jit/pypy/translator/cli/database.py	(original)
+++ pypy/branch/oo-jit/pypy/translator/cli/database.py	Mon Sep  1 10:47:23 2008
@@ -129,6 +129,14 @@
         self.classnames.add((namespace, name))            
         return name
 
+    def class_or_record_name(self, TYPE):
+        if isinstance(TYPE, ootype.Instance):
+            return self.class_name(TYPE)
+        elif isinstance(TYPE, ootype.Record):
+            return self.get_record_name(TYPE)
+        else:
+            assert False
+
     def class_name(self, INSTANCE):
         try:
             NATIVE_INSTANCE = INSTANCE._hints['NATIVE_INSTANCE']



More information about the Pypy-commit mailing list