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 VALUE
rb_builtin_ast_value(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
)
22 VALUE ast_value
= rb_builtin_ast_value(feature_name
, &name_str
);
23 rb_vm_t
*vm
= GET_VM();
25 if (NIL_P(ast_value
)) {
26 rb_fatal("builtin_iseq_load: can not find %s; "
27 "probably miniprelude.c is out of date",
30 vm
->builtin_function_table
= table
;
31 static const rb_compile_option_t optimization
= {
32 .inline_const_cache
= TRUE
,
33 .peephole_optimization
= TRUE
,
34 .tailcall_optimization
= FALSE
,
35 .specialized_instruction
= TRUE
,
36 .operands_unification
= TRUE
,
37 .instructions_unification
= TRUE
,
38 .frozen_string_literal
= TRUE
,
39 .debug_frozen_string_literal
= FALSE
,
40 .coverage_enabled
= FALSE
,
43 ast
= rb_ruby_ast_data_get(ast_value
);
44 const rb_iseq_t
*iseq
= rb_iseq_new_with_opt(ast_value
, name_str
, name_str
, Qnil
, 0, NULL
, 0, ISEQ_TYPE_TOP
, &optimization
, Qnil
);
45 GET_VM()->builtin_function_table
= NULL
;
50 if (0 && strcmp("prelude", feature_name
) == 0) {
51 rb_io_write(rb_stdout
, rb_iseq_disasm((const rb_iseq_t
*)iseq
));
54 #ifndef INCLUDED_BY_BUILTIN_C
55 st_insert(loaded_builtin_table
, (st_data_t
)feature_name
, (st_data_t
)iseq
);
56 rb_vm_register_global_object((VALUE
)iseq
);
63 rb_load_with_builtin_functions(const char *feature_name
, const struct rb_builtin_function
*table
)
65 const rb_iseq_t
*iseq
= builtin_iseq_load(feature_name
, table
);
69 #ifndef INCLUDED_BY_BUILTIN_C
72 each_builtin_i(st_data_t key
, st_data_t val
, st_data_t dmy
)
74 const char *feature
= (const char *)key
;
75 const rb_iseq_t
*iseq
= (const rb_iseq_t
*)val
;
77 rb_yield_values(2, rb_str_new2(feature
), rb_iseqw_new(iseq
));
84 each_builtin(VALUE self
)
86 st_foreach(loaded_builtin_table
, each_builtin_i
, 0);
93 rb_define_singleton_method(rb_cRubyVM
, "each_builtin", each_builtin
, 0);
94 loaded_builtin_table
= st_init_strtable();
98 Init_builtin_features(void)
101 builtin_iseq_load("gem_prelude", NULL
);