comparison python/zcc.py @ 314:38f5f298ce0e

Add log for interference graph
author Windel Bouwman
date Wed, 18 Dec 2013 20:22:20 +0100
parents 04cf4d26a3bc
children 084cccaa5deb
comparison
equal deleted inserted replaced
313:04cf4d26a3bc 314:38f5f298ce0e
31 def __init__(self): 31 def __init__(self):
32 super().__init__(fmt=logformat) 32 super().__init__(fmt=logformat)
33 33
34 def format(self, record): 34 def format(self, record):
35 s = super().format(record) 35 s = super().format(record)
36 s += '\n'
36 if hasattr(record, 'c3_ast'): 37 if hasattr(record, 'c3_ast'):
37 f = io.StringIO() 38 f = io.StringIO()
38 print('', file=f) 39 print('', file=f)
39 print('', file=f) 40 print('', file=f)
40 print('.. code::', file=f) 41 print('.. code::', file=f)
79 print('.. graphviz::', file=f) 80 print('.. graphviz::', file=f)
80 print('', file=f) 81 print('', file=f)
81 print(' digraph G {', file=f) 82 print(' digraph G {', file=f)
82 cfg = record.ra_cfg 83 cfg = record.ra_cfg
83 cfg.to_dot(f) 84 cfg.to_dot(f)
85 print(' }', file=f)
86 print('', file=f)
87 s += '\n' + f.getvalue()
88 if hasattr(record, 'ra_ig'):
89 f = io.StringIO()
90 print('', file=f)
91 print('', file=f)
92 print('.. graphviz::', file=f)
93 print('', file=f)
94 print(' digraph G {', file=f)
95 ig = record.ra_ig
96 ig.to_dot(f)
84 print(' }', file=f) 97 print(' }', file=f)
85 print('', file=f) 98 print('', file=f)
86 s += '\n' + f.getvalue() 99 s += '\n' + f.getvalue()
87 return s 100 return s
88 101