50 | 50 |
sys.stdout.write("\n")
|
51 | 51 |
|
52 | 52 |
if options.dump_callgraph:
|
53 | |
graph = {}
|
54 | |
|
55 | |
from sixtypical.model import RoutineType, VectorType
|
56 | |
|
57 | |
def find_routines_matching_vector_type(program, type_):
|
58 | |
return [] # dummy
|
59 | |
|
60 | |
for routine in program.routines:
|
61 | |
potentially_calls = []
|
62 | |
for (called_routine, called_routine_type) in routine.called_routines:
|
63 | |
if isinstance(called_routine_type, RoutineType):
|
64 | |
potentially_calls.append(called_routine.name)
|
65 | |
elif isinstance(called_routine_type, VectorType):
|
66 | |
for potentially_called in find_routines_matching_vector_type(program, called_routine_type):
|
67 | |
potentially_calls.append(potentially_called.name)
|
68 | |
else:
|
69 | |
raise NotImplementedError
|
70 | |
graph[routine.name] = {
|
71 | |
'potentially-calls': potentially_calls,
|
72 | |
}
|
73 | |
|
74 | |
# Reflexive closure
|
75 | |
|
76 | |
for routine in program.routines:
|
77 | |
potentially_called_by = []
|
78 | |
for (name, node) in graph.items():
|
79 | |
potential_calls = node['potentially-calls']
|
80 | |
if routine.name in potential_calls:
|
81 | |
potentially_called_by.append(name)
|
82 | |
graph[routine.name]['potentially-called-by'] = potentially_called_by
|
83 | |
|
|
53 |
from sixtypical.callgraph import construct_callgraph
|
|
54 |
graph = construct_callgraph(program)
|
84 | 55 |
sys.stdout.write(json.dumps(graph, indent=4, sort_keys=True, separators=(',', ':')))
|
85 | 56 |
|
86 | 57 |
compilation_roster = None
|