From bcc256aa5d95e18a39b7acdec33a9b45a658f293 Mon Sep 17 00:00:00 2001 From: Chris Pressey Date: Mon, 21 Oct 2019 15:07:54 +0100 Subject: [PATCH] Checkpoint. --- bin/sixtypical | 16 +++++++++++++--- src/sixtypical/analyzer.py | 2 +- src/sixtypical/context.py | 4 ++-- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/bin/sixtypical b/bin/sixtypical index e0492e4..7f98e03 100755 --- a/bin/sixtypical +++ b/bin/sixtypical @@ -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, } diff --git a/src/sixtypical/analyzer.py b/src/sixtypical/analyzer.py index 9e1b840..e6aa6df 100644 --- a/src/sixtypical/analyzer.py +++ b/src/sixtypical/analyzer.py @@ -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: diff --git a/src/sixtypical/context.py b/src/sixtypical/context.py index c66f204..117c02f 100644 --- a/src/sixtypical/context.py +++ b/src/sixtypical/context.py @@ -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_))