@@ -1558,20 +1558,20 @@ yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const y
1558
1558
1559
1559
// Allocate and initialize a new ClassVariableAndWriteNode node.
1560
1560
static yp_class_variable_and_write_node_t *
1561
- yp_class_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
1562
- assert(YP_NODE_TYPE_P(target, YP_NODE_CLASS_VARIABLE_READ_NODE));
1561
+ yp_class_variable_and_write_node_create(yp_parser_t *parser, yp_class_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
1563
1562
assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
1564
1563
yp_class_variable_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_class_variable_and_write_node_t);
1565
1564
1566
1565
*node = (yp_class_variable_and_write_node_t) {
1567
1566
{
1568
1567
.type = YP_NODE_CLASS_VARIABLE_AND_WRITE_NODE,
1569
1568
.location = {
1570
- .start = target->location.start,
1569
+ .start = target->base. location.start,
1571
1570
.end = value->location.end
1572
1571
}
1573
1572
},
1574
- .name_loc = target->location,
1573
+ .name = target->name,
1574
+ .name_loc = target->base.location,
1575
1575
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
1576
1576
.value = value
1577
1577
};
@@ -1581,18 +1581,19 @@ yp_class_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *target,
1581
1581
1582
1582
// Allocate and initialize a new ClassVariableOperatorWriteNode node.
1583
1583
static yp_class_variable_operator_write_node_t *
1584
- yp_class_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
1584
+ yp_class_variable_operator_write_node_create(yp_parser_t *parser, yp_class_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
1585
1585
yp_class_variable_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_class_variable_operator_write_node_t);
1586
1586
1587
1587
*node = (yp_class_variable_operator_write_node_t) {
1588
1588
{
1589
1589
.type = YP_NODE_CLASS_VARIABLE_OPERATOR_WRITE_NODE,
1590
1590
.location = {
1591
- .start = target->location.start,
1591
+ .start = target->base. location.start,
1592
1592
.end = value->location.end
1593
1593
}
1594
1594
},
1595
- .name_loc = target->location,
1595
+ .name = target->name,
1596
+ .name_loc = target->base.location,
1596
1597
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
1597
1598
.value = value,
1598
1599
.operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
@@ -1603,20 +1604,20 @@ yp_class_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *tar
1603
1604
1604
1605
// Allocate and initialize a new ClassVariableOrWriteNode node.
1605
1606
static yp_class_variable_or_write_node_t *
1606
- yp_class_variable_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
1607
- assert(YP_NODE_TYPE_P(target, YP_NODE_CLASS_VARIABLE_READ_NODE));
1607
+ yp_class_variable_or_write_node_create(yp_parser_t *parser, yp_class_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
1608
1608
assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
1609
1609
yp_class_variable_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_class_variable_or_write_node_t);
1610
1610
1611
1611
*node = (yp_class_variable_or_write_node_t) {
1612
1612
{
1613
1613
.type = YP_NODE_CLASS_VARIABLE_OR_WRITE_NODE,
1614
1614
.location = {
1615
- .start = target->location.start,
1615
+ .start = target->base. location.start,
1616
1616
.end = value->location.end
1617
1617
}
1618
1618
},
1619
- .name_loc = target->location,
1619
+ .name = target->name,
1620
+ .name_loc = target->base.location,
1620
1621
.operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
1621
1622
.value = value
1622
1623
};
@@ -1629,13 +1630,21 @@ static yp_class_variable_read_node_t *
1629
1630
yp_class_variable_read_node_create(yp_parser_t *parser, const yp_token_t *token) {
1630
1631
assert(token->type == YP_TOKEN_CLASS_VARIABLE);
1631
1632
yp_class_variable_read_node_t *node = YP_ALLOC_NODE(parser, yp_class_variable_read_node_t);
1632
- *node = (yp_class_variable_read_node_t) {{ .type = YP_NODE_CLASS_VARIABLE_READ_NODE, .location = YP_LOCATION_TOKEN_VALUE(token) }};
1633
+
1634
+ *node = (yp_class_variable_read_node_t) {
1635
+ {
1636
+ .type = YP_NODE_CLASS_VARIABLE_READ_NODE,
1637
+ .location = YP_LOCATION_TOKEN_VALUE(token)
1638
+ },
1639
+ .name = yp_parser_constant_id_location(parser, token->start, token->end)
1640
+ };
1641
+
1633
1642
return node;
1634
1643
}
1635
1644
1636
1645
// Initialize a new ClassVariableWriteNode node from a ClassVariableRead node.
1637
1646
static yp_class_variable_write_node_t *
1638
- yp_class_variable_read_node_to_class_variable_write_node (yp_parser_t *parser, yp_class_variable_read_node_t *read_node, yp_token_t *operator, yp_node_t *value) {
1647
+ yp_class_variable_write_node_create (yp_parser_t *parser, yp_class_variable_read_node_t *read_node, yp_token_t *operator, yp_node_t *value) {
1639
1648
yp_class_variable_write_node_t *node = YP_ALLOC_NODE(parser, yp_class_variable_write_node_t);
1640
1649
1641
1650
*node = (yp_class_variable_write_node_t) {
@@ -1646,6 +1655,7 @@ yp_class_variable_read_node_to_class_variable_write_node(yp_parser_t *parser, yp
1646
1655
.end = value->location.end
1647
1656
},
1648
1657
},
1658
+ .name = read_node->name,
1649
1659
.name_loc = YP_LOCATION_NODE_VALUE((yp_node_t *) read_node),
1650
1660
.operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(operator),
1651
1661
.value = value
@@ -8007,7 +8017,7 @@ parse_write(yp_parser_t *parser, yp_node_t *target, yp_token_t *operator, yp_nod
8007
8017
case YP_NODE_MISSING_NODE:
8008
8018
return target;
8009
8019
case YP_NODE_CLASS_VARIABLE_READ_NODE: {
8010
- yp_class_variable_write_node_t *write_node = yp_class_variable_read_node_to_class_variable_write_node (parser, (yp_class_variable_read_node_t *) target, operator, value);
8020
+ yp_class_variable_write_node_t *write_node = yp_class_variable_write_node_create (parser, (yp_class_variable_read_node_t *) target, operator, value);
8011
8021
yp_node_destroy(parser, target);
8012
8022
return (yp_node_t *) write_node;
8013
8023
}
@@ -12837,7 +12847,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
12837
12847
parser_lex(parser);
12838
12848
12839
12849
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
12840
- yp_node_t *result = (yp_node_t *) yp_class_variable_and_write_node_create(parser, node, &token, value);
12850
+ yp_node_t *result = (yp_node_t *) yp_class_variable_and_write_node_create(parser, (yp_class_variable_read_node_t *) node, &token, value);
12841
12851
12842
12852
yp_node_destroy(parser, node);
12843
12853
return result;
@@ -12938,7 +12948,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
12938
12948
parser_lex(parser);
12939
12949
12940
12950
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
12941
- yp_node_t *result = (yp_node_t *) yp_class_variable_or_write_node_create(parser, node, &token, value);
12951
+ yp_node_t *result = (yp_node_t *) yp_class_variable_or_write_node_create(parser, (yp_class_variable_read_node_t *) node, &token, value);
12942
12952
12943
12953
yp_node_destroy(parser, node);
12944
12954
return result;
@@ -13049,7 +13059,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
13049
13059
parser_lex(parser);
13050
13060
13051
13061
yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
13052
- yp_node_t *result = (yp_node_t *) yp_class_variable_operator_write_node_create(parser, node, &token, value);
13062
+ yp_node_t *result = (yp_node_t *) yp_class_variable_operator_write_node_create(parser, (yp_class_variable_read_node_t *) node, &token, value);
13053
13063
13054
13064
yp_node_destroy(parser, node);
13055
13065
return result;
0 commit comments