Search in sources :

Example 6 with ArgType

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

the class MethodNode method initArguments.

private void initArguments(List<ArgType> args) {
    int pos;
    if (noCode) {
        pos = 1;
    } else {
        pos = regsCount;
        for (ArgType arg : args) {
            pos -= arg.getRegCount();
        }
    }
    if (accFlags.isStatic()) {
        thisArg = null;
    } else {
        TypeImmutableArg arg = InsnArg.typeImmutableReg(pos - 1, parentClass.getClassInfo().getType());
        arg.markAsThis();
        thisArg = arg;
    }
    if (args.isEmpty()) {
        argsList = Collections.emptyList();
        return;
    }
    argsList = new ArrayList<RegisterArg>(args.size());
    for (ArgType arg : args) {
        argsList.add(InsnArg.typeImmutableReg(pos, arg));
        pos += arg.getRegCount();
    }
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) RegisterArg(jadx.core.dex.instructions.args.RegisterArg) TypeImmutableArg(jadx.core.dex.instructions.args.TypeImmutableArg)

Example 7 with ArgType

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

the class LocalVar method init.

private void init(String name, ArgType type, String sign) {
    if (sign != null) {
        try {
            ArgType gType = ArgType.generic(sign);
            if (checkSignature(type, sign, gType)) {
                type = gType;
            }
        } catch (Exception e) {
            LOG.error("Can't parse signature for local variable: {}", sign, e);
        }
    }
    this.name = name;
    this.type = type;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType)

Example 8 with ArgType

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

the class LocalVar method checkSignature.

private boolean checkSignature(ArgType type, String sign, ArgType gType) {
    boolean apply;
    ArgType el = gType.getArrayRootElement();
    if (el.isGeneric()) {
        if (!type.getArrayRootElement().getObject().equals(el.getObject())) {
            LOG.warn("Generic type in debug info not equals: {} != {}", type, gType);
        }
        apply = true;
    } else {
        apply = el.isGenericType();
    }
    return apply;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType)

Example 9 with ArgType

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

the class SignatureParser method consumeType.

public ArgType consumeType() {
    char ch = next();
    mark();
    switch(ch) {
        case 'L':
            ArgType obj = consumeObjectType(false);
            if (obj != null) {
                return obj;
            }
            break;
        case 'T':
            next();
            mark();
            if (forwardTo(';')) {
                return ArgType.genericType(slice());
            }
            break;
        case '[':
            return ArgType.array(consumeType());
        case STOP_CHAR:
            return null;
        default:
            // primitive type (one char)
            ArgType type = ArgType.parse(ch);
            if (type != null) {
                return type;
            }
            break;
    }
    throw new JadxRuntimeException("Can't parse type: " + debugString());
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 10 with ArgType

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

the class SignatureParser method consumeObjectType.

private ArgType consumeObjectType(boolean incompleteType) {
    mark();
    int ch;
    do {
        ch = next();
        if (ch == STOP_CHAR) {
            return null;
        }
    } while (ch != '<' && ch != ';');
    if (ch == ';') {
        String obj;
        if (incompleteType) {
            obj = slice().replace('/', '.');
        } else {
            obj = inclusiveSlice();
        }
        return ArgType.object(obj);
    } else {
        // generic type start ('<')
        String obj = slice();
        if (!incompleteType) {
            obj += ";";
        }
        ArgType[] genArr = consumeGenericArgs();
        consume('>');
        ArgType genericType = ArgType.generic(obj, genArr);
        if (lookAhead('.')) {
            consume('.');
            next();
            // type parsing not completed, proceed to inner class
            ArgType inner = consumeObjectType(true);
            return ArgType.genericInner(genericType, inner.getObject(), inner.getGenericTypes());
        } else {
            consume(';');
            return genericType;
        }
    }
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType)

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