mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-11-22 01:32:13 +00:00
Simplify, fixing an apparent bug in the process.
This commit is contained in:
parent
565f959ee2
commit
987974cc21
@ -141,11 +141,12 @@ class Analyzer(object):
|
|||||||
def analyze_program(self, program):
|
def analyze_program(self, program):
|
||||||
assert isinstance(program, Program)
|
assert isinstance(program, Program)
|
||||||
for routine in program.routines:
|
for routine in program.routines:
|
||||||
|
routine.called_routines = set()
|
||||||
context, type_ = self.analyze_routine(routine)
|
context, type_ = self.analyze_routine(routine)
|
||||||
if type_:
|
if type_:
|
||||||
routine.routine_type = type_
|
routine.routine_type = type_
|
||||||
routine.encountered_gotos = list(context.encountered_gotos()) if context else []
|
routine.encountered_gotos = list(context.encountered_gotos()) if context else []
|
||||||
routine.called_routines = list(context.called_routines) if context else []
|
routine.called_routines = list(routine.called_routines)
|
||||||
|
|
||||||
def analyze_routine(self, routine):
|
def analyze_routine(self, routine):
|
||||||
assert isinstance(routine, Routine)
|
assert isinstance(routine, Routine)
|
||||||
@ -520,7 +521,9 @@ class Analyzer(object):
|
|||||||
type_ = self.get_type(instr.location)
|
type_ = self.get_type(instr.location)
|
||||||
if not isinstance(type_, (RoutineType, VectorType)):
|
if not isinstance(type_, (RoutineType, VectorType)):
|
||||||
raise TypeMismatchError(instr, instr.location.name)
|
raise TypeMismatchError(instr, instr.location.name)
|
||||||
context.mark_as_called(instr.location, type_)
|
|
||||||
|
self.current_routine.called_routines.add((instr.location, type_))
|
||||||
|
|
||||||
if isinstance(type_, VectorType):
|
if isinstance(type_, VectorType):
|
||||||
type_ = type_.of_type
|
type_ = type_.of_type
|
||||||
for ref in type_.inputs:
|
for ref in type_.inputs:
|
||||||
@ -538,7 +541,8 @@ class Analyzer(object):
|
|||||||
|
|
||||||
if not isinstance(type_, (RoutineType, VectorType)):
|
if not isinstance(type_, (RoutineType, VectorType)):
|
||||||
raise TypeMismatchError(instr, location.name)
|
raise TypeMismatchError(instr, location.name)
|
||||||
context.mark_as_called(instr.location, type_)
|
|
||||||
|
self.current_routine.called_routines.add((instr.location, type_))
|
||||||
|
|
||||||
# assert that the dest routine's inputs are all initialized
|
# assert that the dest routine's inputs are all initialized
|
||||||
if isinstance(type_, VectorType):
|
if isinstance(type_, VectorType):
|
||||||
|
@ -36,6 +36,7 @@ def construct_callgraph(program):
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Reflexive closure
|
# Reflexive closure
|
||||||
|
# (Note, this information isn't used anywhere yet)
|
||||||
|
|
||||||
for routine in program.routines:
|
for routine in program.routines:
|
||||||
potentially_called_by = []
|
potentially_called_by = []
|
||||||
|
@ -329,6 +329,3 @@ class AnalysisContext(object):
|
|||||||
return self.symtab.fetch_local_type(self.routine.name, ref.name).max_range
|
return self.symtab.fetch_local_type(self.routine.name, ref.name).max_range
|
||||||
else:
|
else:
|
||||||
return self.symtab.fetch_global_type(ref.name).max_range
|
return self.symtab.fetch_global_type(ref.name).max_range
|
||||||
|
|
||||||
def mark_as_called(self, location, type_):
|
|
||||||
self.called_routines.add((location, type_))
|
|
||||||
|
Loading…
Reference in New Issue
Block a user