Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor line number writes in asm #2123

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading