Package jadx.core.dex.visitors
Class PrepareForCodeGen
java.lang.Object
jadx.core.dex.visitors.AbstractVisitor
jadx.core.dex.visitors.PrepareForCodeGen
- All Implemented Interfaces:
IDexTreeVisitor
Prepare instructions for code generation pass,
most of this modification breaks register dependencies,
so this pass must be just before CodeGen.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddNullCasts(MethodNode mth, BlockNode block) private static voidcheckConstUsage(BlockNode block) Add explicit type for non int constantsprivate voidcheckEncodedValue(MethodNode mth, EncodedValue encodedValue) private static voidcheckInline(BlockNode block) private voidprivate voidcollectFieldsUsageInAnnotations(MethodNode mth, AttrNode attrNode) private static booleanforbidExplicitType(InsnType type) getName()Visitor short idprivate static voidmodifyArith(BlockNode block) Replace arithmetic operation with short form ('a = a + 2' => 'a += 2')private voidCheck that 'super' or 'this' call in constructor is a first instruction.private static voidremoveInstructions(BlockNode block) private static voidremoveParenthesis(BlockNode block) private static voidremoveParenthesis(InsnNode insn) Remove parenthesis for wrapped insn in arith '+' or '-' ('(a + b) +c' => 'a + b + c')private static voidremoveParenthesis(IfCondition cond) private @Nullable ConstructorInsnprivate voidUse source line from top methodprivate voidverifyNullCast(MethodNode mth, InsnArg arg) booleanVisit classvoidvisit(MethodNode mth) Visit methodMethods inherited from class jadx.core.dex.visitors.AbstractVisitor
init, toString
-
Constructor Details
-
PrepareForCodeGen
public PrepareForCodeGen()
-
-
Method Details
-
getName
Description copied from interface:IDexTreeVisitorVisitor short id- Specified by:
getNamein interfaceIDexTreeVisitor- Overrides:
getNamein classAbstractVisitor
-
visit
Description copied from interface:IDexTreeVisitorVisit class- Specified by:
visitin interfaceIDexTreeVisitor- Overrides:
visitin classAbstractVisitor- Returns:
- false for disable child methods and inner classes traversal
- Throws:
JadxException
-
visit
Description copied from interface:IDexTreeVisitorVisit method- Specified by:
visitin interfaceIDexTreeVisitor- Overrides:
visitin classAbstractVisitor- Throws:
JadxException
-
removeInstructions
-
checkInline
-
checkConstUsage
Add explicit type for non int constants -
forbidExplicitType
-
removeParenthesis
-
removeParenthesis
Remove parenthesis for wrapped insn in arith '+' or '-' ('(a + b) +c' => 'a + b + c') -
removeParenthesis
-
modifyArith
Replace arithmetic operation with short form ('a = a + 2' => 'a += 2') -
moveConstructorInConstructor
Check that 'super' or 'this' call in constructor is a first instruction. Otherwise, move to the top and add a warning. -
searchConstructorCall
-
setClassSourceLine
Use source line from top method -
collectFieldsUsageInAnnotations
-
collectFieldsUsageInAnnotations
-
checkEncodedValue
-
addNullCasts
-
verifyNullCast
-