def check_impl(self): from javatools import opcodes from itertools import izip left = self.ldata right = self.rdata offsets = list() if left is None or right is None: return True, None if len(left.code) != len(right.code): # code body change, can't determine constants return True, None for l, r in izip(left.disassemble(), right.disassemble()): if not ((l[0] == r[0]) and (l[1] == r[1])): # code body change, can't determine constants return True, None largs = l[2] rargs = r[2] if opcodes.has_const_arg(l[1]): largs, rargs = list(largs), list(rargs) largs[0] = left.cpool.deref_const(largs[0]) rargs[0] = right.cpool.deref_const(rargs[0]) if largs != rargs: offsets.append(l[0]) self.offsets = offsets return bool(self.offsets), None
def fn_pretty(self, c): from javatools import opcodes if not self.offsets: return None pr = list() for offset, code, args in c.disassemble(): if offset in self.offsets and opcodes.has_const_arg(code): name = opcodes.get_opname_by_code(code) data = c.cpool.pretty_deref_const(args[0]) pr.append((offset, name, data)) return pr