Skip to content

Commit

Permalink
Merge pull request #2821 from S-H-GAMELINKS/use/pmlocation_null_value…
Browse files Browse the repository at this point in the history
…_macro

Replace and Use `PM_LOCATION_NULL_VALUE` macro
  • Loading branch information
kddnewton authored May 17, 2024
2 parents 6e526a5 + 50e188b commit 7a05642
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -1630,7 +1630,7 @@ not_provided(pm_parser_t *parser) {
return (pm_token_t) { .type = PM_TOKEN_NOT_PROVIDED, .start = parser->start, .end = parser->start };
}

#define PM_LOCATION_NULL_VALUE(parser) ((pm_location_t) { .start = parser->start, .end = parser->start })
#define PM_LOCATION_NULL_VALUE(parser) ((pm_location_t) { .start = (parser)->start, .end = (parser)->start })
#define PM_LOCATION_TOKEN_VALUE(token) ((pm_location_t) { .start = (token)->start, .end = (token)->end })
#define PM_LOCATION_NODE_VALUE(node) ((pm_location_t) { .start = (node)->location.start, .end = (node)->location.end })
#define PM_LOCATION_NODE_BASE_VALUE(node) ((pm_location_t) { .start = (node)->base.location.start, .end = (node)->base.location.end })
Expand Down Expand Up @@ -2827,8 +2827,7 @@ static pm_call_node_t *
pm_call_node_fcall_synthesized_create(pm_parser_t *parser, pm_arguments_node_t *arguments, pm_constant_id_t name) {
pm_call_node_t *node = pm_call_node_create(parser, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY);

node->base.location.start = parser->start;
node->base.location.end = parser->start;
node->base.location = PM_LOCATION_NULL_VALUE(parser);
node->arguments = arguments;

node->name = name;
Expand Down Expand Up @@ -4621,7 +4620,7 @@ pm_global_variable_read_node_synthesized_create(pm_parser_t *parser, pm_constant
*node = (pm_global_variable_read_node_t) {
{
.type = PM_GLOBAL_VARIABLE_READ_NODE,
.location = { .start = parser->start, .end = parser->start }
.location = PM_LOCATION_NULL_VALUE(parser)
},
.name = name
};
Expand Down Expand Up @@ -4663,11 +4662,11 @@ pm_global_variable_write_node_synthesized_create(pm_parser_t *parser, pm_constan
*node = (pm_global_variable_write_node_t) {
{
.type = PM_GLOBAL_VARIABLE_WRITE_NODE,
.location = { .start = parser->start, .end = parser->start }
.location = PM_LOCATION_NULL_VALUE(parser)
},
.name = name,
.name_loc = { .start = parser->start, .end = parser->start },
.operator_loc = { .start = parser->start, .end = parser->start },
.name_loc = PM_LOCATION_NULL_VALUE(parser),
.operator_loc = PM_LOCATION_NULL_VALUE(parser),
.value = value
};

Expand Down Expand Up @@ -7355,9 +7354,9 @@ pm_symbol_node_synthesized_create(pm_parser_t *parser, const char *content) {
{
.type = PM_SYMBOL_NODE,
.flags = PM_NODE_FLAG_STATIC_LITERAL | PM_SYMBOL_FLAGS_FORCED_US_ASCII_ENCODING,
.location = { .start = parser->start, .end = parser->start }
.location = PM_LOCATION_NULL_VALUE(parser)
},
.value_loc = { .start = parser->start, .end = parser->start },
.value_loc = PM_LOCATION_NULL_VALUE(parser),
.unescaped = { 0 }
};

Expand Down Expand Up @@ -7483,7 +7482,7 @@ pm_true_node_synthesized_create(pm_parser_t *parser) {
*node = (pm_true_node_t) {{
.type = PM_TRUE_NODE,
.flags = PM_NODE_FLAG_STATIC_LITERAL,
.location = { .start = parser->start, .end = parser->end }
.location = PM_LOCATION_NULL_VALUE(parser)
}};

return node;
Expand Down Expand Up @@ -7758,10 +7757,10 @@ pm_while_node_synthesized_create(pm_parser_t *parser, pm_node_t *predicate, pm_s
*node = (pm_while_node_t) {
{
.type = PM_WHILE_NODE,
.location = { .start = parser->start, .end = parser->start }
.location = PM_LOCATION_NULL_VALUE(parser)
},
.keyword_loc = { .start = parser->start, .end = parser->start },
.closing_loc = { .start = parser->start, .end = parser->start },
.keyword_loc = PM_LOCATION_NULL_VALUE(parser),
.closing_loc = PM_LOCATION_NULL_VALUE(parser),
.predicate = predicate,
.statements = statements
};
Expand Down

0 comments on commit 7a05642

Please sign in to comment.