git @ Cat's Eye Technologies SixtyPical / aecea9b
Optomize dump() abstraction. (You muss optomize, always optomize.) Chris Pressey 4 years ago
1 changed file(s) with 7 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
6060 if options.optimize_fallthru:
6161 def dump(label, data):
6262 import json
63 if not options.dump_fallthru_info:
64 return
6365 if label:
6466 sys.stdout.write("*** {}:\n".format(label))
6567 sys.stdout.write(json.dumps(data, indent=4, sort_keys=True))
6971
7072 fa = FallthruAnalyzer(debug=options.debug)
7173 fa.analyze_program(program)
72
73 if options.dump_fallthru_info:
74 dump(None, fa.fall_in_map)
74 dump(None, fa.fall_in_map)
7575
7676 fa.find_cycles()
77
7877 while fa.cycles_found:
79 if options.dump_fallthru_info:
80
81 if options.debug:
82 dump('ancestors', fa.ancestor_map)
83 dump('cycles found', sorted(fa.cycles_found))
84
78 if options.debug:
79 dump('ancestors', fa.ancestor_map)
80 dump('cycles found', sorted(fa.cycles_found))
8581 fa.break_cycle()
86
87 if options.dump_fallthru_info:
88 dump('after breaking cycle', fa.fall_in_map)
89
82 dump('after breaking cycle', fa.fall_in_map)
9083 fa.find_cycles()
9184
9285 if options.analyze_only: