From 49dff732e8734dccc7e30102cadc13290618d54a Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Wed, 30 Aug 2023 14:32:52 -0400 Subject: [PATCH] Update YARP APIs to handle uint8_t --- compile.c | 2 +- iseq.c | 2 +- yarp/yarp_compiler.c | 26 +++++++++++++------------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/compile.c b/compile.c index 2673df5dbb..4d344fff9c 100644 --- a/compile.c +++ b/compile.c @@ -878,7 +878,7 @@ rb_iseq_compile_yarp_node(rb_iseq_t * iseq, const yp_node_t *yarp_pointer, yp_pa yp_constant_t constant = parser->constant_pool.constants[index]; if (constant.id != 0) { - constants[constant.id - 1] = rb_intern3(constant.start, constant.length, encoding); + constants[constant.id - 1] = rb_intern3((const char *) constant.start, constant.length, encoding); } } diff --git a/iseq.c b/iseq.c index 9082cd4861..4466de8bd1 100644 --- a/iseq.c +++ b/iseq.c @@ -1425,7 +1425,7 @@ iseqw_s_compile_yarp(int argc, VALUE *argv, VALUE self) size_t len = RSTRING_LEN(src); VALUE name = rb_fstring_lit(""); - yp_parser_init(&parser, RSTRING_PTR(src), len, ""); + yp_parser_init(&parser, (const uint8_t *) RSTRING_PTR(src), len, ""); yp_node_t *node = yp_parse(&parser); diff --git a/yarp/yarp_compiler.c b/yarp/yarp_compiler.c index fa71c12226..0c31cd83a0 100644 --- a/yarp/yarp_compiler.c +++ b/yarp/yarp_compiler.c @@ -19,8 +19,8 @@ yp_iseq_new_with_opt(yp_scope_node_t *node, yp_parser_t *parser, VALUE name, VAL static VALUE parse_number(const yp_node_t *node) { - const char *start = node->location.start; - const char *end = node->location.end; + const uint8_t *start = node->location.start; + const uint8_t *end = node->location.end; size_t length = end - start; char *buffer = malloc(length + 1); @@ -35,12 +35,12 @@ parse_number(const yp_node_t *node) { static inline VALUE parse_string(yp_string_t *string) { - return rb_str_new(yp_string_source(string), yp_string_length(string)); + return rb_str_new((const char *) yp_string_source(string), yp_string_length(string)); } static inline ID -parse_symbol(const char *start, const char *end) { - return rb_intern2(start, end - start); +parse_symbol(const uint8_t *start, const uint8_t *end) { + return rb_intern2((const char *) start, end - start); } static inline ID @@ -50,7 +50,7 @@ parse_node_symbol(yp_node_t *node) { static inline ID parse_string_symbol(yp_string_t *string) { - const char *start = yp_string_source(string); + const uint8_t *start = yp_string_source(string); return parse_symbol(start, start + yp_string_length(string)); } @@ -106,11 +106,11 @@ yp_static_literal_value(yp_node_t *node) static void yp_compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const yp_node_t *cond, - LABEL *then_label, LABEL *else_label, const char *src, bool popped, yp_compile_context_t *compile_context); + LABEL *then_label, LABEL *else_label, const uint8_t *src, bool popped, yp_compile_context_t *compile_context); static void yp_compile_logical(rb_iseq_t *iseq, LINK_ANCHOR *const ret, yp_node_t *cond, - LABEL *then_label, LABEL *else_label, const char *src, bool popped, yp_compile_context_t *compile_context) + LABEL *then_label, LABEL *else_label, const uint8_t *src, bool popped, yp_compile_context_t *compile_context) { yp_parser_t *parser = compile_context->parser; yp_newline_list_t newline_list = parser->newline_list; @@ -140,11 +140,11 @@ yp_compile_logical(rb_iseq_t *iseq, LINK_ANCHOR *const ret, yp_node_t *cond, return; } -static void yp_compile_node(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret, const char * src, bool popped, yp_compile_context_t *context); +static void yp_compile_node(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret, const uint8_t *src, bool popped, yp_compile_context_t *context); static void yp_compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const yp_node_t *cond, - LABEL *then_label, LABEL *else_label, const char *src, bool popped, yp_compile_context_t *compile_context) + LABEL *then_label, LABEL *else_label, const uint8_t *src, bool popped, yp_compile_context_t *compile_context) { yp_parser_t *parser = compile_context->parser; yp_newline_list_t newline_list = parser->newline_list; @@ -197,7 +197,7 @@ again: } static void -yp_compile_if(rb_iseq_t *iseq, const int line, yp_statements_node_t *node_body, yp_node_t *node_else, yp_node_t *predicate, LINK_ANCHOR *const ret, const char * src, bool popped, yp_compile_context_t *compile_context) { +yp_compile_if(rb_iseq_t *iseq, const int line, yp_statements_node_t *node_body, yp_node_t *node_else, yp_node_t *predicate, LINK_ANCHOR *const ret, const uint8_t *src, bool popped, yp_compile_context_t *compile_context) { NODE line_node = generate_dummy_line_node(line, line); DECL_ANCHOR(cond_seq); @@ -261,7 +261,7 @@ yp_compile_if(rb_iseq_t *iseq, const int line, yp_statements_node_t *node_body, } static void -yp_compile_while(rb_iseq_t *iseq, int lineno, yp_node_flags_t flags, enum yp_node_type type, yp_statements_node_t *statements, yp_node_t *predicate, LINK_ANCHOR *const ret, const char * src, bool popped, yp_compile_context_t *compile_context) +yp_compile_while(rb_iseq_t *iseq, int lineno, yp_node_flags_t flags, enum yp_node_type type, yp_statements_node_t *statements, yp_node_t *predicate, LINK_ANCHOR *const ret, const uint8_t *src, bool popped, yp_compile_context_t *compile_context) { NODE dummy_line_node = generate_dummy_line_node(lineno, lineno); @@ -388,7 +388,7 @@ yp_compile_class_path(LINK_ANCHOR *const ret, rb_iseq_t *iseq, const yp_node_t * * compile_context - Stores parser and local information */ static void -yp_compile_node(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret, const char * src, bool popped, yp_compile_context_t *compile_context) +yp_compile_node(rb_iseq_t *iseq, const yp_node_t *node, LINK_ANCHOR *const ret, const uint8_t *src, bool popped, yp_compile_context_t *compile_context) { yp_parser_t *parser = compile_context->parser; yp_newline_list_t newline_list = parser->newline_list;