12
12
static struct st_table * loaded_builtin_table ;
13
13
#endif
14
14
15
+ bool pm_builtin_ast_value (pm_parse_result_t * result , const char * feature_name , VALUE * name_str );
15
16
VALUE rb_builtin_ast_value (const char * feature_name , VALUE * name_str );
16
17
17
18
static const rb_iseq_t *
18
19
builtin_iseq_load (const char * feature_name , const struct rb_builtin_function * table )
19
20
{
20
21
VALUE name_str = 0 ;
21
- rb_ast_t * ast ;
22
- VALUE ast_value = rb_builtin_ast_value (feature_name , & name_str );
23
- rb_vm_t * vm = GET_VM ();
22
+ const rb_iseq_t * iseq ;
24
23
25
- if (NIL_P (ast_value )) {
26
- rb_fatal ("builtin_iseq_load: can not find %s; "
27
- "probably miniprelude.c is out of date" ,
28
- feature_name );
29
- }
30
- vm -> builtin_function_table = table ;
24
+ rb_vm_t * vm = GET_VM ();
31
25
static const rb_compile_option_t optimization = {
32
26
.inline_const_cache = TRUE,
33
27
.peephole_optimization = TRUE,
@@ -40,11 +34,38 @@ builtin_iseq_load(const char *feature_name, const struct rb_builtin_function *ta
40
34
.coverage_enabled = FALSE,
41
35
.debug_level = 0 ,
42
36
};
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 ;
46
37
47
- rb_ast_dispose (ast );
38
+ if (* rb_ruby_prism_ptr ()) {
39
+ pm_parse_result_t result = { 0 };
40
+ if (!pm_builtin_ast_value (& result , feature_name , & name_str )) {
41
+ rb_fatal ("builtin_iseq_load: can not find %s; "
42
+ "probably miniprelude.c is out of date" ,
43
+ feature_name );
44
+ }
45
+
46
+ vm -> builtin_function_table = table ;
47
+ iseq = pm_iseq_new_with_opt (& result .node , name_str , name_str , Qnil , 0 , NULL , 0 , ISEQ_TYPE_TOP , & optimization );
48
+
49
+ GET_VM ()-> builtin_function_table = NULL ;
50
+ pm_parse_result_free (& result );
51
+ }
52
+ else {
53
+ VALUE ast_value = rb_builtin_ast_value (feature_name , & name_str );
54
+
55
+ if (NIL_P (ast_value )) {
56
+ rb_fatal ("builtin_iseq_load: can not find %s; "
57
+ "probably miniprelude.c is out of date" ,
58
+ feature_name );
59
+ }
60
+
61
+ rb_ast_t * ast = rb_ruby_ast_data_get (ast_value );
62
+
63
+ vm -> builtin_function_table = table ;
64
+ iseq = rb_iseq_new_with_opt (ast_value , name_str , name_str , Qnil , 0 , NULL , 0 , ISEQ_TYPE_TOP , & optimization , Qnil );
65
+
66
+ GET_VM ()-> builtin_function_table = NULL ;
67
+ rb_ast_dispose (ast );
68
+ }
48
69
49
70
// for debug
50
71
if (0 && strcmp ("prelude" , feature_name ) == 0 ) {
0 commit comments