1
0
mirror of https://github.com/catseye/SixtyPical.git synced 2024-11-25 07:32:16 +00:00

Inch toward compiling statics.

This commit is contained in:
Chris Pressey 2018-02-09 14:44:41 +00:00
parent 71cded0297
commit 52fb1dc6b9

View File

@ -31,6 +31,7 @@ class Compiler(object):
self.routines = {}
self.labels = {}
self.trampolines = {} # Location -> Label
self.current_routine = None
# helper methods
@ -58,6 +59,10 @@ class Compiler(object):
return length
def get_label(self, name):
if self.current_routine and hasattr(self.current_routine, 'statics'):
for static in self.current_routine.statics:
if static.location.name == name:
raise NotImplementedError("static " + name)
return self.labels[name]
# visitor methods
@ -112,11 +117,13 @@ class Compiler(object):
def compile_routine(self, routine):
self.current_routine = routine
assert isinstance(routine, Routine)
if routine.block:
self.emitter.resolve_label(self.get_label(routine.name))
self.compile_block(routine.block)
self.emitter.emit(RTS())
self.current_routine = None
def compile_block(self, block):
assert isinstance(block, Block)