Skip to content

Commit a108fb4

Browse files
committed
[GR-73856] Ensure synthetic SourceRanges map to unavailable sections.
PullRequest: graalpython/4298
2 parents 6569797 + 12dfa24 commit a108fb4

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

  • graalpython
    • com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/tokenizer
    • com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl

graalpython/com.oracle.graal.python.pegparser/src/com/oracle/graal/python/pegparser/tokenizer/SourceRange.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public SourceRange withEnd(int newEndLine, int newEndColumn) {
6666

6767
public SourceRange startLineShiftColumn(int shift) {
6868
assert shift >= 0;
69-
if (shift == 0) {
69+
if (shift == 0 || this == ARTIFICIAL_RANGE) {
7070
return this;
7171
}
7272
return new SourceRange(startLine, startColumn, startLine, startColumn + shift);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/compiler/bytecode_dsl/RootNodeCompiler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ void beginRootSourceSection(SSTNode node, Builder b) {
816816
}
817817

818818
private static void beginSourceSectionInner(Builder b, SourceRange sourceRange) {
819-
if (sourceRange.startLine >= 1) {
819+
if (sourceRange.startLine >= 1 && sourceRange != SourceRange.ARTIFICIAL_RANGE) {
820820
if (sourceRange.startColumn >= 0 && sourceRange.endLine >= sourceRange.startLine && sourceRange.endColumn >= 0) {
821821
if (sourceRange.endColumn > 0) {
822822
b.beginSourceSection(sourceRange.startLine, sourceRange.startColumn + 1, sourceRange.endLine, sourceRange.endColumn);
@@ -4120,6 +4120,7 @@ public Void visit(StmtTy.FunctionDef node) {
41204120
}
41214121

41224122
public void emitFunctionDef(StmtTy node, String name, ArgumentsTy args, StmtTy[] body, ExprTy[] decoratorList, ExprTy returns, TypeParamTy[] typeParams) {
4123+
// For instrumentation, we want to map this statement only to the declaration line, such
41234124
// that, e.g., breakpoints inside the body fire only once the body actually executes and
41244125
// not is declared. There is no simple way to get the exact line width here, so we just
41254126
// approximate it with name width.

0 commit comments

Comments
 (0)