示例#1
0
def writeSelection(self, rel):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "BR" + str(self.switchIT(rel)).upper()
    self.gen[len(self.gen) - 1].partA = grammar.Parser.get_last(self)
    self.gen[len(self.gen) - 1].Target = len(self.gen) + 1
    self.gen[len(self.gen) - 1].Backpatch = str(len(self.gen) - 2)
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "BR"
示例#2
0
def iteration_instruction_write(self, rel):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "BR" + str(self.switchIT(rel)).upper()
    self.gen[len(self.gen) - 1].partA = grammar.Parser.get_last(self)
    self.gen[len(self.gen) - 1].Target = len(self.gen) + 1
    self.gen[len(self.gen) - 1].Backpatch = "bpin:" + str(len(self.gen) + 1)
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "BR"
示例#3
0
def writeArgument(self, z):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "ARGS"
    if z.id == "NUM":
        self.gen[len(self.gen) - 1].Target = z.content
    else:
        self.gen[len(self.gen) - 1].Target = z.id
示例#4
0
def ArrayInstruct(self, value):
    self.gen.append(grammar.Instruction())
    if value == 0:
        self.gen[len(self.gen) - 1].Action = "DISP"
        self.gen[len(self.gen) - 1].partA = ""
        self.gen[len(self.gen) - 1].partB = str(int("10") * 4)
    else:
        self.gen[len(self.gen) - 1].Action = "MUL"
        self.gen[len(self.gen) - 1].partA = "4"
        if value != 0:
            self.gen[len(self.gen) - 1].partB = "ops"
        else:
            self.gen[len(self.gen) - 1].partB = "gank"
        self.gen[len(self.gen) - 1].Target = self.get_newt()
        self.gen.append(grammar.Instruction())
        self.gen[len(self.gen) - 1].Action = "DISP"
        self.gen[len(self.gen) - 1].partA = ""
        self.gen[len(self.gen) - 1].partB = self.get_last()
示例#5
0
def writefunction(self, z):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "CALL"
    if z.id == "NUM":
        self.gen[len(self.gen) - 1].Target = z.content
    else:
        self.gen[len(self.gen) - 1].partA = z.id
    self.gen[len(self.gen) - 1].partB = len(z.paramTypes)
    self.gen[len(self.gen) - 1].Target = grammar.Parser.get_newt(self)
示例#6
0
def writeReturnpre(self):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "RETURN"
示例#7
0
def writeElse(self):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "BR"
示例#8
0
def closeBlock(self):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "END"
    self.gen[len(self.gen) - 1].partA = "BLOCK"
示例#9
0
def openBlock(self):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "BLOCK"
示例#10
0
def writeEQU(self, last, ender):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "ASSIGN"
    self.gen[len(self.gen) - 1].partA = last
    self.gen[len(self.gen) - 1].Target = ender
示例#11
0
def iteration_instruction_write2(self, backup, tempbackpatch):
    self.gen.append(grammar.Instruction())
    self.gen[len(self.gen) - 1].Action = "BR"
    self.gen[len(self.gen) - 1].Target = tempbackpatch
    self.gen[backup].Target = len(self.gen)
    self.gen[len(self.gen) - 1].Backpatch = "val for bpw"