Package jadx.core.dex.visitors.regions
Class TernaryMod
java.lang.Object
jadx.core.dex.visitors.regions.AbstractRegionVisitor
jadx.core.dex.visitors.regions.TernaryMod
- All Implemented Interfaces:
IRegionIterativeVisitor,IRegionVisitor
Convert 'if' to ternary operation
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleancheckLineStats(InsnNode t, InsnNode e) Return 'true' if there are several args with same source linesprivate static voidclearConditionBlocks(List<BlockNode> conditionBlocks, BlockNode header) private static booleancontainsTernary(InsnNode insn) booleanenterRegion(MethodNode mth, IRegion region) private static BlockNodegetTernaryInsnBlock(IContainer thenRegion) private static booleanmakeTernaryInsn(MethodNode mth, IfRegion ifRegion) static voidprocess(MethodNode mth) private static booleanprocessOneBranchTernary(MethodNode mth, IfRegion ifRegion) Convert one variable change with only 'then' branch: 'if (c) {r = a;}' to 'r = c ? a : r' Convert if 'r' used only onceprivate static booleanprocessRegion(MethodNode mth, IRegion region) private static voidreplaceWithTernary(MethodNode mth, IfRegion ifRegion, BlockNode block, InsnNode insn) private static booleanverifyLineHints(MethodNode mth, InsnNode thenInsn, InsnNode elseInsn) booleanvisitRegion(MethodNode mth, IRegion region) If return 'true' traversal will be restarted.Methods inherited from class jadx.core.dex.visitors.regions.AbstractRegionVisitor
leaveRegion, processBlock
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
TernaryMod
private TernaryMod()
-
-
Method Details
-
process
-
enterRegion
- Specified by:
enterRegionin interfaceIRegionVisitor- Overrides:
enterRegionin classAbstractRegionVisitor- Returns:
- true for traverse sub-blocks, false otherwise.
-
visitRegion
Description copied from interface:IRegionIterativeVisitorIf return 'true' traversal will be restarted.- Specified by:
visitRegionin interfaceIRegionIterativeVisitor
-
processRegion
-
makeTernaryInsn
-
verifyLineHints
-
clearConditionBlocks
-
getTernaryInsnBlock
-
containsTernary
-
checkLineStats
Return 'true' if there are several args with same source lines -
processOneBranchTernary
Convert one variable change with only 'then' branch: 'if (c) {r = a;}' to 'r = c ? a : r' Convert if 'r' used only once -
replaceWithTernary
private static void replaceWithTernary(MethodNode mth, IfRegion ifRegion, BlockNode block, InsnNode insn)
-