[pypy-svn] r7422 - in pypy/trunk/src: goal pypy/translator/tool/pygame
mgedmin at codespeak.net
mgedmin at codespeak.net
Fri Nov 19 12:02:17 CET 2004
Author: mgedmin
Date: Fri Nov 19 12:02:16 2004
New Revision: 7422
Modified:
pypy/trunk/src/goal/translate_pypy.py
pypy/trunk/src/pypy/translator/tool/pygame/flowviewer.py
Log:
Added --mark-some-objects option to translate_pypy.py to find, list and
highlight in the flow graph all functions that receive or return SomeObject()s.
Modified: pypy/trunk/src/goal/translate_pypy.py
==============================================================================
--- pypy/trunk/src/goal/translate_pypy.py (original)
+++ pypy/trunk/src/goal/translate_pypy.py Fri Nov 19 12:02:16 2004
@@ -8,6 +8,8 @@
-no-c Don't generate the C code
-c Generate the C code, but don't compile it
-o Generate and compile the C code, but don't run it
+ --mark-some-objects
+ Mark all functions that have SomeObject in their signature.
"""
import autopath, sys, threading, pdb
from pypy.objspace.std.objspace import StdObjSpace, W_Object
@@ -42,10 +44,14 @@
a = t.annotate([])
a.simplify()
- count_someobjects(a)
+ if options['--mark-some-objects']:
+ find_someobjects(a)
-def count_someobjects(annotator):
+
+def find_someobjects(annotator):
+ """Find all functions in that have SomeObject in their signature."""
translator = annotator.translator
+ translator.highlight_functions = {}
def is_someobject(var):
try:
@@ -61,8 +67,11 @@
return binding.__class__.__name__
header = True
+ items = [(graph.name, func, graph)
+ for func, graph in translator.flowgraphs.items()]
+ items.sort()
num = someobjnum = 0
- for func, graph in translator.flowgraphs.items():
+ for graphname, func, graph in items:
unknown_input_args = len(filter(is_someobject, graph.getargs()))
unknown_return_value = is_someobject(graph.getreturnvar())
if unknown_input_args or unknown_return_value:
@@ -71,6 +80,7 @@
print "=" * 70
print "Functions that have SomeObject in their signature"
print "=" * 70
+ translator.highlight_functions[func] = True
print ("%(name)s(%(args)s) -> %(result)s\n"
"%(filename)s:%(lineno)s\n"
% {'name': graph.name,
@@ -94,6 +104,7 @@
'-no-c': False,
'-c': False,
'-o': False,
+ '--mark-some-objects': False,
}
for arg in sys.argv[1:]:
if arg in ('-h', '--help'):
Modified: pypy/trunk/src/pypy/translator/tool/pygame/flowviewer.py
==============================================================================
--- pypy/trunk/src/pypy/translator/tool/pygame/flowviewer.py (original)
+++ pypy/trunk/src/pypy/translator/tool/pygame/flowviewer.py Fri Nov 19 12:02:16 2004
@@ -160,11 +160,16 @@
# show the call graph
functions = translator.functions
+ highlight_functions = getattr(translator, 'highlight_functions', {}) # XXX
dotgen.emit_node('entry', fillcolor="green", shape="octagon",
label="Translator\\nEntry Point")
for func in functions:
data = self.labelof(func, func.func_name)
- dotgen.emit_node(nameof(func), label=data, shape="box")
+ if func in highlight_functions:
+ kw = {'fillcolor': '#ffcccc'}
+ else:
+ kw = {}
+ dotgen.emit_node(nameof(func), label=data, shape="box", **kw)
dotgen.emit_edge('entry', nameof(functions[0]), color="green")
for f1, f2 in translator.callgraph.itervalues():
dotgen.emit_edge(nameof(f1), nameof(f2))
More information about the Pypy-commit
mailing list