Package jadx.core.dex.visitors
Class SimplifyVisitor
java.lang.Object
jadx.core.dex.visitors.AbstractVisitor
jadx.core.dex.visitors.SimplifyVisitor
- All Implemented Interfaces:
IDexTreeVisitor
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncollectUseChain(MethodNode mth, InvokeNode insn, RegisterArg instanceArg) concatConstArgs(List<InsnArg> args) private static ArithNodeconvertFieldArith(MethodNode mth, InsnNode insn) Convert field arith operation to arith instruction (IPUT (ARITH (IGET, lit)) -> ARITH ((IGET))= lit)) private static InsnNodeconvertInvoke(MethodNode mth, InvokeNode insn) Simplify chains of calls to StringBuilder#append() plus constructor of StringBuilder.private static InsnNodeconvertStringBuilderChain(MethodNode mth, InvokeNode toStrInsn, List<InsnNode> chain) flattenInsnChainUntil(InsnNode insn, InsnType insnType) private static InsnArggetArgFromAppend(InsnNode chainInsn) private static InsnArggetConcatArg(List<String> concatList, List<InsnArg> args, int idx) private static @Nullable StringgetConstString(InsnArg arg) voidCalled after loading dex tree, but before visitor traversal.private static booleanisArithWideUpCast(@Nullable InsnNode parentInsn, ArgType argType, ArgType castToType) Keep cast to wide types in arith instructions, because arguments type determine instruction used in result bytecode.private static booleanisCastDuplicate(IndexInsnNode castInsn) private static booleanisConstConcatNeeded(List<InsnArg> args) private static InsnNodeprocessCast(MethodNode mth, IndexInsnNode castInsn, @Nullable InsnNode parentInsn) private static voidremoveStringBuilderInsns(MethodNode mth, InvokeNode toStrInsn, List<InsnNode> chain) Remove and unbind all instructions with StringBuilderprivate static booleanshadowedByOuterCast(RootNode root, ArgType castType, @Nullable InsnNode parentInsn) private voidsimplifyArgs(MethodNode mth, InsnNode insn) private static InsnNodesimplifyArith(ArithNode arith) private booleansimplifyBlock(MethodNode mth, BlockNode block) private static voidsimplifyIf(MethodNode mth, IfNode insn) Simplify 'cmp' instruction in if conditionprivate InsnNodesimplifyInsn(MethodNode mth, InsnNode insn, @Nullable InsnNode parentInsn) private InsnNodesimplifyStringConstructor(MethodNode mth, ConstructorInsn insn) private static voidsimplifyTernary(MethodNode mth, TernaryInsn insn) Simplify condition in ternary operationvoidvisit(MethodNode mth) Visit methodMethods inherited from class jadx.core.dex.visitors.AbstractVisitor
getName, toString, visit
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
stringGetBytesMth
-
-
Constructor Details
-
SimplifyVisitor
public SimplifyVisitor()
-
-
Method Details
-
init
Description copied from interface:IDexTreeVisitorCalled after loading dex tree, but before visitor traversal.- Specified by:
initin interfaceIDexTreeVisitor- Overrides:
initin classAbstractVisitor
-
visit
Description copied from interface:IDexTreeVisitorVisit method- Specified by:
visitin interfaceIDexTreeVisitor- Overrides:
visitin classAbstractVisitor
-
simplifyBlock
-
simplifyArgs
-
simplifyInsn
private InsnNode simplifyInsn(MethodNode mth, InsnNode insn, @Nullable @Nullable InsnNode parentInsn) -
simplifyStringConstructor
-
processCast
private static InsnNode processCast(MethodNode mth, IndexInsnNode castInsn, @Nullable @Nullable InsnNode parentInsn) -
isArithWideUpCast
private static boolean isArithWideUpCast(@Nullable @Nullable InsnNode parentInsn, ArgType argType, ArgType castToType) Keep cast to wide types in arith instructions, because arguments type determine instruction used in result bytecode. Example: (long) i invalid input: '<'invalid input: '<' 32 - without 'long' cast will be used 'int shift' instruction and result will be incorrect -
isCastDuplicate
-
shadowedByOuterCast
-
simplifyIf
Simplify 'cmp' instruction in if condition -
simplifyTernary
Simplify condition in ternary operation -
convertInvoke
Simplify chains of calls to StringBuilder#append() plus constructor of StringBuilder. Those chains are usually automatically generated by the Java compiler when you create String concatenations like"text " + 1 + " text". -
collectUseChain
private static List<InsnNode> collectUseChain(MethodNode mth, InvokeNode insn, RegisterArg instanceArg) -
convertStringBuilderChain
private static InsnNode convertStringBuilderChain(MethodNode mth, InvokeNode toStrInsn, List<InsnNode> chain) -
isConstConcatNeeded
-
concatConstArgs
-
getConcatArg
-
getConstString
-
removeStringBuilderInsns
private static void removeStringBuilderInsns(MethodNode mth, InvokeNode toStrInsn, List<InsnNode> chain) Remove and unbind all instructions with StringBuilder -
flattenInsnChainUntil
-
getArgFromAppend
-
simplifyArith
-
convertFieldArith
Convert field arith operation to arith instruction (IPUT (ARITH (IGET, lit)) -> ARITH ((IGET))= lit))
-