Search in sources :

Example 1 with SignatureParser

use of jadx.core.dex.nodes.parser.SignatureParser in project jadx by skylot.

the class MethodNode method parseSignature.

private boolean parseSignature() {
    SignatureParser sp = SignatureParser.fromNode(this);
    if (sp == null) {
        return false;
    }
    try {
        genericMap = sp.consumeGenericMap();
        List<ArgType> argsTypes = sp.consumeMethodArgs();
        retType = sp.consumeType();
        List<ArgType> mthArgs = mthInfo.getArgumentsTypes();
        if (argsTypes.size() != mthArgs.size()) {
            if (argsTypes.isEmpty()) {
                return false;
            }
            if (!mthInfo.isConstructor()) {
                LOG.warn("Wrong signature parse result: {} -> {}, not generic version: {}", sp, argsTypes, mthArgs);
                return false;
            } else if (getParentClass().getAccessFlags().isEnum()) {
                // TODO:
                argsTypes.add(0, mthArgs.get(0));
                argsTypes.add(1, mthArgs.get(1));
            } else {
                // add synthetic arg for outer class
                argsTypes.add(0, mthArgs.get(0));
            }
            if (argsTypes.size() != mthArgs.size()) {
                return false;
            }
        }
        initArguments(argsTypes);
    } catch (JadxRuntimeException e) {
        LOG.error("Method signature parse error: {}", this, e);
        return false;
    }
    return true;
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) SignatureParser(jadx.core.dex.nodes.parser.SignatureParser)

Example 2 with SignatureParser

use of jadx.core.dex.nodes.parser.SignatureParser 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)

Aggregations

ArgType (jadx.core.dex.instructions.args.ArgType)2 SignatureParser (jadx.core.dex.nodes.parser.SignatureParser)2 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)2