99
|
1
|
71
|
2 from .value import Value
|
70
|
3
|
110
|
4 def Enum(**enums):
|
|
5 return type('Enum', (), enums)
|
|
6
|
70
|
7 class Instruction(Value):
|
104
|
8 """ Base class for all instructions. """
|
70
|
9 pass
|
|
10
|
|
11 class CallInstruction(Instruction):
|
110
|
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)
|
70
|
18
|
|
19 class BinaryOperator(Instruction):
|
104
|
20 def __init__(self, operation, value1, value2):
|
110
|
21 assert value1
|
|
22 assert value2
|
|
23 print('operation is in binops:', operation in BinOps)
|
104
|
24 # Check types of the two operands:
|
|
25 self.value1 = value1
|
|
26 self.value2 = value2
|
|
27 self.operation = operation
|
70
|
28
|
|
29 class LoadInstruction(Instruction):
|
|
30 def __init__(self, ptr, name, insertBefore):
|
|
31 self.setName(name)
|
|
32
|