Add accessors to instructions.

This commit is contained in:
whitequark 2015-07-14 22:18:38 +03:00
parent bdcb24108b
commit 9ff9f85f19
1 changed files with 15 additions and 0 deletions

View File

@ -383,6 +383,9 @@ class Branch(Terminator):
def opcode(self):
return "branch"
def target(self):
return self.operands[0]
class BranchIf(Terminator):
"""
A conditional branch instruction.
@ -399,6 +402,15 @@ class BranchIf(Terminator):
def opcode(self):
return "branch_if"
def condition(self):
return self.operands[0]
def if_true(self):
return self.operands[1]
def if_false(self):
return self.operands[2]
class Return(Terminator):
"""
A return instruction.
@ -413,6 +425,9 @@ class Return(Terminator):
def opcode(self):
return "return"
def value(self):
return self.operands[0]
class Eval(Instruction):
"""
An instruction that evaluates an AST fragment.