ext/yarp/api_node.c in yarp-0.9.0 vs ext/yarp/api_node.c in yarp-0.10.0

- old
+ new

@@ -148,11 +148,11 @@ static VALUE rb_cYARPWhileNode; static VALUE rb_cYARPXStringNode; static VALUE rb_cYARPYieldNode; static VALUE -yp_location_new(yp_parser_t *parser, const char *start, const char *end, VALUE source) { +yp_location_new(yp_parser_t *parser, const uint8_t *start, const uint8_t *end, VALUE source) { VALUE argv[] = { source, LONG2FIX(start - parser->start), LONG2FIX(end - start) }; return rb_class_new_instance(3, argv, rb_cYARPLocation); } VALUE @@ -160,26 +160,26 @@ ID type = rb_intern(yp_token_type_to_str(token->type)); VALUE location = yp_location_new(parser, token->start, token->end, source); VALUE argv[] = { ID2SYM(type), - rb_enc_str_new(token->start, token->end - token->start, encoding), + rb_enc_str_new((const char *) token->start, token->end - token->start, encoding), location }; return rb_class_new_instance(3, argv, rb_cYARPToken); } static VALUE yp_string_new(yp_string_t *string, rb_encoding *encoding) { - return rb_enc_str_new(yp_string_source(string), yp_string_length(string), encoding); + return rb_enc_str_new((const char *) yp_string_source(string), yp_string_length(string), encoding); } // Create a YARP::Source object from the given parser. VALUE yp_source_new(yp_parser_t *parser) { - VALUE source = rb_str_new(parser->start, parser->end - parser->start); + VALUE source = rb_str_new((const char *) parser->start, parser->end - parser->start); VALUE offsets = rb_ary_new_capa(parser->newline_list.size); for (size_t index = 0; index < parser->newline_list.size; index++) { rb_ary_push(offsets, INT2FIX(parser->newline_list.offsets[index])); } @@ -221,11 +221,11 @@ for (size_t index = 0; index < parser->constant_pool.capacity; index++) { 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); } } yp_node_stack_node_t *node_stack = NULL; yp_node_stack_push(&node_stack, node); @@ -1364,12 +1364,12 @@ argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value argv[2] = rb_ary_pop(value_stack); - // operator_id - argv[3] = rb_id2sym(constants[cast->operator_id - 1]); + // operator + argv[3] = rb_id2sym(constants[cast->operator - 1]); // location argv[4] = yp_location_new(parser, node->location.start, node->location.end, source); rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cYARPCallOperatorWriteNode)); @@ -1463,108 +1463,128 @@ break; } #line 137 "api_node.c.erb" case YP_NODE_CLASS_VARIABLE_AND_WRITE_NODE: { yp_class_variable_and_write_node_t *cast = (yp_class_variable_and_write_node_t *) node; - VALUE argv[4]; + VALUE argv[5]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // name_loc - argv[0] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + argv[1] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); // operator_loc - argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); + argv[2] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value - argv[2] = rb_ary_pop(value_stack); + argv[3] = rb_ary_pop(value_stack); // location - argv[3] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[4] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(4, argv, rb_cYARPClassVariableAndWriteNode)); + rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cYARPClassVariableAndWriteNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_CLASS_VARIABLE_OPERATOR_WRITE_NODE: { yp_class_variable_operator_write_node_t *cast = (yp_class_variable_operator_write_node_t *) node; - VALUE argv[5]; + VALUE argv[6]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // name_loc - argv[0] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + argv[1] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); // operator_loc - argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); + argv[2] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value - argv[2] = rb_ary_pop(value_stack); + argv[3] = rb_ary_pop(value_stack); // operator - argv[3] = rb_id2sym(constants[cast->operator - 1]); + argv[4] = rb_id2sym(constants[cast->operator - 1]); // location - argv[4] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[5] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cYARPClassVariableOperatorWriteNode)); + rb_ary_push(value_stack, rb_class_new_instance(6, argv, rb_cYARPClassVariableOperatorWriteNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_CLASS_VARIABLE_OR_WRITE_NODE: { yp_class_variable_or_write_node_t *cast = (yp_class_variable_or_write_node_t *) node; - VALUE argv[4]; + VALUE argv[5]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // name_loc - argv[0] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + argv[1] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); // operator_loc - argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); + argv[2] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value - argv[2] = rb_ary_pop(value_stack); + argv[3] = rb_ary_pop(value_stack); // location - argv[3] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[4] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(4, argv, rb_cYARPClassVariableOrWriteNode)); + rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cYARPClassVariableOrWriteNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_CLASS_VARIABLE_READ_NODE: { - VALUE argv[1]; + yp_class_variable_read_node_t *cast = (yp_class_variable_read_node_t *) node; + VALUE argv[2]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // location - argv[0] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[1] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(1, argv, rb_cYARPClassVariableReadNode)); + rb_ary_push(value_stack, rb_class_new_instance(2, argv, rb_cYARPClassVariableReadNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_CLASS_VARIABLE_TARGET_NODE: { - VALUE argv[1]; + yp_class_variable_target_node_t *cast = (yp_class_variable_target_node_t *) node; + VALUE argv[2]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // location - argv[0] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[1] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(1, argv, rb_cYARPClassVariableTargetNode)); + rb_ary_push(value_stack, rb_class_new_instance(2, argv, rb_cYARPClassVariableTargetNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_CLASS_VARIABLE_WRITE_NODE: { yp_class_variable_write_node_t *cast = (yp_class_variable_write_node_t *) node; - VALUE argv[4]; + VALUE argv[5]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // name_loc - argv[0] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + argv[1] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); // value - argv[1] = rb_ary_pop(value_stack); + argv[2] = rb_ary_pop(value_stack); // operator_loc - argv[2] = cast->operator_loc.start == NULL ? Qnil : yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); + argv[3] = cast->operator_loc.start == NULL ? Qnil : yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // location - argv[3] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[4] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(4, argv, rb_cYARPClassVariableWriteNode)); + rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cYARPClassVariableWriteNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_CONSTANT_AND_WRITE_NODE: { yp_constant_and_write_node_t *cast = (yp_constant_and_write_node_t *) node; @@ -2167,16 +2187,16 @@ VALUE argv[4]; // name_loc argv[0] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); - // operator_loc - argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); - // value - argv[2] = rb_ary_pop(value_stack); + argv[1] = rb_ary_pop(value_stack); + // operator_loc + argv[2] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); + // location argv[3] = yp_location_new(parser, node->location.start, node->location.end, source); rb_ary_push(value_stack, rb_class_new_instance(4, argv, rb_cYARPGlobalVariableWriteNode)); break; @@ -2296,108 +2316,128 @@ break; } #line 137 "api_node.c.erb" case YP_NODE_INSTANCE_VARIABLE_AND_WRITE_NODE: { yp_instance_variable_and_write_node_t *cast = (yp_instance_variable_and_write_node_t *) node; - VALUE argv[4]; + VALUE argv[5]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // name_loc - argv[0] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + argv[1] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); // operator_loc - argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); + argv[2] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value - argv[2] = rb_ary_pop(value_stack); + argv[3] = rb_ary_pop(value_stack); // location - argv[3] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[4] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(4, argv, rb_cYARPInstanceVariableAndWriteNode)); + rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cYARPInstanceVariableAndWriteNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE: { yp_instance_variable_operator_write_node_t *cast = (yp_instance_variable_operator_write_node_t *) node; - VALUE argv[5]; + VALUE argv[6]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // name_loc - argv[0] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + argv[1] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); // operator_loc - argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); + argv[2] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value - argv[2] = rb_ary_pop(value_stack); + argv[3] = rb_ary_pop(value_stack); // operator - argv[3] = rb_id2sym(constants[cast->operator - 1]); + argv[4] = rb_id2sym(constants[cast->operator - 1]); // location - argv[4] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[5] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cYARPInstanceVariableOperatorWriteNode)); + rb_ary_push(value_stack, rb_class_new_instance(6, argv, rb_cYARPInstanceVariableOperatorWriteNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_INSTANCE_VARIABLE_OR_WRITE_NODE: { yp_instance_variable_or_write_node_t *cast = (yp_instance_variable_or_write_node_t *) node; - VALUE argv[4]; + VALUE argv[5]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // name_loc - argv[0] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + argv[1] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); // operator_loc - argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); + argv[2] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value - argv[2] = rb_ary_pop(value_stack); + argv[3] = rb_ary_pop(value_stack); // location - argv[3] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[4] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(4, argv, rb_cYARPInstanceVariableOrWriteNode)); + rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cYARPInstanceVariableOrWriteNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_INSTANCE_VARIABLE_READ_NODE: { - VALUE argv[1]; + yp_instance_variable_read_node_t *cast = (yp_instance_variable_read_node_t *) node; + VALUE argv[2]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // location - argv[0] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[1] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(1, argv, rb_cYARPInstanceVariableReadNode)); + rb_ary_push(value_stack, rb_class_new_instance(2, argv, rb_cYARPInstanceVariableReadNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_INSTANCE_VARIABLE_TARGET_NODE: { - VALUE argv[1]; + yp_instance_variable_target_node_t *cast = (yp_instance_variable_target_node_t *) node; + VALUE argv[2]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // location - argv[0] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[1] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(1, argv, rb_cYARPInstanceVariableTargetNode)); + rb_ary_push(value_stack, rb_class_new_instance(2, argv, rb_cYARPInstanceVariableTargetNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_INSTANCE_VARIABLE_WRITE_NODE: { yp_instance_variable_write_node_t *cast = (yp_instance_variable_write_node_t *) node; - VALUE argv[4]; + VALUE argv[5]; + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); + // name_loc - argv[0] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + argv[1] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); // value - argv[1] = rb_ary_pop(value_stack); + argv[2] = rb_ary_pop(value_stack); // operator_loc - argv[2] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); + argv[3] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // location - argv[3] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[4] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(4, argv, rb_cYARPInstanceVariableWriteNode)); + rb_ary_push(value_stack, rb_class_new_instance(5, argv, rb_cYARPInstanceVariableWriteNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_INTEGER_NODE: { VALUE argv[1]; @@ -2598,12 +2638,12 @@ argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value argv[2] = rb_ary_pop(value_stack); - // constant_id - argv[3] = rb_id2sym(constants[cast->constant_id - 1]); + // name + argv[3] = rb_id2sym(constants[cast->name - 1]); // depth argv[4] = ULONG2NUM(cast->depth); // location @@ -2624,15 +2664,15 @@ argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value argv[2] = rb_ary_pop(value_stack); - // constant_id - argv[3] = rb_id2sym(constants[cast->constant_id - 1]); + // name + argv[3] = rb_id2sym(constants[cast->name - 1]); - // operator_id - argv[4] = rb_id2sym(constants[cast->operator_id - 1]); + // operator + argv[4] = rb_id2sym(constants[cast->operator - 1]); // depth argv[5] = ULONG2NUM(cast->depth); // location @@ -2653,12 +2693,12 @@ argv[1] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // value argv[2] = rb_ary_pop(value_stack); - // constant_id - argv[3] = rb_id2sym(constants[cast->constant_id - 1]); + // name + argv[3] = rb_id2sym(constants[cast->name - 1]); // depth argv[4] = ULONG2NUM(cast->depth); // location @@ -2670,12 +2710,12 @@ #line 137 "api_node.c.erb" case YP_NODE_LOCAL_VARIABLE_READ_NODE: { yp_local_variable_read_node_t *cast = (yp_local_variable_read_node_t *) node; VALUE argv[3]; - // constant_id - argv[0] = rb_id2sym(constants[cast->constant_id - 1]); + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); // depth argv[1] = ULONG2NUM(cast->depth); // location @@ -2687,12 +2727,12 @@ #line 137 "api_node.c.erb" case YP_NODE_LOCAL_VARIABLE_TARGET_NODE: { yp_local_variable_target_node_t *cast = (yp_local_variable_target_node_t *) node; VALUE argv[3]; - // constant_id - argv[0] = rb_id2sym(constants[cast->constant_id - 1]); + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); // depth argv[1] = ULONG2NUM(cast->depth); // location @@ -2704,22 +2744,22 @@ #line 137 "api_node.c.erb" case YP_NODE_LOCAL_VARIABLE_WRITE_NODE: { yp_local_variable_write_node_t *cast = (yp_local_variable_write_node_t *) node; VALUE argv[6]; - // constant_id - argv[0] = rb_id2sym(constants[cast->constant_id - 1]); + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); // depth argv[1] = ULONG2NUM(cast->depth); - // value - argv[2] = rb_ary_pop(value_stack); - // name_loc - argv[3] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + argv[2] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); + // value + argv[3] = rb_ary_pop(value_stack); + // operator_loc argv[4] = yp_location_new(parser, cast->operator_loc.start, cast->operator_loc.end, source); // location argv[5] = yp_location_new(parser, node->location.start, node->location.end, source); @@ -2882,25 +2922,29 @@ rb_ary_push(value_stack, rb_class_new_instance(3, argv, rb_cYARPNoKeywordsParameterNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_NUMBERED_REFERENCE_READ_NODE: { - VALUE argv[1]; + yp_numbered_reference_read_node_t *cast = (yp_numbered_reference_read_node_t *) node; + VALUE argv[2]; + // number + argv[0] = ULONG2NUM(cast->number); + // location - argv[0] = yp_location_new(parser, node->location.start, node->location.end, source); + argv[1] = yp_location_new(parser, node->location.start, node->location.end, source); - rb_ary_push(value_stack, rb_class_new_instance(1, argv, rb_cYARPNumberedReferenceReadNode)); + rb_ary_push(value_stack, rb_class_new_instance(2, argv, rb_cYARPNumberedReferenceReadNode)); break; } #line 137 "api_node.c.erb" case YP_NODE_OPTIONAL_PARAMETER_NODE: { yp_optional_parameter_node_t *cast = (yp_optional_parameter_node_t *) node; VALUE argv[5]; - // constant_id - argv[0] = rb_id2sym(constants[cast->constant_id - 1]); + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); // name_loc argv[1] = yp_location_new(parser, cast->name_loc.start, cast->name_loc.end, source); // operator_loc @@ -3203,11 +3247,11 @@ #line 137 "api_node.c.erb" case YP_NODE_REQUIRED_PARAMETER_NODE: { yp_required_parameter_node_t *cast = (yp_required_parameter_node_t *) node; VALUE argv[2]; - // constant_id - argv[0] = rb_id2sym(constants[cast->constant_id - 1]); + // name + argv[0] = rb_id2sym(constants[cast->name - 1]); // location argv[1] = yp_location_new(parser, node->location.start, node->location.end, source); rb_ary_push(value_stack, rb_class_new_instance(2, argv, rb_cYARPRequiredParameterNode));