Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Truffle] Initial implementation of Encoding#inspect.
  • Loading branch information
nirvdrum committed Dec 9, 2014
1 parent cfebc79 commit 4bf8f6e
Showing 1 changed file with 19 additions and 1 deletion.
Expand Up @@ -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.