[pypy-svn] r17918 - in pypy/dist/pypy/translator: . goal tool

pedronis at codespeak.net pedronis at codespeak.net
Tue Sep 27 21:18:19 CEST 2005


Author: pedronis
Date: Tue Sep 27 21:18:17 2005
New Revision: 17918

Modified:
   pypy/dist/pypy/translator/goal/translate_pypy_new.py
   pypy/dist/pypy/translator/tool/util.py
   pypy/dist/pypy/translator/translator.py
Log:
reorganize: move about from translate_pypy_new to translator.Translator as method (parallel to the various show functionality)



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 21:18:17 2005
@@ -162,7 +162,7 @@
             block = getattr(val, '__annotator_block', None)
             if block:
                 print '-'*60
-                about(block)
+                t.about(block)
                 print '-'*60
 
             print >> sys.stderr
@@ -193,31 +193,6 @@
                 debugger.join()
                 cleanup()
 
-    def about(x):
-        """ interactive debugging helper """
-        from pypy.objspace.flow.model import Block, flatten
-        if isinstance(x, Block):
-            for func, graph in t.flowgraphs.items():
-                if x in flatten(graph):
-                    funcname = func.func_name
-                    cls = getattr(func, 'class_', None)
-                    if cls:
-                        funcname = '%s.%s' % (cls.__name__, funcname)
-                    print '%s is a %s in the graph of %s' % (x,
-                                x.__class__.__name__, funcname)
-                    print 'at %s:%d' % (func.func_globals.get('__name__', '?'),
-                                        func.func_code.co_firstlineno)
-                    break
-            else:
-                print '%s is a %s at some unknown location' % (x,
-                                x.__class__.__name__)
-            print 'containing the following operations:'
-            for op in x.operations:
-                print op
-            print '--end--'
-            return
-        print "don't know about", x
-
     from optparse import OptionParser
     parser = OptionParser()
     for group in opts:

Modified: pypy/dist/pypy/translator/tool/util.py
==============================================================================
--- pypy/dist/pypy/translator/tool/util.py	(original)
+++ pypy/dist/pypy/translator/tool/util.py	Tue Sep 27 21:18:17 2005
@@ -120,6 +120,7 @@
         print "=" * 70
 
 def worstblocks_topten(ann, n=10):
+    from pypy.tool.ansi_print import ansi_print
     h = [(count, block) for block, count in ann.reflowcounter.iteritems()]
     h.sort()
     if not h:
@@ -131,7 +132,7 @@
             break
         count, block = h.pop()
         ansi_print('                                                      #%3d: reflown %d times  |' % (i+1, count), 36)
-        about(block)
+        ann.translator.about(block)
     ansi_print("`----------------------------------------------------------------------------'", 36)
     print
 

Modified: pypy/dist/pypy/translator/translator.py
==============================================================================
--- pypy/dist/pypy/translator/translator.py	(original)
+++ pypy/dist/pypy/translator/translator.py	Tue Sep 27 21:18:17 2005
@@ -132,6 +132,31 @@
         self.annotator.build_types(graph, input_args_types, func)
         return self.annotator
 
+    def about(self, x):
+        """Interactive debugging helper """
+        from pypy.objspace.flow.model import Block, flatten
+        if isinstance(x, Block):
+            for func, graph in self.flowgraphs.items():
+                if x in graph.iterblocks():
+                    funcname = func.func_name
+                    cls = getattr(func, 'class_', None)
+                    if cls:
+                        funcname = '%s.%s' % (cls.__name__, funcname)
+                    print '%s is a %s in the graph of %s' % (x,
+                                x.__class__.__name__, funcname)
+                    print 'at %s:%d' % (func.func_globals.get('__name__', '?'),
+                                        func.func_code.co_firstlineno)
+                    break
+            else:
+                print '%s is a %s at some unknown location' % (x,
+                                x.__class__.__name__)
+            print 'containing the following operations:'
+            for op in x.operations:
+                print "   ",op
+            print '--end--'
+            return
+        raise TypeError, "don't know about %r" % x
+
     def checkgraphs(self):
         for graph in self.flowgraphs.itervalues():
             checkgraph(graph)



More information about the Pypy-commit mailing list