Search in sources :

Example 1 with InsnRemover

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();
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) InsnNode(jadx.core.dex.nodes.InsnNode) InsnRemover(jadx.core.utils.InsnRemover)

Example 2 with InsnRemover

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();
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) InsnNode(jadx.core.dex.nodes.InsnNode) InsnRemover(jadx.core.utils.InsnRemover)

Example 3 with InsnRemover

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();
}
Also used : IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) InsnNode(jadx.core.dex.nodes.InsnNode) InsnRemover(jadx.core.utils.InsnRemover)

Example 4 with InsnRemover

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);
}
Also used : InsnRemover(jadx.core.utils.InsnRemover)

Example 5 with InsnRemover

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;
        }
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) InsnNode(jadx.core.dex.nodes.InsnNode) InsnRemover(jadx.core.utils.InsnRemover)

Aggregations

InsnRemover (jadx.core.utils.InsnRemover)6 InsnNode (jadx.core.dex.nodes.InsnNode)5 BlockNode (jadx.core.dex.nodes.BlockNode)4 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)2