use of jadx.core.utils.InsnRemover in project jadx by skylot.
the class BlockExceptionHandler method removeMonitorExitFromExcHandler.
private static void removeMonitorExitFromExcHandler(MethodNode mth, ExceptionHandler excHandler) {
for (BlockNode excBlock : excHandler.getBlocks()) {
InsnRemover remover = new InsnRemover(mth, excBlock);
for (InsnNode insn : excBlock.getInstructions()) {
if (insn.getType() == InsnType.MONITOR_ENTER) {
break;
}
if (insn.getType() == InsnType.MONITOR_EXIT) {
remover.addAndUnbind(insn);
}
}
remover.perform();
}
}
use of jadx.core.utils.InsnRemover in project jadx by skylot.
the class MoveInlineVisitor method moveInline.
public static void moveInline(MethodNode mth) {
InsnRemover remover = new InsnRemover(mth);
for (BlockNode block : mth.getBasicBlocks()) {
remover.setBlock(block);
for (InsnNode insn : block.getInstructions()) {
if (insn.getType() != InsnType.MOVE) {
continue;
}
if (processMove(mth, insn)) {
remover.addAndUnbind(insn);
}
}
remover.perform();
}
}
use of jadx.core.utils.InsnRemover in project jadx by skylot.
the class SimplifyVisitor method removeStringBuilderInsns.
/**
* Remove and unbind all instructions with StringBuilder
*/
private static void removeStringBuilderInsns(MethodNode mth, InvokeNode toStrInsn, List<InsnNode> chain) {
InsnRemover.unbindAllArgs(mth, toStrInsn);
for (InsnNode insnNode : chain) {
InsnRemover.unbindAllArgs(mth, insnNode);
}
InsnRemover insnRemover = new InsnRemover(mth);
for (InsnNode insnNode : chain) {
if (insnNode != toStrInsn) {
insnRemover.addAndUnbind(insnNode);
}
}
insnRemover.perform();
}
use of jadx.core.utils.InsnRemover in project jadx by skylot.
the class ModVisitor method visit.
@Override
public void visit(MethodNode mth) {
if (mth.isNoCode()) {
return;
}
InsnRemover remover = new InsnRemover(mth);
replaceStep(mth, remover);
removeStep(mth, remover);
iterativeRemoveStep(mth);
}
use of jadx.core.utils.InsnRemover in project jadx by skylot.
the class ReSugarCode method visit.
@Override
public void visit(MethodNode mth) throws JadxException {
if (mth.isNoCode()) {
return;
}
int k = 0;
while (true) {
boolean changed = false;
InsnRemover remover = new InsnRemover(mth);
for (BlockNode block : mth.getBasicBlocks()) {
remover.setBlock(block);
List<InsnNode> instructions = block.getInstructions();
int size = instructions.size();
for (int i = 0; i < size; i++) {
changed |= process(mth, instructions, i, remover);
}
remover.perform();
}
if (changed) {
CodeShrinkVisitor.shrinkMethod(mth);
} else {
break;
}
if (k++ > 100) {
mth.addWarnComment("Reached limit for ReSugarCode iterations");
break;
}
}
}
Aggregations