Update YARP APIs to handle uint8_t

This commit is contained in:
Kevin Newton 2023-08-30 14:32:52 -04:00
parent 7be08f3f58
commit 49dff732e8
No known key found for this signature in database
GPG Key ID: 0EAD74C79EC73F26
3 changed files with 15 additions and 15 deletions

View File

@ -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);
}
}

2
iseq.c
View File

@ -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("<compiled>");
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);

View File

@ -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;