Search in sources :

Example 21 with IContainer

use of jadx.core.dex.nodes.IContainer in project jadx by skylot.

the class RegionMakerVisitor method processSwitch.

private static void processSwitch(MethodNode mth, SwitchRegion sw) {
    for (IContainer c : sw.getBranches()) {
        if (!(c instanceof Region)) {
            continue;
        }
        Set<IBlock> blocks = new HashSet<IBlock>();
        RegionUtils.getAllRegionBlocks(c, blocks);
        if (blocks.isEmpty()) {
            addBreakToContainer((Region) c);
            continue;
        }
        for (IBlock block : blocks) {
            if (!(block instanceof BlockNode)) {
                continue;
            }
            BlockNode bn = (BlockNode) block;
            for (BlockNode s : bn.getCleanSuccessors()) {
                if (!blocks.contains(s) && !bn.contains(AFlag.SKIP) && !s.contains(AFlag.FALL_THROUGH)) {
                    addBreak(mth, c, bn);
                    break;
                }
            }
        }
    }
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) IBlock(jadx.core.dex.nodes.IBlock) IRegion(jadx.core.dex.nodes.IRegion) SwitchRegion(jadx.core.dex.regions.SwitchRegion) SynchronizedRegion(jadx.core.dex.regions.SynchronizedRegion) LoopRegion(jadx.core.dex.regions.loops.LoopRegion) Region(jadx.core.dex.regions.Region) IContainer(jadx.core.dex.nodes.IContainer) HashSet(java.util.HashSet)

Example 22 with IContainer

use of jadx.core.dex.nodes.IContainer in project jadx by skylot.

the class IfRegionVisitor method markElseIfChains.

/**
	 * Mark if-else-if chains
	 */
private static void markElseIfChains(IfRegion ifRegion) {
    if (hasSimpleReturnBlock(ifRegion.getThenRegion())) {
        return;
    }
    IContainer elsRegion = ifRegion.getElseRegion();
    if (elsRegion instanceof Region) {
        List<IContainer> subBlocks = ((Region) elsRegion).getSubBlocks();
        if (subBlocks.size() == 1 && subBlocks.get(0) instanceof IfRegion) {
            subBlocks.get(0).add(AFlag.ELSE_IF_CHAIN);
            elsRegion.add(AFlag.ELSE_IF_CHAIN);
        }
    }
}
Also used : IRegion(jadx.core.dex.nodes.IRegion) IfRegion(jadx.core.dex.regions.conditions.IfRegion) Region(jadx.core.dex.regions.Region) IContainer(jadx.core.dex.nodes.IContainer) IfRegion(jadx.core.dex.regions.conditions.IfRegion)

Aggregations

IContainer (jadx.core.dex.nodes.IContainer)22 IRegion (jadx.core.dex.nodes.IRegion)11 InsnNode (jadx.core.dex.nodes.InsnNode)6 Region (jadx.core.dex.regions.Region)6 IBlock (jadx.core.dex.nodes.IBlock)5 BlockNode (jadx.core.dex.nodes.BlockNode)4 IBranchRegion (jadx.core.dex.nodes.IBranchRegion)4 LoopRegion (jadx.core.dex.regions.loops.LoopRegion)4 ExceptionHandler (jadx.core.dex.trycatch.ExceptionHandler)4 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)3 SwitchRegion (jadx.core.dex.regions.SwitchRegion)3 SynchronizedRegion (jadx.core.dex.regions.SynchronizedRegion)3 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)3 InsnArg (jadx.core.dex.instructions.args.InsnArg)2 IfRegion (jadx.core.dex.regions.conditions.IfRegion)2 TryCatchBlock (jadx.core.dex.trycatch.TryCatchBlock)2 HashSet (java.util.HashSet)2 EdgeInsnAttr (jadx.core.dex.attributes.nodes.EdgeInsnAttr)1 InsnType (jadx.core.dex.instructions.InsnType)1 PhiInsn (jadx.core.dex.instructions.PhiInsn)1