Checkpoint.
Chris Pressey
3 years ago
52 | 52 |
if options.dump_callgraph:
|
53 | 53 |
graph = {}
|
54 | 54 |
|
|
55 |
from sixtypical.model import RoutineType, VectorType
|
|
56 |
|
|
57 |
def find_routines_matching_vector_type(program, type_):
|
|
58 |
return [] # dummy
|
|
59 |
|
55 | 60 |
for routine in program.routines:
|
56 | 61 |
potentially_calls = []
|
57 | |
for called_routine in routine.called_routines:
|
58 | |
# TODO if called_routine is a vector, this should be all routines which can be assigned to this vector
|
59 | |
potentially_calls.append(called_routine.name)
|
|
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
|
60 | 70 |
graph[routine.name] = {
|
61 | 71 |
'potentially-calls': potentially_calls,
|
62 | 72 |
}
|
515 | 515 |
type = self.get_type(instr.location)
|
516 | 516 |
if not isinstance(type, (RoutineType, VectorType)):
|
517 | 517 |
raise TypeMismatchError(instr, instr.location.name)
|
518 | |
context.mark_as_called(instr.location)
|
|
518 |
context.mark_as_called(instr.location, type)
|
519 | 519 |
if isinstance(type, VectorType):
|
520 | 520 |
type = type.of_type
|
521 | 521 |
for ref in type.inputs:
|
329 | 329 |
else:
|
330 | 330 |
return self.symtab.fetch_global_type(ref.name).max_range
|
331 | 331 |
|
332 | |
def mark_as_called(self, routine):
|
333 | |
self.called_routines.add(routine)
|
|
332 |
def mark_as_called(self, location, type_):
|
|
333 |
self.called_routines.add((location, type_))
|