1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-21 10:31:25 +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")
if options.dump_callgraph:
graph = {}
for routine in program.routines:
sys.stdout.write('-----------\n')
sys.stdout.write('{}\n'.format(routine.name))
potentially_calls = []
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
if options.optimize_fallthru: