use of jadx.core.dex.nodes.BlockNode in project jadx by skylot.
the class BlockSplitter method setupConnectionsFromJumps.
private static void setupConnectionsFromJumps(MethodNode mth, Map<Integer, BlockNode> blocksMap) {
for (BlockNode block : mth.getBasicBlocks()) {
for (InsnNode insn : block.getInstructions()) {
List<JumpInfo> jumps = insn.getAll(AType.JUMP);
for (JumpInfo jump : jumps) {
BlockNode srcBlock = getBlock(jump.getSrc(), blocksMap);
BlockNode thisBlock = getBlock(jump.getDest(), blocksMap);
connect(srcBlock, thisBlock);
}
}
}
}
use of jadx.core.dex.nodes.BlockNode in project jadx by skylot.
the class BlockSplitter method isDoWhile.
private static boolean isDoWhile(Map<Integer, BlockNode> blocksMap, BlockNode curBlock, InsnNode insn) {
// split 'do-while' block (last instruction: 'if', target this block)
if (insn.getType() != InsnType.IF) {
return false;
}
IfNode ifs = (IfNode) insn;
BlockNode targetBlock = blocksMap.get(ifs.getTarget());
return targetBlock == curBlock;
}
use of jadx.core.dex.nodes.BlockNode in project jadx by skylot.
the class BlockSplitter method startNewBlock.
static BlockNode startNewBlock(MethodNode mth, int offset) {
BlockNode block = new BlockNode(mth.getBasicBlocks().size(), offset);
mth.getBasicBlocks().add(block);
return block;
}
use of jadx.core.dex.nodes.BlockNode in project jadx by skylot.
the class BlockSplitter method removeEmptyBlock.
static boolean removeEmptyBlock(BlockNode block) {
if (canRemoveBlock(block)) {
if (block.getSuccessors().size() == 1) {
BlockNode successor = block.getSuccessors().get(0);
block.getPredecessors().forEach(pred -> {
pred.getSuccessors().remove(block);
BlockSplitter.connect(pred, successor);
BlockSplitter.replaceTarget(pred, block, successor);
pred.updateCleanSuccessors();
});
BlockSplitter.removeConnection(block, successor);
} else {
block.getPredecessors().forEach(pred -> {
pred.getSuccessors().remove(block);
pred.updateCleanSuccessors();
});
}
block.add(AFlag.REMOVE);
block.getSuccessors().clear();
block.getPredecessors().clear();
return true;
}
return false;
}
use of jadx.core.dex.nodes.BlockNode in project jadx by skylot.
the class BlockSplitter method expandMoveMulti.
private static void expandMoveMulti(MethodNode mth) {
for (BlockNode block : mth.getBasicBlocks()) {
List<InsnNode> insnsList = block.getInstructions();
int len = insnsList.size();
for (int i = 0; i < len; i++) {
InsnNode insn = insnsList.get(i);
if (insn.getType() == InsnType.MOVE_MULTI) {
int mvCount = insn.getArgsCount() / 2;
for (int j = 0; j < mvCount; j++) {
InsnNode mv = new InsnNode(InsnType.MOVE, 1);
int startArg = j * 2;
mv.setResult((RegisterArg) insn.getArg(startArg));
mv.addArg(insn.getArg(startArg + 1));
mv.copyAttributesFrom(insn);
if (j == 0) {
mv.setOffset(insn.getOffset());
insnsList.set(i, mv);
} else {
insnsList.add(i + j, mv);
}
}
i += mvCount - 1;
len = insnsList.size();
}
}
}
}
Aggregations