Class FixTypesVisitor
java.lang.Object
jadx.core.dex.visitors.AbstractVisitor
jadx.core.dex.visitors.typeinference.FixTypesVisitor
- All Implemented Interfaces:
IDexTreeVisitor
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final org.slf4j.Loggerprivate List<Function<MethodNode, Boolean>> private final TypeInferenceVisitorprivate TypeUpdate -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate BooleanapplyFieldType(MethodNode mth) Use type for var assigned from field (IGET or SGET).private booleancalculateFromBounds(MethodNode mth, SSAVar ssaVar) private booleancheckAndSplitConstInsn(MethodNode mth, SSAVar var) private @Nullable BlockNodecheckBlockForInsnInsert(BlockNode blockNode) private booleancheckRawType(MethodNode mth, SSAVar var, ArgType objType) private static booleancheckTypes(MethodNode mth) Check if all types resolvedprivate booleandeduceType(MethodNode mth, SSAVar var) private booleandupConst(MethodNode mth, SSAVar var) private booleanfixBooleanUsage(MethodNode mth, RegisterArg boundArg) private booleanforceImmutableType(SSAVar ssaVar) private @Nullable ArgTypegetCommonTypeForPhiArgs(PhiInsn phiInsn) getName()Visitor short idvoidCalled after loading dex tree, but before visitor traversal.private @Nullable IndexInsnNodeinsertAssignCast(MethodNode mth, SSAVar var, ArgType castType) private booleaninsertExplicitUseCast(MethodNode mth, SSAVar ssaVar, RegisterArg useArg, ArgType fieldType) private voidinsertMove(MethodNode mth, BlockNode blockNode, PhiInsn phiInsn, RegisterArg reg) private intinsertMovesForPhi(MethodNode mth, PhiInsn phiInsn, boolean apply) private @Nullable IndexInsnNodeinsertUseCast(MethodNode mth, RegisterArg useArg, ArgType castType) private intinsertUseCasts(MethodNode mth, SSAVar var) private IndexInsnNodemakeCastInsn(RegisterArg result, RegisterArg arg, ArgType castType) makePossibleTypesList(ArgType type, @Nullable SSAVar var) private InsnNodenotBooleanToInt(ArithNode insn, RegisterArg boundArg) private TernaryInsnprepareBooleanConvertInsn(RegisterArg resultArg, RegisterArg boundArg, ArgType useType) private booleanprocessIncompatiblePrimitives(MethodNode mth, SSAVar var) private intprivate booleanselectBestTypeFromBounds(Set<ITypeBound> bounds) private booleansetBestType(MethodNode mth, SSAVar ssaVar) private static booleansplitByPhi(MethodNode mth, SSAVar var) For every PHI make separate CONST insnprivate booleantryDeduceTypes(MethodNode mth) private booleantryFieldTypeWithNewCasts(MethodNode mth, SSAVar ssaVar, boolean insertCasts) private inttryInsertAdditionalInsn(MethodNode mth, PhiInsn phiInsn) Add MOVE instruction before PHI in bound blocks to make 'soft' type link.private booleanprivate booleantryInsertCasts(MethodNode mth) private inttryInsertVarCast(MethodNode mth, SSAVar var) private booleantryPossibleTypes(MethodNode mth, SSAVar var, ArgType type) private booleantryRawType(MethodNode mth, SSAVar var) private booleanprivate booleanFix check casts to type var extend type:
<T extends Comparable> T var = (Comparable) obj; => T var = (T) obj;private booleanprivate booleanprivate booleanprivate booleantryWiderObjects(MethodNode mth, SSAVar var) voidvisit(MethodNode mth) Visit methodMethods inherited from class jadx.core.dex.visitors.AbstractVisitor
toString, visit
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
typeInference
-
typeUpdate
-
resolvers
-
-
Constructor Details
-
FixTypesVisitor
public FixTypesVisitor()
-
-
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
-
checkTypes
Check if all types resolved -
runMultiVariableSearch
-
setBestType
-
calculateFromBounds
-
selectBestTypeFromBounds
-
tryPossibleTypes
-
makePossibleTypesList
-
tryDeduceTypes
-
deduceType
-
tryRemoveGenerics
-
tryRawType
-
checkRawType
-
applyFieldType
Use type for var assigned from field (IGET or SGET). Insert additional casts at var use places. -
tryFieldTypeWithNewCasts
-
insertExplicitUseCast
private boolean insertExplicitUseCast(MethodNode mth, SSAVar ssaVar, RegisterArg useArg, ArgType fieldType) -
tryRestoreTypeVarCasts
Fix check casts to type var extend type:
<T extends Comparable> T var = (Comparable) obj; => T var = (T) obj; -
restoreTypeVarCasts
-
tryInsertCasts
-
tryInsertVarCast
-
insertUseCasts
-
insertAssignCast
@Nullable private @Nullable IndexInsnNode insertAssignCast(MethodNode mth, SSAVar var, ArgType castType) -
insertUseCast
@Nullable private @Nullable IndexInsnNode insertUseCast(MethodNode mth, RegisterArg useArg, ArgType castType) -
makeCastInsn
-
trySplitConstInsns
-
checkAndSplitConstInsn
-
dupConst
-
splitByPhi
For every PHI make separate CONST insn -
tryInsertAdditionalMove
-
tryInsertAdditionalInsn
Add MOVE instruction before PHI in bound blocks to make 'soft' type link. This allows using different types in blocks merged by PHI. -
getCommonTypeForPhiArgs
-
insertMovesForPhi
-
insertMove
-
checkBlockForInsnInsert
-
tryWiderObjects
-
tryToFixIncompatiblePrimitives
-
processIncompatiblePrimitives
-
fixBooleanUsage
-
notBooleanToInt
-
prepareBooleanConvertInsn
private TernaryInsn prepareBooleanConvertInsn(RegisterArg resultArg, RegisterArg boundArg, ArgType useType) -
tryToForceImmutableTypes
-
forceImmutableType
-
getName
Description copied from interface:IDexTreeVisitorVisitor short id- Specified by:
getNamein interfaceIDexTreeVisitor- Overrides:
getNamein classAbstractVisitor
-