1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* trunk/common.mk, goruby.c, golf_prelude.rb: for golfers.

* trunk/main.c (main): hook for embedding applications.

* trunk/tool/compile_prelude.rb: can change initialize function name.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14676 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-12-25 07:04:30 +00:00
parent 319bcad626
commit 4496da18a8
6 changed files with 40 additions and 3 deletions

View file

@ -1,3 +1,11 @@
Tue Dec 25 16:04:28 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* trunk/common.mk, goruby.c, golf_prelude.rb: for golfers.
* trunk/main.c (main): hook for embedding applications.
* trunk/tool/compile_prelude.rb: can change initialize function name.
Tue Dec 25 15:59:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (rb_enc_register): do not use based_encoding to check if

View file

@ -14,7 +14,8 @@ LIBRUBY_EXTS = ./.libruby-with-ext.time
RDOCOUT = $(EXTOUT)/rdoc
DMYEXT = dmyext.$(OBJEXT)
MAINOBJ = main.$(OBJEXT)
NORMALMAINOBJ = main.$(OBJEXT) revision.$(OBJEXT)
MAINOBJ = $(NORMALMAINOBJ)
EXTOBJS =
DLDOBJS = $(DMYEXT)
@ -79,6 +80,8 @@ OBJS = dln.$(OBJEXT) \
prelude.$(OBJEXT) \
$(COMMONOBJS)
GOLFOBJS = goruby.$(OBJEXT) golf_prelude.$(OBJEXT)
SCRIPT_ARGS = --dest-dir="$(DESTDIR)" \
--extout="$(EXTOUT)" \
--make="$(MAKE)" \
@ -99,7 +102,13 @@ all: $(MKFILES) $(PREP) $(RBCONFIG) $(LIBRUBY) encs
@$(MINIRUBY) $(srcdir)/ext/extmk.rb $(EXTMK_ARGS)
prog: $(PROGRAM) $(WPROGRAM)
miniruby$(EXEEXT): config.status $(MAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(ARCHFILE)
miniruby$(EXEEXT): config.status $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(DMYEXT) $(ARCHFILE)
GORUBY = go$(RUBY_INSTALL_NAME)
golf: $(LIBRUBY) $(GOLFOBJS)
$(MAKE) $(MFLAGS) MAINOBJ="$(GOLFOBJS)" PROGRAM=$(GORUBY)$(EXEEXT) program
program: $(PROGRAM)
$(PROGRAM): $(LIBRUBY) $(MAINOBJ) $(OBJS) $(EXTOBJS) $(SETUP) $(PREP)
@ -600,6 +609,9 @@ blockinlining.$(OBJEXT): {$(VPATH)}blockinlining.c \
id.$(OBJEXT): {$(VPATH)}id.c {$(VPATH)}ruby.h
miniprelude.$(OBJEXT): {$(VPATH)}miniprelude.c {$(VPATH)}ruby.h {$(VPATH)}vm_core.h
prelude.$(OBJEXT): {$(VPATH)}prelude.c {$(VPATH)}ruby.h {$(VPATH)}vm_core.h
golf_prelude.$(OBJEXT): {$(VPATH)}golf_prelude.c {$(VPATH)}ruby.h {$(VPATH)}vm_core.h
goruby.$(OBJEXT): {$(VPATH)}goruby.c {$(VPATH)}main.c {$(VPATH)}ruby.h {$(VPATH)}config.h \
{$(VPATH)}defines.h {$(VPATH)}intern.h {$(VPATH)}missing.h
ascii.$(OBJEXT): {$(VPATH)}ascii.c {$(VPATH)}regenc.h \
{$(VPATH)}oniguruma.h {$(VPATH)}config.h {$(VPATH)}defines.h
@ -650,10 +662,13 @@ miniprelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb
prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $(RBCONFIG)
$(MINIRUBY) -I$(srcdir) -I$(srcdir)/lib -rrbconfig $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/gem_prelude.rb $@
golf_prelude.c: $(srcdir)/tool/compile_prelude.rb $(srcdir)/prelude.rb $(srcdir)/golf_prelude.rb
$(BASERUBY) -I$(srcdir) -I$(srcdir)/lib -rrbconfig $(srcdir)/tool/compile_prelude.rb $(srcdir)/golf_prelude.rb $@
prereq: incs srcs preludes
preludes: {$(VPATH)}miniprelude.c
preludes: {$(srcdir)}golf_prelude.c
docs:
$(BASERUBY) -I$(srcdir) $(srcdir)/tool/makedocs.rb $(INSNS2VMOPT)

7
golf_prelude.rb Normal file
View file

@ -0,0 +1,7 @@
class Object
def method_missing m, *a, &b
r = /^#{m}/
t = (methods + private_methods).sort.find{|e|r=~e}
t ? __send__(t, *a, &b) : super
end
end

3
goruby.c Normal file
View file

@ -0,0 +1,3 @@
void Init_golf(void);
#define RUBY_MAIN_INIT() Init_golf()
#include "main.c"

3
main.c
View file

@ -33,6 +33,9 @@ main(int argc, char **argv, char **envp)
{
RUBY_INIT_STACK;
ruby_init();
#ifdef RUBY_MAIN_INIT
RUBY_MAIN_INIT();
#endif
return ruby_run_node(ruby_options(argc, argv));
}
}

View file

@ -8,6 +8,7 @@ $:.unshift(File.expand_path("../..", __FILE__))
preludes = ARGV.dup
outfile = preludes.pop
init_name = outfile[/\w+(?=_prelude.c\z)/] || 'prelude'
C_ESC = {
"\\" => "\\\\",
@ -72,7 +73,7 @@ static const char prelude_code<%=i%>[] =
% }
void
Init_prelude(void)
Init_<%=init_name%>(void)
{
% lines_list.each_with_index {|(setup_lines, lines), i|
rb_iseq_eval(rb_iseq_compile(