mirror of
https://github.com/catseye/SixtyPical.git
synced 2024-09-28 02:55:59 +00:00
Pass next routine to each routine being compiled.
This commit is contained in:
parent
ea788264f7
commit
b9df1482c6
@ -122,10 +122,11 @@ class Compiler(object):
|
|||||||
compilation_roster = [['main']] + [[routine.name] for routine in program.routines if routine.name != 'main']
|
compilation_roster = [['main']] + [[routine.name] for routine in program.routines if routine.name != 'main']
|
||||||
|
|
||||||
for roster_row in compilation_roster:
|
for roster_row in compilation_roster:
|
||||||
for routine_name in roster_row[0:-1]:
|
for i, routine_name in enumerate(roster_row):
|
||||||
self.compile_routine(self.routines[routine_name], skip_final_goto=True)
|
if i < len(roster_row) - 1:
|
||||||
routine_name = roster_row[-1]
|
self.compile_routine(self.routines[routine_name], next_routine=self.routines[roster_row[i + 1]])
|
||||||
self.compile_routine(self.routines[routine_name])
|
else:
|
||||||
|
self.compile_routine(self.routines[routine_name])
|
||||||
|
|
||||||
for location, label in self.trampolines.items():
|
for location, label in self.trampolines.items():
|
||||||
self.emitter.resolve_label(label)
|
self.emitter.resolve_label(label)
|
||||||
@ -155,9 +156,9 @@ class Compiler(object):
|
|||||||
if defn.initial is None and defn.addr is None:
|
if defn.initial is None and defn.addr is None:
|
||||||
self.emitter.resolve_bss_label(label)
|
self.emitter.resolve_bss_label(label)
|
||||||
|
|
||||||
def compile_routine(self, routine, skip_final_goto=False):
|
def compile_routine(self, routine, next_routine=None):
|
||||||
self.current_routine = routine
|
self.current_routine = routine
|
||||||
self.skip_final_goto = skip_final_goto
|
self.skip_final_goto = (next_routine is not None)
|
||||||
self.final_goto_seen = False
|
self.final_goto_seen = False
|
||||||
assert isinstance(routine, Routine)
|
assert isinstance(routine, Routine)
|
||||||
if routine.block:
|
if routine.block:
|
||||||
@ -170,8 +171,11 @@ class Compiler(object):
|
|||||||
|
|
||||||
def compile_block(self, block):
|
def compile_block(self, block):
|
||||||
assert isinstance(block, Block)
|
assert isinstance(block, Block)
|
||||||
|
block.shallow_contains_goto = False
|
||||||
for instr in block.instrs:
|
for instr in block.instrs:
|
||||||
self.compile_instr(instr)
|
self.compile_instr(instr)
|
||||||
|
if isinstance(instr, GoTo):
|
||||||
|
block.shallow_contains_goto = True
|
||||||
|
|
||||||
def compile_instr(self, instr):
|
def compile_instr(self, instr):
|
||||||
if isinstance(instr, SingleOp):
|
if isinstance(instr, SingleOp):
|
||||||
|
Loading…
Reference in New Issue
Block a user