mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-28 12:51:10 +00:00
Optomize dump() abstraction. (You muss optomize, always optomize.)
This commit is contained in:
parent
e39dbf68ed
commit
aecea9b6a3
@ -61,6 +61,8 @@ def process_input_files(filenames, options):
|
|||||||
if options.optimize_fallthru:
|
if options.optimize_fallthru:
|
||||||
def dump(label, data):
|
def dump(label, data):
|
||||||
import json
|
import json
|
||||||
|
if not options.dump_fallthru_info:
|
||||||
|
return
|
||||||
if label:
|
if label:
|
||||||
sys.stdout.write("*** {}:\n".format(label))
|
sys.stdout.write("*** {}:\n".format(label))
|
||||||
sys.stdout.write(json.dumps(data, indent=4, sort_keys=True))
|
sys.stdout.write(json.dumps(data, indent=4, sort_keys=True))
|
||||||
@ -70,24 +72,15 @@ def process_input_files(filenames, options):
|
|||||||
|
|
||||||
fa = FallthruAnalyzer(debug=options.debug)
|
fa = FallthruAnalyzer(debug=options.debug)
|
||||||
fa.analyze_program(program)
|
fa.analyze_program(program)
|
||||||
|
|
||||||
if options.dump_fallthru_info:
|
|
||||||
dump(None, fa.fall_in_map)
|
dump(None, fa.fall_in_map)
|
||||||
|
|
||||||
fa.find_cycles()
|
fa.find_cycles()
|
||||||
|
|
||||||
while fa.cycles_found:
|
while fa.cycles_found:
|
||||||
if options.dump_fallthru_info:
|
|
||||||
|
|
||||||
if options.debug:
|
if options.debug:
|
||||||
dump('ancestors', fa.ancestor_map)
|
dump('ancestors', fa.ancestor_map)
|
||||||
dump('cycles found', sorted(fa.cycles_found))
|
dump('cycles found', sorted(fa.cycles_found))
|
||||||
|
|
||||||
fa.break_cycle()
|
fa.break_cycle()
|
||||||
|
|
||||||
if options.dump_fallthru_info:
|
|
||||||
dump('after breaking cycle', fa.fall_in_map)
|
dump('after breaking cycle', fa.fall_in_map)
|
||||||
|
|
||||||
fa.find_cycles()
|
fa.find_cycles()
|
||||||
|
|
||||||
if options.analyze_only:
|
if options.analyze_only:
|
||||||
|
Loading…
Reference in New Issue
Block a user