From d62328251d2231210b7d214be3e26e1c5cd32a11 Mon Sep 17 00:00:00 2001 From: Jemma Issroff Date: Tue, 11 Jul 2023 11:31:42 -0400 Subject: [PATCH] [ruby/yarp] Remove yp_location_for_node in preference of yp_newline_list_line_column https://github.com/ruby/yarp/commit/55aa813909 --- yarp/yarp.c | 34 ---------------------------------- yarp/yarp.h | 19 ------------------- 2 files changed, 53 deletions(-) diff --git a/yarp/yarp.c b/yarp/yarp.c index 3460dd2607..97b698279d 100644 --- a/yarp/yarp.c +++ b/yarp/yarp.c @@ -12900,40 +12900,6 @@ yp_parse_serialize(const char *source, size_t size, yp_buffer_t *buffer) { yp_parser_free(&parser); } -static yp_code_position_t -yp_code_position(yp_newline_list_t newline_list, size_t loc) { - int line = 0; - while (line < (int)newline_list.size && newline_list.offsets[line] < loc) { - line++; - } - - if (line > 0) { - line--; - } - - int column = (int) (loc - newline_list.offsets[line]); - - yp_code_position_t position; - position.lineno = line; - position.column = column; - - return position; -} - -yp_code_location_t -yp_location_for_node(yp_parser_t *parser, yp_node_t *node) { - yp_newline_list_t newline_list = parser->newline_list; - - yp_code_position_t start = yp_code_position(newline_list, (size_t)(node->location.start - parser->start)); - yp_code_position_t end = yp_code_position(newline_list, (size_t)(node->location.end - parser->start)); - - yp_code_location_t location; - location.beg_pos = start; - location.end_pos = end; - - return location; -} - #undef YP_CASE_KEYWORD #undef YP_CASE_OPERATOR #undef YP_CASE_WRITABLE diff --git a/yarp/yarp.h b/yarp/yarp.h index a41182ae12..4bbffdbb10 100644 --- a/yarp/yarp.h +++ b/yarp/yarp.h @@ -66,23 +66,4 @@ YP_EXPORTED_FUNCTION void yp_parse_serialize(const char *source, size_t size, yp // Returns a string representation of the given token type. YP_EXPORTED_FUNCTION const char * yp_token_type_to_str(yp_token_type_t token_type); -// This reprsents a line, column position in the parsed source code -// The layouts of this struct should not change because they mirror -// rb_code_position_struct in ruby/ruby which allows us to type pun -typedef struct yp_code_position_struct { - int lineno; - int column; -} yp_code_position_t; - -// This reprsents a begin and end of anything in the AST that has a -// location from the parsed source code. -// The layouts of this struct should not change because they mirror -// rb_code_position_struct in ruby/ruby which allows us to type pun -typedef struct yp_code_location_struct { - yp_code_position_t beg_pos; - yp_code_position_t end_pos; -} yp_code_location_t; - -yp_code_location_t yp_location_for_node(yp_parser_t *parser, yp_node_t *node); - #endif