@@ -2621,20 +2621,20 @@ yp_in_node_create(yp_parser_t *parser, yp_node_t *pattern, yp_statements_node_t
2621
2621
2622
2622
// Allocate and initialize a new InstanceVariableAndWriteNode node.
2623
2623
static yp_instance_variable_and_write_node_t *
2624
- yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
2625
- assert(YP_NODE_TYPE_P(target, YP_NODE_INSTANCE_VARIABLE_READ_NODE));
2624
+ yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_instance_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
2626
2625
assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
2627
2626
yp_instance_variable_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_and_write_node_t);
2628
2627
2629
2628
*node = (yp_instance_variable_and_write_node_t) {
2630
2629
{
2631
2630
.type = YP_NODE_INSTANCE_VARIABLE_AND_WRITE_NODE,
2632
2631
.location = {
2633
- .start = target->location.start,
2632
+ .start = target->base. location.start,
2634
2633
.end = value->location.end
2635
2634
}
2636
2635
},
2637
- .name_loc = target->location,
2636
+ .name = target->name,
2637
+ .name_loc = target->base.location,
2638
2638
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
2639
2639
.value = value
2640
2640
};
@@ -2644,18 +2644,19 @@ yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *targe
2644
2644
2645
2645
// Allocate and initialize a new InstanceVariableOperatorWriteNode node.
2646
2646
static yp_instance_variable_operator_write_node_t *
2647
- yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
2647
+ yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_instance_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
2648
2648
yp_instance_variable_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_operator_write_node_t);
2649
2649
2650
2650
*node = (yp_instance_variable_operator_write_node_t) {
2651
2651
{
2652
2652
.type = YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE,
2653
2653
.location = {
2654
- .start = target->location.start,
2654
+ .start = target->base. location.start,
2655
2655
.end = value->location.end
2656
2656
}
2657
2657
},
2658
- .name_loc = target->location,
2658
+ .name = target->name,
2659
+ .name_loc = target->base.location,
2659
2660
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
2660
2661
.value = value,
2661
2662
.operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
@@ -2666,20 +2667,20 @@ yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *
2666
2667
2667
2668
// Allocate and initialize a new InstanceVariableOrWriteNode node.
2668
2669
static yp_instance_variable_or_write_node_t *
2669
- yp_instance_variable_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
2670
- assert(YP_NODE_TYPE_P(target, YP_NODE_INSTANCE_VARIABLE_READ_NODE));
2670
+ yp_instance_variable_or_write_node_create(yp_parser_t *parser, yp_instance_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
2671
2671
assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
2672
2672
yp_instance_variable_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_or_write_node_t);
2673
2673
2674
2674
*node = (yp_instance_variable_or_write_node_t) {
2675
2675
{
2676
2676
.type = YP_NODE_INSTANCE_VARIABLE_OR_WRITE_NODE,
2677
2677
.location = {
2678
- .start = target->location.start,
2678
+ .start = target->base. location.start,
2679
2679
.end = value->location.end
2680
2680
}
2681
2681
},
2682
- .name_loc = target->location,
2682
+ .name = target->name,
2683
+ .name_loc = target->base.location,
2683
2684
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
2684
2685
.value = value
2685
2686
};
@@ -2693,9 +2694,13 @@ yp_instance_variable_read_node_create(yp_parser_t *parser, const yp_token_t *tok
2693
2694
assert(token->type == YP_TOKEN_INSTANCE_VARIABLE);
2694
2695
yp_instance_variable_read_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_read_node_t);
2695
2696
2696
- *node = (yp_instance_variable_read_node_t) {{
2697
- .type = YP_NODE_INSTANCE_VARIABLE_READ_NODE, .location = YP_LOCATION_TOKEN_VALUE(token)
2698
- }};
2697
+ *node = (yp_instance_variable_read_node_t) {
2698
+ {
2699
+ .type = YP_NODE_INSTANCE_VARIABLE_READ_NODE,
2700
+ .location = YP_LOCATION_TOKEN_VALUE(token)
2701
+ },
2702
+ .name = yp_parser_constant_id_location(parser, token->start + 1, token->end)
2703
+ };
2699
2704
2700
2705
return node;
2701
2706
}
@@ -2712,6 +2717,7 @@ yp_instance_variable_write_node_create(yp_parser_t *parser, yp_instance_variable
2712
2717
.end = value->location.end
2713
2718
}
2714
2719
},
2720
+ .name = read_node->name,
2715
2721
.name_loc = YP_LOCATION_NODE_BASE_VALUE(read_node),
2716
2722
.operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(operator),
2717
2723
.value = value
@@ -12812,7 +12818,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
12812
12818
parser_lex(parser);
12813
12819
12814
12820
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
12815
- yp_node_t *result = (yp_node_t *) yp_instance_variable_and_write_node_create(parser, node, &token, value);
12821
+ yp_node_t *result = (yp_node_t *) yp_instance_variable_and_write_node_create(parser, (yp_instance_variable_read_node_t *) node, &token, value);
12816
12822
12817
12823
yp_node_destroy(parser, node);
12818
12824
return result;
@@ -12913,7 +12919,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
12913
12919
parser_lex(parser);
12914
12920
12915
12921
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
12916
- yp_node_t *result = (yp_node_t *) yp_instance_variable_or_write_node_create(parser, node, &token, value);
12922
+ yp_node_t *result = (yp_node_t *) yp_instance_variable_or_write_node_create(parser, (yp_instance_variable_read_node_t *) node, &token, value);
12917
12923
12918
12924
yp_node_destroy(parser, node);
12919
12925
return result;
@@ -13024,7 +13030,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
13024
13030
parser_lex(parser);
13025
13031
13026
13032
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
13027
- yp_node_t *result = (yp_node_t *) yp_instance_variable_operator_write_node_create(parser, node, &token, value);
13033
+ yp_node_t *result = (yp_node_t *) yp_instance_variable_operator_write_node_create(parser, (yp_instance_variable_read_node_t *) node, &token, value);
13028
13034
13029
13035
yp_node_destroy(parser, node);
13030
13036
return result;
0 commit comments