140 | 140 |
def analyze_program(self, program):
|
141 | 141 |
assert isinstance(program, Program)
|
142 | 142 |
for routine in program.routines:
|
143 | |
context = self.analyze_routine(routine)
|
|
143 |
context, type_ = self.analyze_routine(routine)
|
|
144 |
if type_:
|
|
145 |
routine.routine_type = type_
|
144 | 146 |
routine.encountered_gotos = list(context.encountered_gotos()) if context else []
|
145 | 147 |
routine.called_routines = list(context.called_routines) if context else []
|
146 | 148 |
|
147 | 149 |
def analyze_routine(self, routine):
|
148 | 150 |
assert isinstance(routine, Routine)
|
|
151 |
type_ = self.get_type_for_name(routine.name)
|
|
152 |
|
149 | 153 |
if routine.block is None:
|
150 | 154 |
# it's an extern, that's fine
|
151 | |
return None
|
|
155 |
return None, type_
|
152 | 156 |
|
153 | 157 |
self.current_routine = routine
|
154 | |
type_ = self.get_type_for_name(routine.name)
|
|
158 |
|
155 | 159 |
context = AnalysisContext(self.symtab, routine, type_.inputs, type_.outputs, type_.trashes)
|
156 | 160 |
|
157 | 161 |
# register any local statics as already-initialized
|
|
209 | 213 |
|
210 | 214 |
self.exit_contexts = None
|
211 | 215 |
self.current_routine = None
|
212 | |
return context
|
|
216 |
return context, type_
|
213 | 217 |
|
214 | 218 |
def analyze_block(self, block, context):
|
215 | 219 |
assert isinstance(block, Block)
|