Skip to content

Commit

Permalink
define printString in bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
rkh committed Jan 19, 2011
1 parent 16db7f3 commit b2cfdb3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bin/reak
Expand Up @@ -59,7 +59,7 @@ display = proc do |code|
end

begin
p Reak::Compiler.new.compile(code).call
puts Reak::Compiler.new.compile(code).call.reak_send("printString")
rescue Exception => e
e.render
end
Expand Down
17 changes: 17 additions & 0 deletions lib/reak/bootstrap.rb
Expand Up @@ -16,10 +16,27 @@ def reak_def(name, &block)

class Object
reak_def("=") { |other| self == other }
reak_def("printString") { "a RubyObject(#{inspect})" }

def reak_send(name, *args)
__send__ "reak:#{name}", *args
end
end

class Fixnum
reak_alias [:+, :-, :<, :>]
reak_alias :printString, :inspect
end

class Symbol
reak_def("printString") do
str = inspect[1..-1]
if str[0] == ?"
"#'#{str[1..-2].gsub("'", "''")}'"
else
"##{str}"
end
end
end

module Smalltalk
Expand Down

0 comments on commit b2cfdb3

Please sign in to comment.