Search in sources :

Example 41 with ArgType

use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.

the class InsnDecoder method filledNewArray.

private InsnNode filledNewArray(DecodedInstruction insn, int offset, boolean isRange) {
    int resReg = getMoveResultRegister(insnArr, offset);
    ArgType arrType = dex.getType(insn.getIndex());
    ArgType elType = arrType.getArrayElement();
    boolean typeImmutable = elType.isPrimitive();
    int regsCount = insn.getRegisterCount();
    InsnArg[] regs = new InsnArg[regsCount];
    if (isRange) {
        int r = insn.getA();
        for (int i = 0; i < regsCount; i++) {
            regs[i] = InsnArg.reg(r, elType, typeImmutable);
            r++;
        }
    } else {
        for (int i = 0; i < regsCount; i++) {
            int regNum = InsnUtils.getArg(insn, i);
            regs[i] = InsnArg.reg(regNum, elType, typeImmutable);
        }
    }
    InsnNode node = new FilledNewArrayNode(elType, regs.length);
    node.setResult(resReg == -1 ? null : InsnArg.reg(resReg, arrType));
    for (InsnArg arg : regs) {
        node.addArg(arg);
    }
    return node;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) InsnNode(jadx.core.dex.nodes.InsnNode) InsnArg(jadx.core.dex.instructions.args.InsnArg)

Example 42 with ArgType

use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.

the class AnnotationsParser method readAnnotation.

public static Annotation readAnnotation(DexNode dex, Section s, boolean readVisibility) throws DecodeException {
    EncValueParser parser = new EncValueParser(dex, s);
    Visibility visibility = null;
    if (readVisibility) {
        byte v = s.readByte();
        visibility = VISIBILITIES[v];
    }
    int typeIndex = s.readUleb128();
    int size = s.readUleb128();
    Map<String, Object> values = new LinkedHashMap<String, Object>(size);
    for (int i = 0; i < size; i++) {
        String name = dex.getString(s.readUleb128());
        values.put(name, parser.parseValue());
    }
    ArgType type = dex.getType(typeIndex);
    Annotation annotation = new Annotation(visibility, type, values);
    if (!type.isObject()) {
        throw new DecodeException("Incorrect type for annotation: " + annotation);
    }
    return annotation;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) Visibility(jadx.core.dex.attributes.annotations.Annotation.Visibility) DecodeException(jadx.core.utils.exceptions.DecodeException) Annotation(jadx.core.dex.attributes.annotations.Annotation) LinkedHashMap(java.util.LinkedHashMap)

Example 43 with ArgType

use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.

the class SignatureParser method consumeExtendsTypesList.

/**
	 * List of types separated by ':' last type is 'java.lang.Object'.
	 * <p/>
	 * Example: "Ljava/lang/Exception;:Ljava/lang/Object;"
	 */
private List<ArgType> consumeExtendsTypesList() {
    List<ArgType> types = Collections.emptyList();
    boolean next;
    do {
        ArgType argType = consumeType();
        if (!argType.equals(ArgType.OBJECT)) {
            if (types.isEmpty()) {
                types = new LinkedList<ArgType>();
            }
            types.add(argType);
        }
        next = lookAhead(':');
        if (next) {
            consume(':');
        }
    } while (next);
    return types;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType)

Example 44 with ArgType

use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.

the class RenameVisitor method makeMethodSignature.

private static String makeMethodSignature(MethodInfo methodInfo) {
    StringBuilder signature = new StringBuilder();
    signature.append(methodInfo.getAlias());
    signature.append('(');
    for (ArgType arg : methodInfo.getArgumentsTypes()) {
        signature.append(TypeGen.signature(arg));
    }
    signature.append(')');
    return signature.toString();
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType)

Example 45 with ArgType

use of jadx.core.dex.instructions.args.ArgType in project jadx by skylot.

the class SimplifyVisitor method processCast.

private static InsnNode processCast(MethodNode mth, InsnNode insn) {
    InsnArg castArg = insn.getArg(0);
    ArgType argType = castArg.getType();
    // Don't removes CHECK_CAST for wrapped INVOKE if invoked method returns different type
    if (castArg.isInsnWrap()) {
        InsnNode wrapInsn = ((InsnWrapArg) castArg).getWrapInsn();
        if (wrapInsn.getType() == InsnType.INVOKE) {
            argType = ((InvokeNode) wrapInsn).getCallMth().getReturnType();
        }
    }
    ArgType castToType = (ArgType) ((IndexInsnNode) insn).getIndex();
    if (ArgType.isCastNeeded(mth.dex(), argType, castToType)) {
        return null;
    }
    InsnNode insnNode = new InsnNode(InsnType.MOVE, 1);
    insnNode.setOffset(insn.getOffset());
    insnNode.setResult(insn.getResult());
    insnNode.addArg(castArg);
    return insnNode;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) InsnNode(jadx.core.dex.nodes.InsnNode) InsnArg(jadx.core.dex.instructions.args.InsnArg) InvokeNode(jadx.core.dex.instructions.InvokeNode) InsnWrapArg(jadx.core.dex.instructions.args.InsnWrapArg)

Aggregations

ArgType (jadx.core.dex.instructions.args.ArgType)48 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)12 InsnNode (jadx.core.dex.nodes.InsnNode)11 InsnArg (jadx.core.dex.instructions.args.InsnArg)9 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)8 LiteralArg (jadx.core.dex.instructions.args.LiteralArg)6 SSAVar (jadx.core.dex.instructions.args.SSAVar)6 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)5 ArrayList (java.util.ArrayList)5 FieldNode (jadx.core.dex.nodes.FieldNode)4 MethodNode (jadx.core.dex.nodes.MethodNode)4 Annotation (jadx.core.dex.attributes.annotations.Annotation)3 FieldInfo (jadx.core.dex.info.FieldInfo)3 FilledNewArrayNode (jadx.core.dex.instructions.FilledNewArrayNode)3 InvokeNode (jadx.core.dex.instructions.InvokeNode)3 BlockNode (jadx.core.dex.nodes.BlockNode)3 ClassNode (jadx.core.dex.nodes.ClassNode)3 DexNode (jadx.core.dex.nodes.DexNode)3 List (java.util.List)3 MethodInfo (jadx.core.dex.info.MethodInfo)2