[pypy-svn] r17924 - pypy/dist/pypy/translator/goal
pedronis at codespeak.net
pedronis at codespeak.net
Tue Sep 27 23:37:08 CEST 2005
Author: pedronis
Date: Tue Sep 27 23:37:06 2005
New Revision: 17924
Modified:
pypy/dist/pypy/translator/goal/query.py
pypy/dist/pypy/translator/goal/translate_pypy_new.py
Log:
reorganized sanity_check_methods as a generator for translate_pypy_new
Modified: pypy/dist/pypy/translator/goal/query.py
==============================================================================
--- pypy/dist/pypy/translator/goal/query.py (original)
+++ pypy/dist/pypy/translator/goal/query.py Tue Sep 27 23:37:06 2005
@@ -408,47 +408,6 @@
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))
- lost = 0
- 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 hasattr(f, 'im_self') and f.im_self is None:
- f = f.im_func
- if f:
- if f not in funcs:
- print "Lost method!", name, subcls.cls, cls, subcls.attrs.keys()
- lost += 0
- return lost
-
def graph_footprint(graph):
class Counter:
blocks = 0
@@ -579,6 +538,43 @@
continue
yield "%s exceptblock is not completely sane" % graph.name
+def check_methods_qgen(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 hasattr(f, 'im_self') and f.im_self is None:
+ f = f.im_func
+ if f:
+ if f not in funcs:
+ yield "lost method: %s %s %s %s" % (name, subcls.cls, cls, subcls.attrs.keys() )
def qoutput(queryg, write=None):
if write is None:
@@ -593,4 +589,7 @@
def polluted(translator):
c = qoutput(polluted_qgen(translator))
print c
-
+
+def sanity_check_methods(translator):
+ lost = qoutput(check_methods_qgen(translator))
+ print lost
Modified: pypy/dist/pypy/translator/goal/translate_pypy_new.py
==============================================================================
--- pypy/dist/pypy/translator/goal/translate_pypy_new.py (original)
+++ pypy/dist/pypy/translator/goal/translate_pypy_new.py Tue Sep 27 23:37:06 2005
@@ -103,9 +103,9 @@
if not irreg:
print "++ All exceptblocks seem sane"
- lost = query.sanity_check_methods(t)
+ lost = query.qoutput(query.check_methods_qgen(t))
assert not lost, "lost methods, something gone wrong with the annotation of method defs"
- print "*** No lost method defs."
+ print "++ No lost method defs"
so = query.qoutput(query.polluted_qgen(t))
tot = len(t.flowgraphs)
More information about the Pypy-commit
mailing list