Skip to content

Commit ae3d921

Browse files
committed
Implement SourceLocation#language
1 parent 5c7903e commit ae3d921

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/java/org/truffleruby/interop/SourceLocationNodes.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.truffleruby.builtins.CoreModule;
1717
import org.truffleruby.builtins.UnaryCoreMethodNode;
1818
import org.truffleruby.core.encoding.Encodings;
19+
import org.truffleruby.core.rope.CodeRange;
1920
import org.truffleruby.core.rope.Rope;
2021
import org.truffleruby.core.string.RubyString;
2122
import org.truffleruby.core.string.StringNodes;
@@ -112,4 +113,15 @@ protected boolean isInternal(RubySourceLocation location) {
112113
}
113114
}
114115

116+
@CoreMethod(names = "language")
117+
public abstract static class LanguageNode extends UnaryCoreMethodNode {
118+
@TruffleBoundary
119+
@Specialization
120+
protected RubyString language(RubySourceLocation location,
121+
@Cached StringNodes.MakeStringNode makeStringNode) {
122+
return makeStringNode.executeMake(location.sourceSection.getSource().getLanguage(),
123+
Encodings.UTF_8, CodeRange.CR_UNKNOWN);
124+
}
125+
}
126+
115127
}

0 commit comments

Comments
 (0)