Skip to content

Commit

Permalink
fix: add labels from NOP instructions in fallback mode (#666)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed May 19, 2019
1 parent 75a6714 commit 5efe4bd
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion jadx-core/src/main/java/jadx/core/codegen/MethodGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,17 +241,21 @@ public void addFallbackMethodCode(CodeWriter code) {
}

public static void addFallbackInsns(CodeWriter code, MethodNode mth, InsnNode[] insnArr, boolean addLabels) {
code.incIndent();
InsnGen insnGen = new InsnGen(getFallbackMethodGen(mth), true);
InsnNode prevInsn = null;
for (InsnNode insn : insnArr) {
if (insn == null || insn.getType() == InsnType.NOP) {
if (insn == null) {
continue;
}
if (addLabels && needLabel(insn, prevInsn)) {
code.decIndent();
code.startLine(getLabelName(insn.getOffset()) + ':');
code.incIndent();
}
if (insn.getType() == InsnType.NOP) {
continue;
}
try {
code.startLine();
RegisterArg resArg = insn.getResult();
Expand All @@ -272,6 +276,7 @@ public static void addFallbackInsns(CodeWriter code, MethodNode mth, InsnNode[]
}
prevInsn = insn;
}
code.decIndent();
}

private static boolean needLabel(InsnNode insn, InsnNode prevInsn) {
Expand Down

0 comments on commit 5efe4bd

Please sign in to comment.