use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.
the class InstructionRemover method unbindArgUsage.
public static void unbindArgUsage(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.RegisterArg in project jadx by skylot.
the class SSATransform method renameVariables.
private static void renameVariables(MethodNode mth) {
if (!mth.getSVars().isEmpty()) {
throw new JadxRuntimeException("SSA rename variables already executed");
}
int regsCount = mth.getRegsCount();
SSAVar[] vars = new SSAVar[regsCount];
int[] versions = new int[regsCount];
// init method arguments
for (RegisterArg arg : mth.getArguments(true)) {
int regNum = arg.getRegNum();
vars[regNum] = newSSAVar(mth, versions, arg, regNum);
}
BlockNode enterBlock = mth.getEnterBlock();
initPhiInEnterBlock(vars, enterBlock);
renameVar(mth, vars, versions, enterBlock);
}
use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.
the class SSATransform method removeBlockerInsns.
private static boolean removeBlockerInsns(MethodNode mth) {
boolean removed = false;
for (BlockNode block : mth.getBasicBlocks()) {
PhiListAttr phiList = block.get(AType.PHI_LIST);
if (phiList == null) {
continue;
}
// check if args must be removed
for (PhiInsn phi : phiList.getList()) {
for (int i = 0; i < phi.getArgsCount(); i++) {
RegisterArg arg = phi.getArg(i);
InsnNode parentInsn = arg.getAssignInsn();
if (parentInsn != null && parentInsn.contains(AFlag.REMOVE)) {
phi.removeArg(arg);
InstructionRemover.remove(mth, block, parentInsn);
removed = true;
}
}
}
}
return removed;
}
use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.
the class SSATransform method isSameArgs.
private static boolean isSameArgs(PhiInsn phi) {
boolean allSame = true;
SSAVar var = null;
for (int i = 0; i < phi.getArgsCount(); i++) {
RegisterArg arg = phi.getArg(i);
if (var == null) {
var = arg.getSVar();
} else if (var != arg.getSVar()) {
allSame = false;
break;
}
}
return allSame;
}
use of jadx.core.dex.instructions.args.RegisterArg in project jadx by skylot.
the class InsnNode method removeArg.
protected boolean removeArg(InsnArg arg) {
int count = getArgsCount();
for (int i = 0; i < count; i++) {
if (arg == arguments.get(i)) {
arguments.remove(i);
if (arg instanceof RegisterArg) {
RegisterArg reg = (RegisterArg) arg;
reg.getSVar().removeUse(reg);
}
return true;
}
}
return false;
}
Aggregations