use of jadx.core.dex.instructions.args.InsnWrapArg in project jadx by skylot.
the class CodeShrinkVisitor method simplifyMoveInsns.
private static void simplifyMoveInsns(MethodNode mth, BlockNode block) {
List<InsnNode> insns = block.getInstructions();
int size = insns.size();
for (int i = 0; i < size; i++) {
InsnNode insn = insns.get(i);
if (insn.getType() == InsnType.MOVE) {
// replace 'move' with wrapped insn
InsnArg arg = insn.getArg(0);
if (arg.isInsnWrap()) {
InsnNode wrapInsn = ((InsnWrapArg) arg).getWrapInsn();
InsnRemover.unbindResult(mth, wrapInsn);
wrapInsn.setResult(insn.getResult().duplicate());
wrapInsn.inheritMetadata(insn);
wrapInsn.setOffset(insn.getOffset());
wrapInsn.remove(AFlag.WRAPPED);
block.getInstructions().set(i, wrapInsn);
}
}
}
}
use of jadx.core.dex.instructions.args.InsnWrapArg in project jadx by skylot.
the class InsnUtils method getConstValueByArg.
/**
* Search constant assigned to provided arg.
*
* @return LiteralArg, String, ArgType or null
*/
public static Object getConstValueByArg(RootNode root, InsnArg arg) {
if (arg.isLiteral()) {
return arg;
}
if (arg.isRegister()) {
RegisterArg reg = (RegisterArg) arg;
InsnNode parInsn = reg.getAssignInsn();
if (parInsn == null) {
return null;
}
if (parInsn.getType() == InsnType.MOVE) {
return getConstValueByArg(root, parInsn.getArg(0));
}
return getConstValueByInsn(root, parInsn);
}
if (arg.isInsnWrap()) {
InsnNode insn = ((InsnWrapArg) arg).getWrapInsn();
return getConstValueByInsn(root, insn);
}
return null;
}
use of jadx.core.dex.instructions.args.InsnWrapArg in project jadx by skylot.
the class InsnUtils method recursiveInsnCheck.
private static InsnNode recursiveInsnCheck(InsnNode insn, InsnType insnType, Predicate<InsnNode> test) {
if (insn.getType() == insnType && test.test(insn)) {
return insn;
}
for (InsnArg arg : insn.getArguments()) {
if (arg.isInsnWrap()) {
InsnNode wrapInsn = ((InsnWrapArg) arg).getWrapInsn();
InsnNode foundInsn = recursiveInsnCheck(wrapInsn, insnType, test);
if (foundInsn != null) {
return foundInsn;
}
}
}
return null;
}
use of jadx.core.dex.instructions.args.InsnWrapArg in project jadx by skylot.
the class InsnRemover method unbindArgUsage.
public static void unbindArgUsage(@Nullable MethodNode mth, InsnArg arg) {
if (arg instanceof RegisterArg) {
RegisterArg reg = (RegisterArg) arg;
SSAVar sVar = reg.getSVar();
if (sVar != null) {
sVar.removeUse(reg);
}
} else if (arg instanceof InsnWrapArg) {
InsnWrapArg wrap = (InsnWrapArg) arg;
unbindInsn(mth, wrap.getWrapInsn());
}
}
use of jadx.core.dex.instructions.args.InsnWrapArg in project jadx by skylot.
the class NameGen method makeNameFromInsn.
private String makeNameFromInsn(InsnNode insn) {
switch(insn.getType()) {
case INVOKE:
InvokeNode inv = (InvokeNode) insn;
return makeNameFromInvoke(inv.getCallMth());
case CONSTRUCTOR:
ConstructorInsn co = (ConstructorInsn) insn;
return makeNameForObject(co.getClassType().getType());
case ARRAY_LENGTH:
return "length";
case ARITH:
case TERNARY:
case CAST:
for (InsnArg arg : insn.getArguments()) {
if (arg.isInsnWrap()) {
InsnNode wrapInsn = ((InsnWrapArg) arg).getWrapInsn();
String wName = makeNameFromInsn(wrapInsn);
if (wName != null) {
return wName;
}
}
}
break;
default:
break;
}
return null;
}
Aggregations