git @ Cat's Eye Technologies SixtyPical / 987974c
Simplify, fixing an apparent bug in the process. Chris Pressey 3 years ago
3 changed file(s) with 8 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
140140 def analyze_program(self, program):
141141 assert isinstance(program, Program)
142142 for routine in program.routines:
143 routine.called_routines = set()
143144 context, type_ = self.analyze_routine(routine)
144145 if type_:
145146 routine.routine_type = type_
146147 routine.encountered_gotos = list(context.encountered_gotos()) if context else []
147 routine.called_routines = list(context.called_routines) if context else []
148 routine.called_routines = list(routine.called_routines)
148149
149150 def analyze_routine(self, routine):
150151 assert isinstance(routine, Routine)
519520 type_ = self.get_type(instr.location)
520521 if not isinstance(type_, (RoutineType, VectorType)):
521522 raise TypeMismatchError(instr, instr.location.name)
522 context.mark_as_called(instr.location, type_)
523
524 self.current_routine.called_routines.add((instr.location, type_))
525
523526 if isinstance(type_, VectorType):
524527 type_ = type_.of_type
525528 for ref in type_.inputs:
537540
538541 if not isinstance(type_, (RoutineType, VectorType)):
539542 raise TypeMismatchError(instr, location.name)
540 context.mark_as_called(instr.location, type_)
543
544 self.current_routine.called_routines.add((instr.location, type_))
541545
542546 # assert that the dest routine's inputs are all initialized
543547 if isinstance(type_, VectorType):
3535 }
3636
3737 # Reflexive closure
38 # (Note, this information isn't used anywhere yet)
3839
3940 for routine in program.routines:
4041 potentially_called_by = []
328328 return self.symtab.fetch_local_type(self.routine.name, ref.name).max_range
329329 else:
330330 return self.symtab.fetch_global_type(ref.name).max_range
331
332 def mark_as_called(self, location, type_):
333 self.called_routines.add((location, type_))