1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-22 01:32:13 +00:00

Refine the callgraph algorithm. Still incomplete though.

This commit is contained in:
Chris Pressey 2019-10-21 14:43:21 +01:00
parent 58dc68f838
commit 894fb1a0f2

View File

@ -51,11 +51,28 @@ def process_input_files(filenames, options):
sys.stdout.write("\n") sys.stdout.write("\n")
if options.dump_callgraph: if options.dump_callgraph:
graph = {}
for routine in program.routines: for routine in program.routines:
sys.stdout.write('-----------\n') potentially_calls = []
sys.stdout.write('{}\n'.format(routine.name))
for called_routine in routine.called_routines: for called_routine in routine.called_routines:
sys.stdout.write(' {}\n'.format(called_routine.name)) # TODO if called_routine is a vector, this should be all routines which can be assigned to this vector
potentially_calls.append(called_routine.name)
graph[routine.name] = {
'potentially-calls': potentially_calls,
}
# Reflexive closure
for routine in program.routines:
potentially_called_by = []
for (name, node) in graph.items():
potential_calls = node['potentially-calls']
if routine.name in potential_calls:
potentially_called_by.append(name)
graph[routine.name]['potentially-called-by'] = potentially_called_by
sys.stdout.write(json.dumps(graph, indent=4, sort_keys=True, separators=(',', ':')))
compilation_roster = None compilation_roster = None
if options.optimize_fallthru: if options.optimize_fallthru: