Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[Truffle] Kernel#to_s and Kernel#inspect are different.
We should use Rubinius's definition instead of our own, but there are some parts there we don't support yet and I decided to defer working on them.
  • Loading branch information
nirvdrum committed Feb 5, 2015
1 parent 463db3d commit 69fcbdf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -2231,7 +2231,7 @@ public String toHexString(RubyBignum value) {

}

@CoreMethod(names = {"to_s", "inspect"})
@CoreMethod(names = "to_s")
public abstract static class ToSNode extends CoreMethodNode {

@Child private ClassNode classNode;
Expand Down
17 changes: 17 additions & 0 deletions truffle/src/main/ruby/jruby/truffle/core/shims.rb
Expand Up @@ -184,4 +184,21 @@ def rindex(obj)

index
end
end

module Kernel
def inspect
ivars = instance_variables

return to_s if ivars.empty?

prefix = "#<#{self.class}:0x#{self.object_id.to_s(16)}"

parts = []
ivars.each do |var|
parts << "#{var}=#{instance_variable_get(var).inspect}"
end

"#{prefix} #{parts.join(', ')}>"
end
end

0 comments on commit 69fcbdf

Please sign in to comment.