[pypy-svn] r57682 - in pypy/branch/oo-jit/pypy/jit: codegen/cli codegen/cli/test rainbow

antocuni at codespeak.net antocuni at codespeak.net
Fri Aug 29 16:31:15 CEST 2008


Author: antocuni
Date: Fri Aug 29 16:31:12 2008
New Revision: 57682

Modified:
   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/jit/codegen/cli/test/test_gencli_interpreter.py
   pypy/branch/oo-jit/pypy/jit/rainbow/portal.py
Log:
keep both the type and the attribute name as a fieldtoken. test_simple_struct passes



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	Fri Aug 29 16:31:12 2008
@@ -176,11 +176,15 @@
 
 class GetField(Operation):
 
-    def __init__(self, meth, gv_obj, fieldname):
+    def __init__(self, meth, gv_obj, fieldtoken):
+        from pypy.jit.codegen.cli.rgenop import class2type
         self.meth = meth
         self.gv_obj = gv_obj
-        clitype = gv_obj.getCliType()
-        self.fieldinfo = clitype.GetField(fieldname)
+        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)
+        self.fieldinfo = clitype.GetField(fieldtoken.name)
 
     def restype(self):
         return self.fieldinfo.get_FieldType()
@@ -193,12 +197,16 @@
 
 class SetField(Operation):
 
-    def __init__(self, meth, gv_obj, gv_value, fieldname):
+    def __init__(self, meth, gv_obj, gv_value, fieldtoken):
+        from pypy.jit.codegen.cli.rgenop import class2type
         self.meth = meth
         self.gv_obj = gv_obj
         self.gv_value = gv_value
-        clitype = gv_obj.getCliType()
-        self.fieldinfo = clitype.GetField(fieldname)
+        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)
+        self.fieldinfo = clitype.GetField(fieldtoken.name)
 
     def restype(self):
         return None

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	Fri Aug 29 16:31:12 2008
@@ -34,6 +34,11 @@
         self.res = res
         self.funcclass = funcclass
 
+class FieldToken:
+    def __init__(self, cls, name):
+        self.cls = cls
+        self.name = name
+
 def class2type(cls):
     'Cast a PBC of type ootype.Class into a System.Type instance'
     if cls is cVoid:
@@ -323,8 +328,11 @@
     @staticmethod
     @specialize.memo()
     def fieldToken(T, name):
-        _, FIELD = T._lookup_field(name)
-        return name #, RCliGenOp.kindToken(FIELD)
+        if isinstance(T, ootype.Record):
+            cls = ootype.nullruntimeclass
+        else:
+            cls = ootype.runtimeClass(T)
+        return FieldToken(cls, name)
 
     @staticmethod
     @specialize.memo()

Modified: pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/codegen/cli/test/test_gencli_interpreter.py	Fri Aug 29 16:31:12 2008
@@ -63,7 +63,6 @@
         assert res == 42
 
 
-    test_simple_struct = skip
     test_complex_struct = skip
     test_degenerate_with_voids = skip
     test_arith_plus_minus = skip

Modified: pypy/branch/oo-jit/pypy/jit/rainbow/portal.py
==============================================================================
--- pypy/branch/oo-jit/pypy/jit/rainbow/portal.py	(original)
+++ pypy/branch/oo-jit/pypy/jit/rainbow/portal.py	Fri Aug 29 16:31:12 2008
@@ -90,6 +90,7 @@
             PTR_RESFUNC = self.PTR_RESIDUAL_FUNCTYPE
             args_s = [annmodel.lltype_to_annotation(ARG) for ARG in FUNC.ARGS]
             s_result = annmodel.lltype_to_annotation(FUNC.RESULT)
+            self.annhelper = annhelper
             self.portal_entry_graph = annhelper.getgraph(
                 self.portal_entry, args_s, s_result)
             portal_entry_graph_ptr = annhelper.graph2delayed(



More information about the Pypy-commit mailing list