comparison python/ir/instruction.py @ 262:ed14e077124c

Added conditional branch instructions
author Windel Bouwman
date Fri, 09 Aug 2013 11:30:11 +0200
parents 444b9df2ed99
children f8b5da5784b8
comparison
equal deleted inserted replaced
261:444b9df2ed99 262:ed14e077124c
34 34
35 def replaceby(self, v2): 35 def replaceby(self, v2):
36 for use_ins in self.used_by: 36 for use_ins in self.used_by:
37 use_ins.replaceValue(self, v2.value) 37 use_ins.replaceValue(self, v2.value)
38 assert not self.Used 38 assert not self.Used
39
39 40
40 class Variable(Value): 41 class Variable(Value):
41 pass 42 pass
42 43
43 44
96 def setParent(self, p): 97 def setParent(self, p):
97 self.parent = p 98 self.parent = p
98 Parent = property(getParent, setParent) 99 Parent = property(getParent, setParent)
99 100
100 def replaceValue(self, old, new): 101 def replaceValue(self, old, new):
102 # TODO: make this a generic function
101 raise NotImplementedError('{}'.format(type(self))) 103 raise NotImplementedError('{}'.format(type(self)))
102 104
103 @property 105 @property
104 def Position(self): 106 def Position(self):
105 return self.Block.Instructions.index(self) 107 return self.Block.Instructions.index(self)
184 self.value = value 186 self.value = value
185 self.addDef(target) 187 self.addDef(target)
186 188
187 def __repr__(self): 189 def __repr__(self):
188 return '{} = {}'.format(self.target, self.value) 190 return '{} = {}'.format(self.target, self.value)
191
189 192
190 # Data operations 193 # Data operations
191 class BinaryOperator(Instruction): 194 class BinaryOperator(Instruction):
192 def __init__(self, result, operation, value1, value2): 195 def __init__(self, result, operation, value1, value2):
193 super().__init__() 196 super().__init__()