diff --git a/internal/ruby_parser.h b/internal/ruby_parser.h index 76200ae4e4..eb36be7d4b 100644 --- a/internal/ruby_parser.h +++ b/internal/ruby_parser.h @@ -46,7 +46,6 @@ VALUE rb_parser_end_seen_p(VALUE); VALUE rb_parser_encoding(VALUE); VALUE rb_parser_set_yydebug(VALUE, VALUE); VALUE rb_parser_build_script_lines_from(rb_parser_ary_t *script_lines); -void rb_parser_aset_script_lines_for(VALUE path, rb_parser_ary_t *script_lines); void rb_parser_set_options(VALUE, int, int, int, int); VALUE rb_parser_load_file(VALUE parser, VALUE name); void rb_parser_set_script_lines(VALUE vparser); diff --git a/parse.y b/parse.y index 0bc884fe6b..24f19a683c 100644 --- a/parse.y +++ b/parse.y @@ -7722,7 +7722,6 @@ yycompile0(VALUE arg) n = yyparse(p); RUBY_DTRACE_PARSE_HOOK(END); - rb_parser_aset_script_lines_for(p->ruby_sourcefile_string, p->debug_lines); p->debug_lines = 0; xfree(p->lex.strterm); diff --git a/ruby_parser.c b/ruby_parser.c index 7ba5c26fb0..b72f875155 100644 --- a/ruby_parser.c +++ b/ruby_parser.c @@ -659,6 +659,16 @@ lex_get_str(struct parser_params *p, rb_parser_input_data input, int line_count) return rb_parser_lex_get_str((struct lex_pointer_string *)input); } +static void parser_aset_script_lines_for(VALUE path, rb_parser_ary_t *lines); + +static rb_ast_t* +parser_compile(rb_parser_t *p, rb_parser_lex_gets_func *gets, VALUE fname, rb_parser_input_data input, int line) +{ + rb_ast_t *ast = rb_parser_compile(p, gets, fname, input, line); + parser_aset_script_lines_for(fname, ast->body.script_lines); + return ast; +} + static rb_ast_t* parser_compile_string0(struct ruby_parser *parser, VALUE fname, VALUE s, int line) { @@ -668,7 +678,7 @@ parser_compile_string0(struct ruby_parser *parser, VALUE fname, VALUE s, int lin parser->data.lex_str.str = str; parser->data.lex_str.ptr = 0; - return rb_parser_compile(parser->parser_params, lex_get_str, fname, (rb_parser_input_data)&parser->data, line); + return parser_compile(parser->parser_params, lex_get_str, fname, (rb_parser_input_data)&parser->data, line); } static rb_encoding * @@ -724,7 +734,7 @@ parser_compile_file_path(struct ruby_parser *parser, VALUE fname, VALUE file, in parser->type = lex_type_io; parser->data.lex_io.file = file; - return rb_parser_compile(parser->parser_params, lex_io_gets, fname, (rb_parser_input_data)file, start); + return parser_compile(parser->parser_params, lex_io_gets, fname, (rb_parser_input_data)file, start); } static rb_ast_t* @@ -733,7 +743,7 @@ parser_compile_array(struct ruby_parser *parser, VALUE fname, VALUE array, int s parser->type = lex_type_array; parser->data.lex_array.ary = array; - return rb_parser_compile(parser->parser_params, lex_gets_array, fname, (rb_parser_input_data)array, start); + return parser_compile(parser->parser_params, lex_gets_array, fname, (rb_parser_input_data)array, start); } static rb_ast_t* @@ -741,7 +751,7 @@ parser_compile_generic(struct ruby_parser *parser, rb_parser_lex_gets_func *lex_ { parser->type = lex_type_generic; - return rb_parser_compile(parser->parser_params, lex_gets, fname, (rb_parser_input_data)input, start); + return parser_compile(parser->parser_params, lex_gets, fname, (rb_parser_input_data)input, start); } static void @@ -1100,8 +1110,8 @@ rb_node_encoding_val(const NODE *node) return rb_enc_from_encoding(RNODE_ENCODING(node)->enc); } -void -rb_parser_aset_script_lines_for(VALUE path, rb_parser_ary_t *lines) +static void +parser_aset_script_lines_for(VALUE path, rb_parser_ary_t *lines) { VALUE hash, script_lines; ID script_lines_id;