From 71116cefcaf804b6eb60777880092c07ea18d236 Mon Sep 17 00:00:00 2001 From: Marc Miltenberger Date: Mon, 11 Nov 2024 18:33:14 +0100 Subject: [PATCH] Refactor line number writes in asm --- src/main/java/soot/asm/AsmMethodSource.java | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main/java/soot/asm/AsmMethodSource.java b/src/main/java/soot/asm/AsmMethodSource.java index 15f7ed2f9e8..b2105b449a3 100644 --- a/src/main/java/soot/asm/AsmMethodSource.java +++ b/src/main/java/soot/asm/AsmMethodSource.java @@ -21,7 +21,6 @@ * . * #L% */ - import static org.objectweb.asm.Opcodes.ACONST_NULL; import static org.objectweb.asm.Opcodes.ALOAD; import static org.objectweb.asm.Opcodes.ANEWARRAY; @@ -528,15 +527,9 @@ private Operand popStackConst(Type t) { return AsmUtil.isDWord(t) ? popStackConstDual() : popStackConst(); } - void setUnit(AbstractInsnNode insn, Unit u) { - if (Options.v().keep_line_number() && lastLineNumber >= 0) { - Tag lineTag = u.getTag(LineNumberTag.NAME); - if (lineTag == null) { - lineTag = new LineNumberTag(lastLineNumber); - u.addTag(lineTag); - } else if (((LineNumberTag) lineTag).getLineNumber() != lastLineNumber) { - throw new RuntimeException("Line tag mismatch"); - } + protected void setUnit(AbstractInsnNode insn, Unit u) { + if (lastLineNumber >= 0) { + setLineNumber(u, lastLineNumber); } Unit o = units.put(insn, u); @@ -545,6 +538,18 @@ void setUnit(AbstractInsnNode insn, Unit u) { } } + protected void setLineNumber(Unit u, int lineNumber) { + if (Options.v().keep_line_number()) { + Tag lineTag = u.getTag(LineNumberTag.NAME); + if (lineTag == null) { + lineTag = new LineNumberTag(lineNumber); + u.addTag(lineTag); + } else if (((LineNumberTag) lineTag).getLineNumber() != lineNumber) { + throw new RuntimeException("Line tag mismatch"); + } + } + } + void mergeUnits(AbstractInsnNode insn, Unit u) { Unit prev = units.put(insn, u); if (prev != null) {