Search in sources :

Example 1 with DexMethodRef

use of jadx.plugins.input.dex.sections.DexMethodRef in project jadx by skylot.

the class SmaliPrinter method printMethod.

public static String printMethod(DexMethodData mth) {
    SmaliCodeWriter codeWriter = new SmaliCodeWriter();
    codeWriter.startLine(".method ");
    codeWriter.add(AccessFlags.format(mth.getAccessFlags(), METHOD));
    DexMethodRef methodRef = mth.getMethodRef();
    methodRef.load();
    codeWriter.add(methodRef.getName());
    codeWriter.add('(').addArgs(methodRef.getArgTypes()).add(')');
    codeWriter.add(methodRef.getReturnType());
    codeWriter.incIndent();
    ICodeReader codeReader = mth.getCodeReader();
    if (codeReader != null) {
        codeWriter.startLine(".registers ").add(codeReader.getRegistersCount());
        SmaliInsnFormat insnFormat = SmaliInsnFormat.getInstance();
        InsnFormatterInfo formatterInfo = new InsnFormatterInfo(codeWriter, mth);
        codeReader.visitInstructions(insn -> {
            codeWriter.startLine();
            formatterInfo.setInsn(insn);
            insnFormat.format(formatterInfo);
        });
        codeWriter.decIndent();
    }
    codeWriter.startLine(".end method");
    return codeWriter.getCode();
}
Also used : DexMethodRef(jadx.plugins.input.dex.sections.DexMethodRef) ICodeReader(jadx.api.plugins.input.data.ICodeReader)

Aggregations

ICodeReader (jadx.api.plugins.input.data.ICodeReader)1 DexMethodRef (jadx.plugins.input.dex.sections.DexMethodRef)1