comparison python/ir/instruction.py @ 147:4e79484a9d47

Moved core to ir folder
author Windel Bouwman
date Fri, 22 Feb 2013 10:33:48 +0100
parents python/ppci/core/instruction.py@9e552d34bd60
children b28a11c01dbe
comparison
equal deleted inserted replaced
146:91af0e40f868 147:4e79484a9d47
1
2 from .value import Value
3
4 def Enum(**enums):
5 return type('Enum', (), enums)
6
7 class Instruction(Value):
8 """ Base class for all instructions. """
9 pass
10
11 class CallInstruction(Instruction):
12 def __init__(self, callee, arguments):
13 super().__init__()
14 self.callee = callee
15 self.arguments = arguments
16
17 BinOps = Enum(Add=1, Sub=2, Mul=3)
18
19 class BinaryOperator(Instruction):
20 def __init__(self, operation, value1, value2):
21 assert value1
22 assert value2
23 print('operation is in binops:', operation in BinOps)
24 # Check types of the two operands:
25 self.value1 = value1
26 self.value2 = value2
27 self.operation = operation
28
29 class LoadInstruction(Instruction):
30 def __init__(self, ptr, name, insertBefore):
31 self.setName(name)
32