git @ Cat's Eye Technologies SixtyPical / b9df148
Pass next routine to each routine being compiled. Chris Pressey 3 years ago
1 changed file(s) with 10 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
121121 compilation_roster = [['main']] + [[routine.name] for routine in program.routines if routine.name != 'main']
122122
123123 for roster_row in compilation_roster:
124 for routine_name in roster_row[0:-1]:
125 self.compile_routine(self.routines[routine_name], skip_final_goto=True)
126 routine_name = roster_row[-1]
127 self.compile_routine(self.routines[routine_name])
124 for i, routine_name in enumerate(roster_row):
125 if i < len(roster_row) - 1:
126 self.compile_routine(self.routines[routine_name], next_routine=self.routines[roster_row[i + 1]])
127 else:
128 self.compile_routine(self.routines[routine_name])
128129
129130 for location, label in self.trampolines.items():
130131 self.emitter.resolve_label(label)
154155 if defn.initial is None and defn.addr is None:
155156 self.emitter.resolve_bss_label(label)
156157
157 def compile_routine(self, routine, skip_final_goto=False):
158 def compile_routine(self, routine, next_routine=None):
158159 self.current_routine = routine
159 self.skip_final_goto = skip_final_goto
160 self.skip_final_goto = (next_routine is not None)
160161 self.final_goto_seen = False
161162 assert isinstance(routine, Routine)
162163 if routine.block:
169170
170171 def compile_block(self, block):
171172 assert isinstance(block, Block)
173 block.shallow_contains_goto = False
172174 for instr in block.instrs:
173175 self.compile_instr(instr)
176 if isinstance(instr, GoTo):
177 block.shallow_contains_goto = True
174178
175179 def compile_instr(self, instr):
176180 if isinstance(instr, SingleOp):