[pypy-svn] r15564 - pypy/dist/pypy/translator/goal

pedronis at codespeak.net pedronis at codespeak.net
Wed Aug 3 16:58:57 CEST 2005


Author: pedronis
Date: Wed Aug  3 16:58:56 2005
New Revision: 15564

Modified:
   pypy/dist/pypy/translator/goal/query.py
Log:
sanity check query about methods, at least once it releaved problems with three method impls not appearing in the s_value of the corresponding 
attribute on W_Root



Modified: pypy/dist/pypy/translator/goal/query.py
==============================================================================
--- pypy/dist/pypy/translator/goal/query.py	(original)
+++ pypy/dist/pypy/translator/goal/query.py	Wed Aug  3 16:58:56 2005
@@ -441,3 +441,40 @@
     except:
         import traceback
         traceback.print_exc()
+
+def sanity_check_methods(translator):
+    from pypy.annotation.classdef import ClassDef
+    def ismeth(s_val):
+        if not isinstance(s_val, annmodel.SomePBC):
+            return False
+        s_pbc = s_val
+        c = 0
+        for f, clsdef in s_pbc.prebuiltinstances.iteritems():
+            if callable(f) and isinstance(clsdef, ClassDef):
+                c += 1
+        return c == len(s_pbc.prebuiltinstances)
+    usercls = translator.annotator.getuserclasses()
+    withmeths = []
+    for clsdef in usercls.itervalues():
+        meths = []
+        for attr in clsdef.attrs.values():
+            if ismeth(attr.s_value):
+                meths.append(attr)
+        if meths:
+            withmeths.append((clsdef, meths))
+    for clsdef, meths in withmeths:
+        cls = clsdef.cls
+        n = 0
+        subclasses = []
+        for clsdef1 in usercls.itervalues():
+            if issubclass(clsdef1.cls, cls):
+                subclasses.append(clsdef1)
+        for meth in meths:
+            name = meth.name
+            funcs = dict.fromkeys(meth.s_value.prebuiltinstances.iterkeys())
+            for subcls in subclasses:
+                f = subcls.cls.__dict__.get(name)
+                if f:
+                    if f not in funcs:
+                        print name, subcls.cls, cls, subcls.attrs.keys() 
+



More information about the Pypy-commit mailing list