ruby-changes:1756
From: ko1@a...
Date: 25 Aug 2007 00:26:52 +0900
Subject: [ruby-changes:1756] ko1 - Ruby:r13247 (trunk): * prelude.rb: added. run this script on startup.
ko1 2007-08-25 00:26:28 +0900 (Sat, 25 Aug 2007) New Revision: 13247 Added files: trunk/prelude.rb trunk/tool/compile_prelude.rb Modified files: trunk/ChangeLog trunk/common.mk trunk/inits.c trunk/thread.c Log: * prelude.rb: added. run this script on startup. * tool/compile_prelude.rb: compile prelude.rb to C string. (prelude.rb -> prelude.c) * common.mk: fix to build with prelude.c. * inits.c (rb_call_inits): ditto. * thread.c (Init_Thread): move definition of Mutex#synchronize to prelude.rb. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/prelude.rb?r1=13247&r2=13246 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/prelude.rb?revision=13247&view=markup http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/tool/compile_prelude.rb?r1=13247&r2=13246 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/tool/compile_prelude.rb?revision=13247&view=markup http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=13247&r2=13246 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/thread.c?r1=13247&r2=13246 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/inits.c?r1=13247&r2=13246 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/common.mk?r1=13247&r2=13246 Index: prelude.rb =================================================================== --- prelude.rb (revision 0) +++ prelude.rb (revision 13247) @@ -0,0 +1,14 @@ + +# Mutex + +class Mutex + class Mutex + def synchronize + self.lock + yield + ensure + self.unlock + end + end +end + Property changes on: prelude.rb ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + LF Index: ChangeLog =================================================================== --- ChangeLog (revision 13246) +++ ChangeLog (revision 13247) @@ -1,3 +1,17 @@ +Sat Aug 25 00:22:31 2007 Koichi Sasada <ko1@a...> + + * prelude.rb: added. run this script on startup. + + * tool/compile_prelude.rb: compile prelude.rb to C string. + (prelude.rb -> prelude.c) + + * common.mk: fix to build with prelude.c. + + * inits.c (rb_call_inits): ditto. + + * thread.c (Init_Thread): move definition of Mutex#synchronize + to prelude.rb. + Sat Aug 25 00:08:43 2007 Koichi Sasada <ko1@a...> * compile.c (compile_massign_opt): fix to skip massign optimization Index: thread.c =================================================================== --- thread.c (revision 13246) +++ thread.c (revision 13247) @@ -2968,12 +2968,6 @@ rb_define_method(rb_cMutex, "unlock", rb_mutex_unlock, 0); rb_define_method(rb_cMutex, "sleep", mutex_sleep, -1); - rb_iseq_eval(rb_iseq_compile( - rb_str_new2("class Mutex;" - " def synchronize; self.lock; yield; ensure; self.unlock; end;" - "end;"), - rb_str_new2(__FILE__), INT2FIX(__LINE__))); - recursive_key = rb_intern("__recursive_key__"); rb_eThreadError = rb_define_class("ThreadError", rb_eStandardError); Index: common.mk =================================================================== --- common.mk (revision 13246) +++ common.mk (revision 13247) @@ -76,6 +76,7 @@ thread.$(OBJEXT) \ cont.$(OBJEXT) \ id.$(OBJEXT) \ + prelude.$(OBJEXT) \ $(MISSING) SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \ @@ -588,6 +589,7 @@ {$(VPATH)}debug.h {$(VPATH)}vm_opts.h \ {$(VPATH)}thread_$(THREAD_MODEL).h id.$(OBJEXT): {$(VPATH)}id.c {$(VPATH)}ruby.h +prelude.$(OBJEXT): {$(VPATH)}prelude.c {$(VPATH)}ruby.h MATZRUBY = $(MATZRUBYDIR)ruby @@ -621,6 +623,9 @@ node_name.inc: {$(VPATH)}node.h $(BASERUBY) -n $(srcdir)/tool/node_name.rb $? > $@ +prelude.c: {$(VPATH)}prelude.rb + $(BASERUBY) $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb prelude.c + docs: $(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT) Index: inits.c =================================================================== --- inits.c (revision 13246) +++ inits.c (revision 13247) @@ -51,6 +51,7 @@ void Init_Thread(void); void Init_Cont(void); void Init_top_self(void); +void Init_prelude(void); void rb_call_inits() @@ -94,4 +95,5 @@ Init_Thread(); Init_Cont(); Init_version(); + Init_prelude(); } Index: tool/compile_prelude.rb =================================================================== --- tool/compile_prelude.rb (revision 0) +++ tool/compile_prelude.rb (revision 13247) @@ -0,0 +1,25 @@ + +prelude, outfile = *ARGV +lines = [] + +File.readlines(prelude).each{|line| + lines << "#{line.dump}" +} + +open(outfile, 'w'){|f| +f.puts <<EOS__ + +#include "ruby/ruby.h" +static const char *prelude_code = +#{lines.join("\n")} +; +void +Init_prelude(void) +{ + rb_iseq_eval(rb_iseq_compile( + rb_str_new2(prelude_code), + rb_str_new2("prelude.rb"), INT2FIX(1))); +} +EOS__ +} + Property changes on: tool/compile_prelude.rb ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Name: svn:eol-style + LF -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml