From b2cfdb35d142fd85fe6e246a1f117dd3d57d7116 Mon Sep 17 00:00:00 2001 From: Konstantin Haase Date: Wed, 19 Jan 2011 12:47:45 +0100 Subject: [PATCH] define printString in bootstrap --- bin/reak | 2 +- lib/reak/bootstrap.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/bin/reak b/bin/reak index e487417..8153d9d 100755 --- a/bin/reak +++ b/bin/reak @@ -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 diff --git a/lib/reak/bootstrap.rb b/lib/reak/bootstrap.rb index f415348..41a825c 100644 --- a/lib/reak/bootstrap.rb +++ b/lib/reak/bootstrap.rb @@ -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