Mercurial > lcfOS
diff python/ppci/core/instruction.py @ 110:9e552d34bd60
Work on compiler
author | Windel Bouwman |
---|---|
date | Fri, 04 Jan 2013 15:25:58 +0100 |
parents | ed230e947dc6 |
children |
line wrap: on
line diff
--- a/python/ppci/core/instruction.py Tue Jan 01 17:17:44 2013 +0100 +++ b/python/ppci/core/instruction.py Fri Jan 04 15:25:58 2013 +0100 @@ -1,15 +1,26 @@ from .value import Value +def Enum(**enums): + return type('Enum', (), enums) + class Instruction(Value): """ Base class for all instructions. """ pass class CallInstruction(Instruction): - pass + def __init__(self, callee, arguments): + super().__init__() + self.callee = callee + self.arguments = arguments + +BinOps = Enum(Add=1, Sub=2, Mul=3) class BinaryOperator(Instruction): def __init__(self, operation, value1, value2): + assert value1 + assert value2 + print('operation is in binops:', operation in BinOps) # Check types of the two operands: self.value1 = value1 self.value2 = value2