* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b285d26a16
commit
6bf7d3d8c0
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
|||||||
|
Sat Aug 25 00:22:31 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* 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@atdot.net>
|
Sat Aug 25 00:08:43 2007 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* compile.c (compile_massign_opt): fix to skip massign optimization
|
* compile.c (compile_massign_opt): fix to skip massign optimization
|
||||||
|
@ -76,6 +76,7 @@ OBJS = array.$(OBJEXT) \
|
|||||||
thread.$(OBJEXT) \
|
thread.$(OBJEXT) \
|
||||||
cont.$(OBJEXT) \
|
cont.$(OBJEXT) \
|
||||||
id.$(OBJEXT) \
|
id.$(OBJEXT) \
|
||||||
|
prelude.$(OBJEXT) \
|
||||||
$(MISSING)
|
$(MISSING)
|
||||||
|
|
||||||
SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
|
SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
|
||||||
@ -588,6 +589,7 @@ blockinlining.$(OBJEXT): {$(VPATH)}blockinlining.c \
|
|||||||
{$(VPATH)}debug.h {$(VPATH)}vm_opts.h \
|
{$(VPATH)}debug.h {$(VPATH)}vm_opts.h \
|
||||||
{$(VPATH)}thread_$(THREAD_MODEL).h
|
{$(VPATH)}thread_$(THREAD_MODEL).h
|
||||||
id.$(OBJEXT): {$(VPATH)}id.c {$(VPATH)}ruby.h
|
id.$(OBJEXT): {$(VPATH)}id.c {$(VPATH)}ruby.h
|
||||||
|
prelude.$(OBJEXT): {$(VPATH)}prelude.c {$(VPATH)}ruby.h
|
||||||
|
|
||||||
MATZRUBY = $(MATZRUBYDIR)ruby
|
MATZRUBY = $(MATZRUBYDIR)ruby
|
||||||
|
|
||||||
@ -621,6 +623,9 @@ incs: $(INSNS) node_name.inc
|
|||||||
node_name.inc: {$(VPATH)}node.h
|
node_name.inc: {$(VPATH)}node.h
|
||||||
$(BASERUBY) -n $(srcdir)/tool/node_name.rb $? > $@
|
$(BASERUBY) -n $(srcdir)/tool/node_name.rb $? > $@
|
||||||
|
|
||||||
|
prelude.c: {$(VPATH)}prelude.rb
|
||||||
|
$(BASERUBY) $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb prelude.c
|
||||||
|
|
||||||
docs:
|
docs:
|
||||||
$(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT)
|
$(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT)
|
||||||
|
|
||||||
|
2
inits.c
2
inits.c
@ -51,6 +51,7 @@ void Init_VM(void);
|
|||||||
void Init_Thread(void);
|
void Init_Thread(void);
|
||||||
void Init_Cont(void);
|
void Init_Cont(void);
|
||||||
void Init_top_self(void);
|
void Init_top_self(void);
|
||||||
|
void Init_prelude(void);
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_call_inits()
|
rb_call_inits()
|
||||||
@ -94,4 +95,5 @@ rb_call_inits()
|
|||||||
Init_Thread();
|
Init_Thread();
|
||||||
Init_Cont();
|
Init_Cont();
|
||||||
Init_version();
|
Init_version();
|
||||||
|
Init_prelude();
|
||||||
}
|
}
|
||||||
|
14
prelude.rb
Normal file
14
prelude.rb
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
# Mutex
|
||||||
|
|
||||||
|
class Mutex
|
||||||
|
class Mutex
|
||||||
|
def synchronize
|
||||||
|
self.lock
|
||||||
|
yield
|
||||||
|
ensure
|
||||||
|
self.unlock
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
6
thread.c
6
thread.c
@ -2968,12 +2968,6 @@ Init_Thread(void)
|
|||||||
rb_define_method(rb_cMutex, "unlock", rb_mutex_unlock, 0);
|
rb_define_method(rb_cMutex, "unlock", rb_mutex_unlock, 0);
|
||||||
rb_define_method(rb_cMutex, "sleep", mutex_sleep, -1);
|
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__");
|
recursive_key = rb_intern("__recursive_key__");
|
||||||
rb_eThreadError = rb_define_class("ThreadError", rb_eStandardError);
|
rb_eThreadError = rb_define_class("ThreadError", rb_eStandardError);
|
||||||
|
|
||||||
|
25
tool/compile_prelude.rb
Normal file
25
tool/compile_prelude.rb
Normal file
@ -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__
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user