aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--builtin.c8
-rw-r--r--common.mk3
-rw-r--r--internal.h3
-rw-r--r--mini_builtin.c21
-rw-r--r--ruby.c4
-rw-r--r--template/prelude.c.tmpl2
6 files changed, 29 insertions, 12 deletions
diff --git a/builtin.c b/builtin.c
index 5ad7f23d5a..3bdda6159e 100644
--- a/builtin.c
+++ b/builtin.c
@@ -39,5 +39,11 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
void
Init_builtin(void)
{
- //
+ // nothing
+}
+
+void
+Init_builtin_features(void)
+{
+ rb_load_with_builtin_functions("gem_prelude", NULL);
}
diff --git a/common.mk b/common.mk
index 8defb3e5ff..579cdfa28a 100644
--- a/common.mk
+++ b/common.mk
@@ -164,7 +164,7 @@ GOLFOBJS = goruby.$(OBJEXT) golf_prelude.$(OBJEXT)
DEFAULT_PRELUDES = $(GEM_PRELUDE)
PRELUDE_SCRIPTS = $(DEFAULT_PRELUDES)
-GEM_PRELUDE = $(srcdir)/gem_prelude.rb
+GEM_PRELUDE =
PRELUDES = {$(srcdir)}prelude.c {$(srcdir)}miniprelude.c
GOLFPRELUDES = {$(srcdir)}golf_prelude.c
@@ -1003,6 +1003,7 @@ BUILTIN_RB_SRCS = \
$(srcdir)/pack.rb \
$(srcdir)/trace_point.rb \
$(srcdir)/prelude.rb \
+ $(srcdir)/gem_prelude.rb \
$(empty)
BUILTIN_RB_INCS = $(BUILTIN_RB_SRCS:.rb=.rbinc)
diff --git a/internal.h b/internal.h
index 77101d0195..374db5c0a4 100644
--- a/internal.h
+++ b/internal.h
@@ -2395,9 +2395,6 @@ RUBY_FUNC_NONNULL(1, bool rb_method_basic_definition_p_with_cc(struct rb_call_da
})
#endif
-/* miniprelude.c, prelude.c */
-void Init_prelude(void);
-
/* vm_backtrace.c */
void Init_vm_backtrace(void);
VALUE rb_vm_thread_backtrace(int argc, const VALUE *argv, VALUE thval);
diff --git a/mini_builtin.c b/mini_builtin.c
index 1254e5934f..49c6dceb19 100644
--- a/mini_builtin.c
+++ b/mini_builtin.c
@@ -6,11 +6,10 @@
// included from miniinit.c
static struct st_table *loaded_builtin_table;
-
rb_ast_t *rb_builtin_ast(const char *feature_name, VALUE *name_str);
-void
-rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
+static const rb_iseq_t *
+builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *table)
{
VALUE name_str = 0;
rb_ast_t *ast = rb_builtin_ast(feature_name, &name_str);
@@ -26,11 +25,16 @@ rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin
rb_io_write(rb_stdout, rb_iseq_disasm((const rb_iseq_t *)iseq));
}
- // register (loaded iseq will not be freed)
st_insert(loaded_builtin_table, (st_data_t)feature_name, (st_data_t)iseq);
rb_gc_register_mark_object((VALUE)iseq);
- // eval
+ return iseq;
+}
+
+void
+rb_load_with_builtin_functions(const char *feature_name, const struct rb_builtin_function *table)
+{
+ const rb_iseq_t *iseq = builtin_iseq_load(feature_name, table);
rb_iseq_eval(iseq);
}
@@ -58,3 +62,10 @@ Init_builtin(void)
rb_define_singleton_method(rb_cRubyVM, "each_builtin", each_builtin, 0);
loaded_builtin_table = st_init_strtable();
}
+
+void
+Init_builtin_features(void)
+{
+ // register for ruby
+ builtin_iseq_load("gem_prelude", NULL);
+}
diff --git a/ruby.c b/ruby.c
index 69963e390b..60c57d6259 100644
--- a/ruby.c
+++ b/ruby.c
@@ -1408,10 +1408,12 @@ proc_options(long argc, char **argv, ruby_cmdline_options_t *opt, int envopt)
return argc0 - argc;
}
+void Init_builtin_features(void);
+
static void
ruby_init_prelude(void)
{
- Init_prelude();
+ Init_builtin_features();
rb_const_remove(rb_cObject, rb_intern_const("TMP_RUBY_PREFIX"));
}
diff --git a/template/prelude.c.tmpl b/template/prelude.c.tmpl
index e3cbbaab58..b582e2ddd6 100644
--- a/template/prelude.c.tmpl
+++ b/template/prelude.c.tmpl
@@ -38,7 +38,7 @@ class Prelude
@builtin_count = 0
@preludes = {}
@mains = preludes.map do |filename|
- if prelude = filename.end_with?("_prelude.rb")
+ if prelude = filename.end_with?("golf_prelude.rb")
@prelude_count += 1
else
@builtin_count += 1