@@ -982,7 +982,7 @@ rb_iseq_new_top(const VALUE ast_value, VALUE name, VALUE path, VALUE realpath, c
982982rb_iseq_t *
983983pm_iseq_new_top (pm_scope_node_t * node , VALUE name , VALUE path , VALUE realpath , const rb_iseq_t * parent , int * error_state )
984984{
985- iseq_new_setup_coverage (path , (int ) (node -> parser -> line_offsets . size - 1 ));
985+ iseq_new_setup_coverage (path , (int ) (pm_parser_line_offsets ( node -> parser ) -> size - 1 ));
986986
987987 return pm_iseq_new_with_opt (node , name , path , realpath , 0 , parent , 0 ,
988988 ISEQ_TYPE_TOP , & COMPILE_OPTION_DEFAULT , error_state );
@@ -1006,7 +1006,7 @@ rb_iseq_new_main(const VALUE ast_value, VALUE path, VALUE realpath, const rb_ise
10061006rb_iseq_t *
10071007pm_iseq_new_main (pm_scope_node_t * node , VALUE path , VALUE realpath , const rb_iseq_t * parent , int opt , int * error_state )
10081008{
1009- iseq_new_setup_coverage (path , (int ) (node -> parser -> line_offsets . size - 1 ));
1009+ iseq_new_setup_coverage (path , (int ) (pm_parser_line_offsets ( node -> parser ) -> size - 1 ));
10101010
10111011 return pm_iseq_new_with_opt (node , rb_fstring_lit ("<main>" ),
10121012 path , realpath , 0 ,
@@ -1035,7 +1035,7 @@ pm_iseq_new_eval(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpath,
10351035 if (rb_get_coverage_mode () & COVERAGE_TARGET_EVAL ) {
10361036 VALUE coverages = rb_get_coverages ();
10371037 if (RTEST (coverages ) && RTEST (path ) && !RTEST (rb_hash_has_key (coverages , path ))) {
1038- iseq_setup_coverage (coverages , path , ((int ) (node -> parser -> line_offsets . size - 1 )) + first_lineno - 1 );
1038+ iseq_setup_coverage (coverages , path , ((int ) (pm_parser_line_offsets ( node -> parser ) -> size - 1 )) + first_lineno - 1 );
10391039 }
10401040 }
10411041
@@ -1143,10 +1143,11 @@ pm_iseq_new_with_opt(pm_scope_node_t *node, VALUE name, VALUE path, VALUE realpa
11431143 option = & next_option ;
11441144
11451145 pm_location_t * location = & node -> base .location ;
1146- int32_t start_line = node -> parser -> start_line ;
1146+ int32_t start_line = pm_parser_start_line (node -> parser );
1147+ const pm_line_offset_list_t * line_offsets = pm_parser_line_offsets (node -> parser );
11471148
1148- pm_line_column_t start = pm_line_offset_list_line_column (& node -> parser -> line_offsets , location -> start , start_line );
1149- pm_line_column_t end = pm_line_offset_list_line_column (& node -> parser -> line_offsets , location -> start + location -> length , start_line );
1149+ pm_line_column_t start = pm_line_offset_list_line_column (line_offsets , location -> start , start_line );
1150+ pm_line_column_t end = pm_line_offset_list_line_column (line_offsets , location -> start + location -> length , start_line );
11501151
11511152 rb_code_location_t code_location = (rb_code_location_t ) {
11521153 .beg_pos = { .lineno = (int ) start .line , .column = (int ) start .column },
@@ -1411,19 +1412,20 @@ pm_iseq_compile_with_option(VALUE src, VALUE file, VALUE realpath, VALUE line, V
14111412 src = StringValue (src );
14121413 }
14131414
1414- pm_parse_result_t result = { 0 };
1415- pm_options_line_set (& result .options , NUM2INT (line ));
1416- pm_options_scopes_init (& result .options , 1 );
1415+ pm_parse_result_t result ;
1416+ pm_parse_result_init (& result );
1417+ pm_options_line_set (result .options , NUM2INT (line ));
1418+ pm_options_scopes_init (result .options , 1 );
14171419 result .node .coverage_enabled = 1 ;
14181420
14191421 switch (option .frozen_string_literal ) {
14201422 case ISEQ_FROZEN_STRING_LITERAL_UNSET :
14211423 break ;
14221424 case ISEQ_FROZEN_STRING_LITERAL_DISABLED :
1423- pm_options_frozen_string_literal_set (& result .options , false);
1425+ pm_options_frozen_string_literal_set (result .options , false);
14241426 break ;
14251427 case ISEQ_FROZEN_STRING_LITERAL_ENABLED :
1426- pm_options_frozen_string_literal_set (& result .options , true);
1428+ pm_options_frozen_string_literal_set (result .options , true);
14271429 break ;
14281430 default :
14291431 rb_bug ("pm_iseq_compile_with_option: invalid frozen_string_literal=%d" , option .frozen_string_literal );
@@ -1783,6 +1785,8 @@ iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
17831785 return iseqw_s_compile_parser (argc , argv , self , true);
17841786}
17851787
1788+ static VALUE iseqw_s_compile_file_prism (int argc , VALUE * argv , VALUE self );
1789+
17861790/*
17871791 * call-seq:
17881792 * InstructionSequence.compile_file(file[, options]) -> iseq
@@ -1806,6 +1810,10 @@ iseqw_s_compile_prism(int argc, VALUE *argv, VALUE self)
18061810static VALUE
18071811iseqw_s_compile_file (int argc , VALUE * argv , VALUE self )
18081812{
1813+ if (rb_ruby_prism_p ()) {
1814+ return iseqw_s_compile_file_prism (argc , argv , self );
1815+ }
1816+
18091817 VALUE file , opt = Qnil ;
18101818 VALUE parser , f , exc = Qnil , ret ;
18111819 rb_ast_t * ast ;
@@ -1892,8 +1900,8 @@ iseqw_s_compile_file_prism(int argc, VALUE *argv, VALUE self)
18921900 rb_execution_context_t * ec = GET_EC ();
18931901 VALUE v = rb_vm_push_frame_fname (ec , file );
18941902
1895- pm_parse_result_t result = { 0 } ;
1896- result . options . line = 1 ;
1903+ pm_parse_result_t result ;
1904+ pm_parse_result_init ( & result ) ;
18971905 result .node .coverage_enabled = 1 ;
18981906
18991907 VALUE script_lines ;
0 commit comments