Maciej Fijalkowski avatar Maciej Fijalkowski committed 6fbbe0d

make the test pass, unsure if it"s complete

Comments (0)

Files changed (2)

pypy/jit/codewriter/jtransform.py

                 opname = "unicodegetitem"
             return SpaceOperation(opname, [op.args[0], op.args[2]], op.result)
         else:
-            return SpaceOperation('getinteriorfield', op.args[:], op.result)
+            v_inst, v_index, c_field = op.args
+            # only GcArray of Struct supported
+            assert isinstance(v_inst.concretetype.TO, lltype.GcArray)
+            STRUCT = v_inst.concretetype.TO.OF
+            assert isinstance(STRUCT, lltype.Struct)
+            sizedescr = self.cpu.sizeof(STRUCT)
+            fielddescr = self.cpu.fielddescrof(STRUCT, c_field.value)
+            args = [v_inst, v_index, sizedescr, fielddescr]
+            return SpaceOperation('getinteriorfield', args, op.result)
 
     def rewrite_op_setinteriorfield(self, op):
         # only supports strings and unicodes

pypy/jit/codewriter/test/test_jtransform.py

         return ('calldescr', FUNC, ARGS, RESULT)
     def fielddescrof(self, STRUCT, name):
         return ('fielddescr', STRUCT, name)
+    def interiorfielddescrof(self, ARRAY, name):
+        return ('interiorfielddescr', ARRAY, name)
     def arraydescrof(self, ARRAY):
         return FakeDescr(('arraydescr', ARRAY))
     def sizeof(self, STRUCT):
 def test_dict_getinteriorfield():
     DICT = lltype.GcArray(lltype.Struct('ENTRY', ('v', lltype.Signed),
                                         ('k', lltype.Signed)))
-    v = varoftype(DICT)
+    v = varoftype(lltype.Ptr(DICT))
     i = varoftype(lltype.Signed)
     v_result = varoftype(lltype.Signed)
     op = SpaceOperation('getinteriorfield', [v, i, Constant('v', lltype.Void)],
                         v_result)
-    op1 = Transformer().rewrite_operation(op)
+    op1 = Transformer(FakeCPU()).rewrite_operation(op)
     assert op1.opname == 'getinteriorfield'
+    assert op1.args == [v, i, ('sizedescr', DICT.OF),
+                        ('fielddescr', DICT.OF, 'v')]
 
 def test_str_setinteriorfield():
     v = varoftype(lltype.Ptr(rstr.STR))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.