Search in sources :

Example 11 with ArgType

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

the class SignatureParser method consumeGenericArgs.

private ArgType[] consumeGenericArgs() {
    List<ArgType> list = new LinkedList<ArgType>();
    ArgType type;
    do {
        if (lookAhead('*')) {
            next();
            type = ArgType.wildcard();
        } else if (lookAhead('+')) {
            next();
            type = ArgType.wildcard(consumeType(), 1);
        } else if (lookAhead('-')) {
            next();
            type = ArgType.wildcard(consumeType(), -1);
        } else {
            type = consumeType();
        }
        if (type != null) {
            list.add(type);
        }
    } while (type != null && !lookAhead('>'));
    return list.toArray(new ArgType[list.size()]);
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) LinkedList(java.util.LinkedList)

Example 12 with ArgType

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

the class InsnGen method inlineAnonymousConstr.

private void inlineAnonymousConstr(CodeWriter code, ClassNode cls, ConstructorInsn insn) throws CodegenException {
    // anonymous class construction
    if (cls.contains(AFlag.DONT_GENERATE)) {
        code.add("/* anonymous class already generated */");
        ErrorsCounter.methodError(mth, "Anonymous class already generated: " + cls);
        return;
    }
    ArgType parent;
    if (cls.getInterfaces().size() == 1) {
        parent = cls.getInterfaces().get(0);
    } else {
        parent = cls.getSuperClass();
    }
    cls.add(AFlag.DONT_GENERATE);
    MethodNode defCtr = cls.getDefaultConstructor();
    if (defCtr != null) {
        if (RegionUtils.notEmpty(defCtr.getRegion())) {
            defCtr.add(AFlag.ANONYMOUS_CONSTRUCTOR);
        } else {
            defCtr.add(AFlag.DONT_GENERATE);
        }
    }
    code.add("new ");
    if (parent == null) {
        code.add("Object");
    } else {
        useClass(code, parent);
    }
    MethodNode callMth = mth.dex().resolveMethod(insn.getCallMth());
    generateMethodArguments(code, insn, 0, callMth);
    code.add(' ');
    new ClassGen(cls, mgen.getClassGen().getParentGen()).addClassBody(code);
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) MethodNode(jadx.core.dex.nodes.MethodNode)

Example 13 with ArgType

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

the class InsnGen method processOverloadedArg.

/**
	 * Add additional cast for overloaded method argument.
	 */
private boolean processOverloadedArg(CodeWriter code, MethodNode callMth, InsnArg arg, int origPos) {
    ArgType origType = callMth.getMethodInfo().getArgumentsTypes().get(origPos);
    if (!arg.getType().equals(origType)) {
        code.add('(');
        useType(code, origType);
        code.add(") ");
        return true;
    }
    return false;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType)

Example 14 with ArgType

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

the class ClassNode method parseClassSignature.

private void parseClassSignature() {
    SignatureParser sp = SignatureParser.fromNode(this);
    if (sp == null) {
        return;
    }
    try {
        // parse class generic map
        genericMap = sp.consumeGenericMap();
        // parse super class signature
        superClass = sp.consumeType();
        // parse interfaces signatures
        for (int i = 0; i < interfaces.size(); i++) {
            ArgType type = sp.consumeType();
            if (type != null) {
                interfaces.set(i, type);
            } else {
                break;
            }
        }
    } catch (JadxRuntimeException e) {
        LOG.error("Class signature parse error: {}", this, e);
    }
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) SignatureParser(jadx.core.dex.nodes.parser.SignatureParser)

Example 15 with ArgType

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

the class DexNode method readParamList.

public List<ArgType> readParamList(int parametersOffset) {
    TypeList paramList = dexBuf.readTypeList(parametersOffset);
    List<ArgType> args = new ArrayList<ArgType>(paramList.getTypes().length);
    for (short t : paramList.getTypes()) {
        args.add(getType(t));
    }
    return Collections.unmodifiableList(args);
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) ArrayList(java.util.ArrayList) TypeList(com.android.dex.TypeList)

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