diff options
Diffstat (limited to 'pp2cc.py')
-rwxr-xr-x | pp2cc.py | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -30,6 +30,8 @@ __email__ = "uwretep@gmail.com" class Logger(object): def __init__(self): pass + def info(self, message, linked_node=None): + self.log(message, linked_node=linked_node, type="info") def warning(self, message, linked_node=None): self.log(message, linked_node=linked_node, type="warning") def error(self, message, linked_node=None): @@ -149,14 +151,23 @@ class Parse(object): self.codeSegment += self.parseStatement(thing, root_node) def compileASM(self): """Processes lines of assembly and merge it into the output""" - pass + for label in self.asm_node.labels: + new_label = label + # rename existing names + if label in self.labels: + new_label = self.uniqLbl(label) + self.asm_node.renameId(label, new_label) + self.labels.add(new_label) + self.codeSegment += self.asm_node.getCodeLines() def getSource(self): """Retrieves the ASM source. You need to compile it first""" output = [] output.append("@DATA") for varName, size in self.varNames.iteritems(): padding = " " * (16 - len(varName) - 1) - output.append(varName + padding + " DS " + str(size)) + assert size > 0, "Size of '{}' must be at least 1".format(varName) + initializers = "0,".repeat(size)[0:-1] + output.append(varName + padding + " DW " + initializers) output.append("") output.append("@CODE") # initialization of global variables |