use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.
the class PrepareForCodeGen method modifyArith.
/**
* Replace arithmetic operation with short form
* ('a = a + 2' => 'a += 2')
*/
private static void modifyArith(BlockNode block) {
List<InsnNode> list = block.getInstructions();
for (InsnNode insn : list) {
if (insn.getType() == InsnType.ARITH) {
RegisterArg res = insn.getResult();
InsnArg arg = insn.getArg(0);
boolean replace = false;
if (res.equals(arg)) {
replace = true;
} else if (arg.isRegister()) {
RegisterArg regArg = (RegisterArg) arg;
replace = res.equalRegisterAndType(regArg);
}
if (replace) {
insn.add(AFlag.ARITH_ONEARG);
}
}
}
}
use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.
the class BlockProcessor method duplicateReturnInsn.
private static InsnNode duplicateReturnInsn(InsnNode returnInsn) {
InsnNode insn = new InsnNode(returnInsn.getType(), returnInsn.getArgsCount());
if (returnInsn.getArgsCount() == 1) {
RegisterArg arg = (RegisterArg) returnInsn.getArg(0);
insn.addArg(InsnArg.reg(arg.getRegNum(), arg.getType()));
}
insn.copyAttributesFrom(returnInsn);
insn.setOffset(returnInsn.getOffset());
insn.setSourceLine(returnInsn.getSourceLine());
return insn;
}
use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.
the class BlockProcessor method isReturnArgAssignInPred.
private static boolean isReturnArgAssignInPred(List<BlockNode> preds, InsnNode returnInsn) {
RegisterArg arg = (RegisterArg) returnInsn.getArg(0);
int regNum = arg.getRegNum();
for (BlockNode pred : preds) {
for (InsnNode insnNode : pred.getInstructions()) {
RegisterArg result = insnNode.getResult();
if (result != null && result.getRegNum() == regNum) {
return true;
}
}
}
return false;
}
use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.
the class DebugInfoVisitor method visit.
@Override
public void visit(MethodNode mth) throws JadxException {
int debugOffset = mth.getDebugInfoOffset();
if (debugOffset > 0) {
InsnNode[] insnArr = mth.getInstructions();
DebugInfoParser debugInfoParser = new DebugInfoParser(mth, debugOffset, insnArr);
debugInfoParser.process();
// set method source line from first instruction
if (insnArr.length != 0) {
for (InsnNode insn : insnArr) {
if (insn != null) {
int line = insn.getSourceLine();
if (line != 0) {
mth.setSourceLine(line - 1);
}
break;
}
}
}
if (!mth.getReturnType().equals(ArgType.VOID)) {
// fix debug info for splitter 'return' instructions
for (BlockNode exit : mth.getExitBlocks()) {
InsnNode ret = BlockUtils.getLastInsn(exit);
if (ret == null) {
continue;
}
InsnNode oldRet = insnArr[ret.getOffset()];
if (oldRet == ret) {
continue;
}
RegisterArg oldArg = (RegisterArg) oldRet.getArg(0);
RegisterArg newArg = (RegisterArg) ret.getArg(0);
newArg.mergeDebugInfo(oldArg.getType(), oldArg.getName());
ret.setSourceLine(oldRet.getSourceLine());
}
}
}
mth.unloadInsnArr();
}
use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.
the class DependencyCollector method processInsn.
// TODO: add custom instructions processing
private static void processInsn(DexNode dex, Set<ClassNode> depList, InsnNode insnNode) {
RegisterArg result = insnNode.getResult();
if (result != null) {
addDep(dex, depList, result.getType());
}
for (InsnArg arg : insnNode.getArguments()) {
if (arg.isInsnWrap()) {
processInsn(dex, depList, ((InsnWrapArg) arg).getWrapInsn());
} else {
addDep(dex, depList, arg.getType());
}
}
processCustomInsn(dex, depList, insnNode);
}
Aggregations