Skip to content
Permalink
Browse files
[Truffle] Initial implementation of Encoding#inspect.
  • Loading branch information
nirvdrum committed Dec 9, 2014
1 parent cfebc79 commit 4bf8f6efe1d137cb90fbb4086d9555b98517ccc1
Showing with 19 additions and 1 deletion.
  1. +19 −1 core/src/main/java/org/jruby/truffle/nodes/core/EncodingNodes.java
@@ -240,7 +240,25 @@ public ToSNode(ToSNode prev) {
public RubyString toS(RubyEncoding encoding) {
return getContext().makeString(encoding.getName());
}

}

@CoreMethod(names = "inspect")
public abstract static class InspectNode extends CoreMethodNode {

public InspectNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public InspectNode(InspectNode prev) {
super(prev);
}

@CompilerDirectives.SlowPath
@Specialization
public RubyString toS(RubyEncoding encoding) {
RubyString name = getContext().makeString(encoding.getName());

return getContext().makeString(String.format("#<Encoding:%s>", name.toString()));
}
}
}

0 comments on commit 4bf8f6e

Please sign in to comment.