Checkpoint.

This commit is contained in:
Chris Pressey 2019-10-21 15:07:54 +01:00
parent 2e002fc33e
commit bcc256aa5d
3 changed files with 16 additions and 6 deletions

View File

@ -53,11 +53,21 @@ def process_input_files(filenames, options):
if options.dump_callgraph:
graph = {}
from sixtypical.model import RoutineType, VectorType
def find_routines_matching_vector_type(program, type_):
return [] # dummy
for routine in program.routines:
potentially_calls = []
for called_routine in routine.called_routines:
# 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)
for (called_routine, called_routine_type) in routine.called_routines:
if isinstance(called_routine_type, RoutineType):
potentially_calls.append(called_routine.name)
elif isinstance(called_routine_type, VectorType):
for potentially_called in find_routines_matching_vector_type(program, called_routine_type):
potentially_calls.append(potentially_called.name)
else:
raise NotImplementedError
graph[routine.name] = {
'potentially-calls': potentially_calls,
}

View File

@ -516,7 +516,7 @@ class Analyzer(object):
type = self.get_type(instr.location)
if not isinstance(type, (RoutineType, VectorType)):
raise TypeMismatchError(instr, instr.location.name)
context.mark_as_called(instr.location)
context.mark_as_called(instr.location, type)
if isinstance(type, VectorType):
type = type.of_type
for ref in type.inputs:

View File

@ -330,5 +330,5 @@ class AnalysisContext(object):
else:
return self.symtab.fetch_global_type(ref.name).max_range
def mark_as_called(self, routine):
self.called_routines.add(routine)
def mark_as_called(self, location, type_):
self.called_routines.add((location, type_))