def _insn_to_item(self, insn): insn = REIL.Insn(insn) def _arg_in(arg): if arg.type == REIL.A_NONE: return () elif arg.type == REIL.A_CONST: return ( arg.type, arg.size, _U64IN(arg.val) ) else: return ( arg.type, arg.size, arg.name ) if insn.has_attr(REIL.IATTR_BIN): # JSON doesn't support binary data insn.set_attr(REIL.IATTR_BIN, base64.b64encode(insn.get_attr(REIL.IATTR_BIN))) # JSON doesn't support numeric keys attr = [ (key, val) for key, val in insn.attr.items() ] return { 'addr': _U64IN(insn.addr), 'size': insn.size, 'inum': insn.inum, 'op': insn.op, \ 'a': _arg_in(insn.a), 'b': _arg_in(insn.b), 'c': _arg_in(insn.c), \ 'attr': attr }
def __iter__(self): for item in self.collection.find().sort(self.INDEX): yield REIL.Insn(self._insn_from_item(item))