@classmethod
def build_action(cls, definition):
action_class = getattr(actions, definition['action_class'])
- required_bits = definition['required_bits']
+ required_bits = cls.parse_bits(definition['required_bits'])
data = definition.get('data', {})
return action_class(required_bits, **data)
@classmethod
def new_location(cls, definition):
+ if 'bits' in definition:
+ bits = cls.parse_bits(definition['bits'])
+ else:
+ bits = cls.generate_bitwise_operand()
return cls.import_location({
- 'bitwise_operand': cls.generate_bitwise_operand(),
+ 'bitwise_operand': bits,
'actions': definition['actions'],
})
+ @classmethod
+ def parse_bits(self, bit_list):
+ # Convert names to numbers if applicable.
+ return frozenset(BITS.get(bit, bit) for bit in bit_list)
+
def export(self):
return {
'bitwise_operand': self.bitwise_operand,