Skip to content

Commit

Permalink
fix: use labelless format for line numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
jumanji144 committed Apr 15, 2024
1 parent 669c100 commit c9b4e4a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,10 @@ public void visitLabel(@NotNull ASTIdentifier label) {
}

@Override
public void visitLineNumber(ASTIdentifier label, ASTNumber line) {
getOrCreateLabel(label.content()).setLineNumber(line.asInt());
public void visitLineNumber(ASTNumber line) {
Label label = new GenericLabel();
label.setLineNumber(line.asInt());
codeBuilderList.addLabel(label);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public void label(Label label) {
String name = labelNames.get(label.getIndex());
ctx.label(name).next();
if(label.getLineNumber() != Label.UNSET) {
ctx.instruction("line").print(name).arg().print(Integer.toString(label.getLineNumber())).next();
ctx.instruction("line").print(Integer.toString(label.getLineNumber())).next();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ protected void registerInstructions() {

// intrinsics
register(
"line", ops(DefaultOperands.IDENTIFIER, DefaultOperands.INTEGER),
"line", ops(DefaultOperands.INTEGER),
(inst, visitor) -> visitor
.visitLineNumber(inst.argument(0, ASTIdentifier.class), inst.argument(1, ASTNumber.class))
.visitLineNumber(inst.argument(0, ASTNumber.class))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ public interface ASTInstructionVisitor {
/**
* Visit a line number
*
* @param label
* the label
* @param line
* the line number
*/
void visitLineNumber(ASTIdentifier label, ASTNumber line);
void visitLineNumber(ASTNumber line);

void visitException(@NotNull ASTIdentifier start, @NotNull ASTIdentifier end, @NotNull ASTIdentifier handler, @NotNull ASTIdentifier type);

Expand Down

0 comments on commit c9b4e4a

Please sign in to comment.