Search in sources :

Example 1 with ICustomPayload

use of jadx.api.plugins.input.insns.custom.ICustomPayload in project jadx by skylot.

the class InsnDecoder method makeSwitch.

@NotNull
private SwitchInsn makeSwitch(InsnData insn, boolean packed) {
    SwitchInsn swInsn = new SwitchInsn(InsnArg.reg(insn, 0, ArgType.UNKNOWN), insn.getTarget(), packed);
    ICustomPayload payload = insn.getPayload();
    if (payload != null) {
        swInsn.attachSwitchData(new SwitchData((ISwitchPayload) payload), insn.getTarget());
    }
    return swInsn;
}
Also used : ISwitchPayload(jadx.api.plugins.input.insns.custom.ISwitchPayload) ICustomPayload(jadx.api.plugins.input.insns.custom.ICustomPayload) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with ICustomPayload

use of jadx.api.plugins.input.insns.custom.ICustomPayload in project jadx by skylot.

the class UsageInfoVisitor method processInsn.

private static void processInsn(RootNode root, MethodNode mth, InsnData insnData, UsageInfo usageInfo) {
    if (insnData.getOpcode() == Opcode.UNKNOWN) {
        return;
    }
    switch(insnData.getIndexType()) {
        case TYPE_REF:
            insnData.decode();
            ArgType usedType = ArgType.parse(insnData.getIndexAsType());
            usageInfo.clsUse(mth, usedType);
            break;
        case FIELD_REF:
            insnData.decode();
            FieldNode fieldNode = root.resolveField(FieldInfo.fromRef(root, insnData.getIndexAsField()));
            if (fieldNode != null) {
                usageInfo.fieldUse(mth, fieldNode);
            }
            break;
        case METHOD_REF:
            {
                insnData.decode();
                IMethodRef mthRef;
                ICustomPayload payload = insnData.getPayload();
                if (payload != null) {
                    mthRef = ((IMethodRef) payload);
                } else {
                    mthRef = insnData.getIndexAsMethod();
                }
                MethodNode methodNode = root.resolveMethod(MethodInfo.fromRef(root, mthRef));
                if (methodNode != null) {
                    usageInfo.methodUse(mth, methodNode);
                }
                break;
            }
        case CALL_SITE:
            {
                insnData.decode();
                ICallSite callSite = InsnDataUtils.getCallSite(insnData);
                IMethodHandle methodHandle = InsnDataUtils.getMethodHandleAt(callSite, 4);
                if (methodHandle != null) {
                    IMethodRef mthRef = methodHandle.getMethodRef();
                    MethodNode mthNode = root.resolveMethod(MethodInfo.fromRef(root, mthRef));
                    if (mthNode != null) {
                        usageInfo.methodUse(mth, mthNode);
                    }
                }
                break;
            }
    }
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) IMethodHandle(jadx.api.plugins.input.data.IMethodHandle) FieldNode(jadx.core.dex.nodes.FieldNode) MethodNode(jadx.core.dex.nodes.MethodNode) IMethodRef(jadx.api.plugins.input.data.IMethodRef) ICustomPayload(jadx.api.plugins.input.insns.custom.ICustomPayload) ICallSite(jadx.api.plugins.input.data.ICallSite)

Aggregations

ICustomPayload (jadx.api.plugins.input.insns.custom.ICustomPayload)2 ICallSite (jadx.api.plugins.input.data.ICallSite)1 IMethodHandle (jadx.api.plugins.input.data.IMethodHandle)1 IMethodRef (jadx.api.plugins.input.data.IMethodRef)1 ISwitchPayload (jadx.api.plugins.input.insns.custom.ISwitchPayload)1 ArgType (jadx.core.dex.instructions.args.ArgType)1 FieldNode (jadx.core.dex.nodes.FieldNode)1 MethodNode (jadx.core.dex.nodes.MethodNode)1 NotNull (org.jetbrains.annotations.NotNull)1