git @ Cat's Eye Technologies SixtyPical / bcc256a
Checkpoint. Chris Pressey 2 years ago
3 changed file(s) with 16 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
5252 if options.dump_callgraph:
5353 graph = {}
5454
55 from sixtypical.model import RoutineType, VectorType
56
57 def find_routines_matching_vector_type(program, type_):
58 return [] # dummy
59
5560 for routine in program.routines:
5661 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
6070 graph[routine.name] = {
6171 'potentially-calls': potentially_calls,
6272 }
515515 type = self.get_type(instr.location)
516516 if not isinstance(type, (RoutineType, VectorType)):
517517 raise TypeMismatchError(instr, instr.location.name)
518 context.mark_as_called(instr.location)
518 context.mark_as_called(instr.location, type)
519519 if isinstance(type, VectorType):
520520 type = type.of_type
521521 for ref in type.inputs:
329329 else:
330330 return self.symtab.fetch_global_type(ref.name).max_range
331331
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_))