2 #include "internal/array.h"
7 #include "miniprelude.c"
9 // included from miniinit.c
11 #ifndef INCLUDED_BY_BUILTIN_C
12 static struct st_table
*loaded_builtin_table
;
15 rb_ast_t
*rb_builtin_ast(const char *feature_name
, VALUE
*name_str
);
17 static const rb_iseq_t
*
18 builtin_iseq_load(const char *feature_name
, const struct rb_builtin_function
*table
)
21 rb_ast_t
*ast
= rb_builtin_ast(feature_name
, &name_str
);
22 rb_vm_t
*vm
= GET_VM();
24 vm
->builtin_function_table
= table
;
25 vm
->builtin_inline_index
= 0;
26 static const rb_compile_option_t optimization
= {
27 TRUE
, /* int inline_const_cache; */
28 TRUE
, /* int peephole_optimization; */
29 FALSE
,/* int tailcall_optimization; */
30 TRUE
, /* int specialized_instruction; */
31 TRUE
, /* int operands_unification; */
32 TRUE
, /* int instructions_unification; */
33 TRUE
, /* int stack_caching; */
34 TRUE
, /* int frozen_string_literal; */
35 FALSE
, /* int debug_frozen_string_literal; */
36 FALSE
, /* unsigned int coverage_enabled; */
37 0, /* int debug_level; */
39 const rb_iseq_t
*iseq
= rb_iseq_new_with_opt(&ast
->body
, name_str
, name_str
, Qnil
, INT2FIX(0), NULL
, 0, ISEQ_TYPE_TOP
, &optimization
);
40 GET_VM()->builtin_function_table
= NULL
;
45 if (0 && strcmp("prelude", feature_name
) == 0) {
46 rb_io_write(rb_stdout
, rb_iseq_disasm((const rb_iseq_t
*)iseq
));
49 #ifndef INCLUDED_BY_BUILTIN_C
50 st_insert(loaded_builtin_table
, (st_data_t
)feature_name
, (st_data_t
)iseq
);
51 rb_gc_register_mark_object((VALUE
)iseq
);
58 rb_load_with_builtin_functions(const char *feature_name
, const struct rb_builtin_function
*table
)
60 const rb_iseq_t
*iseq
= builtin_iseq_load(feature_name
, table
);
64 #ifndef INCLUDED_BY_BUILTIN_C
67 each_builtin_i(st_data_t key
, st_data_t val
, st_data_t dmy
)
69 const char *feature
= (const char *)key
;
70 const rb_iseq_t
*iseq
= (const rb_iseq_t
*)val
;
72 rb_yield_values(2, rb_str_new2(feature
), rb_iseqw_new(iseq
));
78 each_builtin(VALUE self
)
80 st_foreach(loaded_builtin_table
, each_builtin_i
, 0);
87 rb_define_singleton_method(rb_cRubyVM
, "each_builtin", each_builtin
, 0);
88 loaded_builtin_table
= st_init_strtable();
92 Init_builtin_features(void)
95 builtin_iseq_load("gem_prelude", NULL
);