Search in sources :

Example 6 with CodegenException

use of jadx.core.utils.exceptions.CodegenException in project jadx by skylot.

the class MethodGen method addFallbackInsns.

public static void addFallbackInsns(CodeWriter code, MethodNode mth, InsnNode[] insnArr, boolean addLabels) {
    InsnGen insnGen = new InsnGen(getFallbackMethodGen(mth), true);
    for (InsnNode insn : insnArr) {
        if (insn == null || insn.getType() == InsnType.NOP) {
            continue;
        }
        if (addLabels && (insn.contains(AType.JUMP) || insn.contains(AType.EXC_HANDLER))) {
            code.decIndent();
            code.startLine(getLabelName(insn.getOffset()) + ":");
            code.incIndent();
        }
        try {
            if (insnGen.makeInsn(insn, code)) {
                CatchAttr catchAttr = insn.get(AType.CATCH_BLOCK);
                if (catchAttr != null) {
                    code.add("\t " + catchAttr);
                }
            }
        } catch (CodegenException e) {
            LOG.debug("Error generate fallback instruction: ", e.getCause());
            code.startLine("// error: " + insn);
        }
    }
}
Also used : InsnNode(jadx.core.dex.nodes.InsnNode) CodegenException(jadx.core.utils.exceptions.CodegenException) CatchAttr(jadx.core.dex.trycatch.CatchAttr)

Aggregations

CodegenException (jadx.core.utils.exceptions.CodegenException)6 InsnNode (jadx.core.dex.nodes.InsnNode)2 CodeGen (jadx.core.codegen.CodeGen)1 CodeWriter (jadx.core.codegen.CodeWriter)1 InsnGen (jadx.core.codegen.InsnGen)1 MethodGen (jadx.core.codegen.MethodGen)1 LoopLabelAttr (jadx.core.dex.attributes.nodes.LoopLabelAttr)1 FieldInfo (jadx.core.dex.info.FieldInfo)1 ConstClassNode (jadx.core.dex.instructions.ConstClassNode)1 ConstStringNode (jadx.core.dex.instructions.ConstStringNode)1 FillArrayNode (jadx.core.dex.instructions.FillArrayNode)1 GotoNode (jadx.core.dex.instructions.GotoNode)1 IfNode (jadx.core.dex.instructions.IfNode)1 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)1 SwitchNode (jadx.core.dex.instructions.SwitchNode)1 ArgType (jadx.core.dex.instructions.args.ArgType)1 FieldArg (jadx.core.dex.instructions.args.FieldArg)1 InsnArg (jadx.core.dex.instructions.args.InsnArg)1 LiteralArg (jadx.core.dex.instructions.args.LiteralArg)1 Named (jadx.core.dex.instructions.args.Named)1