[pypy-svn] r65475 - in pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llgraph: . test

antocuni at codespeak.net antocuni at codespeak.net
Thu May 28 11:54:11 CEST 2009


Author: antocuni
Date: Thu May 28 11:54:10 2009
New Revision: 65475

Modified:
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llgraph/runner.py
   pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llgraph/test/test_llgraph.py
Log:
make sure that you return the always same descr for fields defined in the superclasses


Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llgraph/runner.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llgraph/runner.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llgraph/runner.py	Thu May 28 11:54:10 2009
@@ -402,7 +402,9 @@
 
     @staticmethod
     def fielddescrof(T, fieldname):
-        return FieldDescr.new(T, fieldname)
+        # use class where the field is really defined as a key
+        T1, _ = T._lookup_field(fieldname)
+        return FieldDescr.new(T1, fieldname)
 
     @staticmethod
     def calldescrof(FUNC, ARGS, RESULT):

Modified: pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llgraph/test/test_llgraph.py
==============================================================================
--- pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llgraph/test/test_llgraph.py	(original)
+++ pypy/branch/pyjitpl5-experiments/pypy/jit/backend/llgraph/test/test_llgraph.py	Thu May 28 11:54:10 2009
@@ -224,3 +224,13 @@
 ## these tests never worked
 ## class TestOOTypeLLGraph(LLGraphTest):
 ##     from pypy.jit.backend.llgraph.runner import OOtypeCPU as cpu_type
+
+def test_fielddescr_ootype():
+    from pypy.rpython.ootypesystem import ootype
+    from pypy.jit.backend.llgraph.runner import OOtypeCPU
+    A = ootype.Instance("A", ootype.ROOT, {"foo": ootype.Signed})
+    B = ootype.Instance("B", A)
+    cpu = OOtypeCPU(None)
+    descr1 = cpu.fielddescrof(A, "foo")
+    descr2 = cpu.fielddescrof(B, "foo")
+    assert descr1 is descr2



More information about the Pypy-commit mailing list