1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-25 07:32:16 +00:00

Call it fall_in_map.

This commit is contained in:
Chris Pressey 2018-04-04 14:16:49 +01:00
parent 9c196efe25
commit e39dbf68ed
2 changed files with 13 additions and 13 deletions

View File

@ -72,7 +72,7 @@ def process_input_files(filenames, options):
fa.analyze_program(program)
if options.dump_fallthru_info:
dump(None, fa.fallthru_map)
dump(None, fa.fall_in_map)
fa.find_cycles()
@ -86,7 +86,7 @@ def process_input_files(filenames, options):
fa.break_cycle()
if options.dump_fallthru_info:
dump('after breaking cycle', fa.fallthru_map)
dump('after breaking cycle', fa.fall_in_map)
fa.find_cycles()

View File

@ -16,19 +16,19 @@ class FallthruAnalyzer(object):
self.debug = debug
def analyze_program(self, program):
fallthru_map = {}
fall_in_map = {}
for routine in program.routines:
encountered_gotos = list(routine.encountered_gotos)
if len(encountered_gotos) == 1 and isinstance(encountered_gotos[0].type, RoutineType):
fallthru_map.setdefault(encountered_gotos[0].name, set()).add(routine.name)
self.fallthru_map = dict([(k, sorted(v)) for k, v in fallthru_map.iteritems()])
return self.fallthru_map
fall_in_map.setdefault(encountered_gotos[0].name, set()).add(routine.name)
self.fall_in_map = dict([(k, sorted(v)) for k, v in fall_in_map.iteritems()])
return self.fall_in_map
def find_cycles(self):
self.ancestor_map = {}
for key in self.fallthru_map:
for key in self.fall_in_map:
ancestors = set()
make_transitive_closure(self.fallthru_map, key, ancestors)
make_transitive_closure(self.fall_in_map, key, ancestors)
self.ancestor_map[key] = sorted(ancestors)
self.cycles_found = set()
@ -42,12 +42,12 @@ class FallthruAnalyzer(object):
cycle_to_break = sorted(self.cycles_found)[0]
cycles_to_break = set([cycle_to_break])
new_fallthru_map = {}
for key in self.fallthru_map:
values = set(self.fallthru_map[key]) - cycles_to_break
new_fall_in_map = {}
for key in self.fall_in_map:
values = set(self.fall_in_map[key]) - cycles_to_break
if values:
new_fallthru_map[key] = sorted(values)
self.fallthru_map = new_fallthru_map
new_fall_in_map[key] = sorted(values)
self.fall_in_map = new_fall_in_map
def serialize(self):
raise NotImplementedError