Skip to content

Commit

Permalink
Merge pull request #2123 from MarcMil/devfixes
Browse files Browse the repository at this point in the history
Refactor line number writes in asm
  • Loading branch information
StevenArzt authored Nov 11, 2024
2 parents e36861e + 12efaa6 commit a1acd61
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/main/java/soot/asm/AsmMethodSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
* <http://www.gnu.org/licenses/lgpl-2.1.html>.
* #L%
*/

import static org.objectweb.asm.Opcodes.ACONST_NULL;
import static org.objectweb.asm.Opcodes.ALOAD;
import static org.objectweb.asm.Opcodes.ANEWARRAY;
Expand Down Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit a1acd61

Please sign in to comment.