def __iter__(self):
yield from self.__items
+ @_functools.lru_cache(maxsize=None)
def __contains__(self, key):
if isinstance(key, int):
return self.__opcodes.__contains__(key)
+ elif isinstance(key, int):
+ for (opcode, insn) in self.__opcodes.items():
+ if ((opcode.value & opcode.mask) ==
+ (key & opcode.mask)):
+ return True
+ return False
elif isinstance(key, str):
return self.__names.__contains__(key)
else:
raise KeyError(key)
+ @_functools.lru_cache(maxsize=None)
def __getitem__(self, key):
- if isinstance(key, int):
+ if isinstance(key, Opcode):
return self.__opcodes.__getitem__(key)
+ elif isinstance(key, int):
+ for (opcode, insn) in self.__opcodes.items():
+ if ((opcode.value & opcode.mask) ==
+ (key & opcode.mask)):
+ return insn
+ raise KeyError(key)
elif isinstance(key, str):
return self.__names.__getitem__(key)
else: