Skip to content

Commit 1457605

Browse files
committed
[Truffle] Add Thread::Backtrace::Location#lineno.
1 parent fc0e290 commit 1457605

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

spec/truffle/tags/core/thread/backtrace/location/absolute_path_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

spec/truffle/tags/core/thread/backtrace/location/lineno_tags.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ public RubySymbol calleeName(VirtualFrame frame) {
297297
}
298298
}
299299

300-
@CoreMethod(names = "caller_locations", isModuleFunction = true, optional = 2)
300+
@CoreMethod(names = "caller_locations", isModuleFunction = true, optional = 2, lowerFixnumParameters = {0, 1})
301301
public abstract static class CallerLocationsNode extends CoreMethodArrayArgumentsNode {
302302

303303
public CallerLocationsNode(RubyContext context, SourceSection sourceSection) {

truffle/src/main/java/org/jruby/truffle/nodes/core/ThreadBacktraceLocationNodes.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,25 @@ public RubyString absolutePath(RubyBasicObject threadBacktraceLocation) {
8888

8989
}
9090

91+
@CoreMethod(names = "lineno")
92+
public abstract static class LinenoNode extends UnaryCoreMethodNode {
93+
94+
public LinenoNode(RubyContext context, SourceSection sourceSection) {
95+
super(context, sourceSection);
96+
}
97+
98+
@CompilerDirectives.TruffleBoundary
99+
@Specialization
100+
public int lineno(RubyBasicObject threadBacktraceLocation) {
101+
final Activation activation = getActivation(threadBacktraceLocation);
102+
103+
final SourceSection sourceSection = activation.getCallNode().getEncapsulatingSourceSection();
104+
105+
return sourceSection.getStartLine();
106+
}
107+
108+
}
109+
91110
@CoreMethod(names = {"to_s", "inspect"})
92111
public abstract static class ToSNode extends UnaryCoreMethodNode {
93112

0 commit comments

Comments
 (0)