mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-21 10:31:25 +00:00
First cut at finding all routines that could be assigned to vector.
This commit is contained in:
parent
7187fa6285
commit
182935a088
@ -141,18 +141,22 @@ class Analyzer(object):
|
||||
def analyze_program(self, program):
|
||||
assert isinstance(program, Program)
|
||||
for routine in program.routines:
|
||||
context = self.analyze_routine(routine)
|
||||
context, type_ = self.analyze_routine(routine)
|
||||
if type_:
|
||||
routine.routine_type = type_
|
||||
routine.encountered_gotos = list(context.encountered_gotos()) if context else []
|
||||
routine.called_routines = list(context.called_routines) if context else []
|
||||
|
||||
def analyze_routine(self, routine):
|
||||
assert isinstance(routine, Routine)
|
||||
type_ = self.get_type_for_name(routine.name)
|
||||
|
||||
if routine.block is None:
|
||||
# it's an extern, that's fine
|
||||
return None
|
||||
return None, type_
|
||||
|
||||
self.current_routine = routine
|
||||
type_ = self.get_type_for_name(routine.name)
|
||||
|
||||
context = AnalysisContext(self.symtab, routine, type_.inputs, type_.outputs, type_.trashes)
|
||||
|
||||
# register any local statics as already-initialized
|
||||
@ -210,7 +214,7 @@ class Analyzer(object):
|
||||
|
||||
self.exit_contexts = None
|
||||
self.current_routine = None
|
||||
return context
|
||||
return context, type_
|
||||
|
||||
def analyze_block(self, block, context):
|
||||
assert isinstance(block, Block)
|
||||
|
@ -1,8 +1,11 @@
|
||||
from sixtypical.model import RoutineType, VectorType
|
||||
|
||||
|
||||
def find_routines_matching_vector_type(program, type_):
|
||||
return [] # dummy
|
||||
def find_routines_matching_type(program, type_):
|
||||
"""Return the subset of routines of the program whose value
|
||||
may be assigned to a location of the given type_ (typically
|
||||
a vector)."""
|
||||
return [r for r in program.routines if RoutineType.executable_types_compatible(r.routine_type, type_)]
|
||||
|
||||
|
||||
def construct_callgraph(program):
|
||||
@ -14,7 +17,7 @@ def construct_callgraph(program):
|
||||
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):
|
||||
for potentially_called in find_routines_matching_type(program, called_routine_type):
|
||||
potentially_calls.append(potentially_called.name)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
Loading…
Reference in New Issue
Block a user