Search in sources :

Example 1 with Mode

use of jadx.core.dex.regions.conditions.IfCondition.Mode in project jadx by skylot.

the class IfMakerHelper method mergeIfInfo.

private static IfInfo mergeIfInfo(IfInfo first, IfInfo second, boolean followThenBranch) {
    Mode mergeOperation = followThenBranch ? Mode.AND : Mode.OR;
    IfCondition condition = IfCondition.merge(mergeOperation, first.getCondition(), second.getCondition());
    // skip synthetic successor if both parts leads to same block
    BlockNode thenBlock;
    BlockNode elseBlock;
    if (followThenBranch) {
        thenBlock = second.getThenBlock();
        elseBlock = getCrossBlock(first.getElseBlock(), second.getElseBlock());
    } else {
        thenBlock = getCrossBlock(first.getThenBlock(), second.getThenBlock());
        elseBlock = second.getElseBlock();
    }
    IfInfo result = new IfInfo(condition, thenBlock, elseBlock);
    result.setIfBlock(first.getIfBlock());
    result.merge(first, second);
    BlockNode otherPathBlock = followThenBranch ? first.getElseBlock() : first.getThenBlock();
    skipSimplePath(otherPathBlock, result.getSkipBlocks());
    return result;
}
Also used : BlockNode(jadx.core.dex.nodes.BlockNode) Mode(jadx.core.dex.regions.conditions.IfCondition.Mode) IfInfo(jadx.core.dex.regions.conditions.IfInfo) IfCondition(jadx.core.dex.regions.conditions.IfCondition)

Aggregations

BlockNode (jadx.core.dex.nodes.BlockNode)1 IfCondition (jadx.core.dex.regions.conditions.IfCondition)1 Mode (jadx.core.dex.regions.conditions.IfCondition.Mode)1 IfInfo (jadx.core.dex.regions.conditions.IfInfo)1