Search in sources :

Example 1 with MethodUtils

use of jadx.core.dex.nodes.utils.MethodUtils in project jadx by skylot.

the class TypeInferenceVisitor method makeInvokeUseBound.

private ITypeBound makeInvokeUseBound(RegisterArg regArg, BaseInvokeNode invoke) {
    InsnArg instanceArg = invoke.getInstanceArg();
    if (instanceArg == null) {
        return null;
    }
    MethodUtils methodUtils = root.getMethodUtils();
    IMethodDetails methodDetails = methodUtils.getMethodDetails(invoke);
    if (methodDetails == null) {
        return null;
    }
    if (instanceArg != regArg) {
        int argIndex = invoke.getArgIndex(regArg) - invoke.getFirstArgOffset();
        ArgType argType = methodDetails.getArgTypes().get(argIndex);
        if (!argType.containsTypeVariable()) {
            return null;
        }
        return new TypeBoundInvokeUse(root, invoke, regArg, argType);
    }
    // for override methods use origin declared class as type
    if (methodDetails instanceof MethodNode) {
        MethodNode callMth = (MethodNode) methodDetails;
        ClassInfo declCls = methodUtils.getMethodOriginDeclClass(callMth);
        return new TypeBoundConst(BoundEnum.USE, declCls.getType(), regArg);
    }
    return null;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) MethodNode(jadx.core.dex.nodes.MethodNode) InsnArg(jadx.core.dex.instructions.args.InsnArg) MethodUtils(jadx.core.dex.nodes.utils.MethodUtils) IMethodDetails(jadx.core.dex.nodes.IMethodDetails) ClassInfo(jadx.core.dex.info.ClassInfo)

Aggregations

ClassInfo (jadx.core.dex.info.ClassInfo)1 ArgType (jadx.core.dex.instructions.args.ArgType)1 InsnArg (jadx.core.dex.instructions.args.InsnArg)1 IMethodDetails (jadx.core.dex.nodes.IMethodDetails)1 MethodNode (jadx.core.dex.nodes.MethodNode)1 MethodUtils (jadx.core.dex.nodes.utils.MethodUtils)1