diff options
author | Kevin Newton <[email protected]> | 2024-01-02 14:54:45 -0500 |
---|---|---|
committer | git <[email protected]> | 2024-01-02 20:59:19 +0000 |
commit | adbfbd822f37d9dfc94d071af4d2d4390bfb29eb (patch) | |
tree | a027fe16a035133f864df962ab83c7da0be82ee8 /prism/prism.c | |
parent | 380c218bfa85dcb1418c72144f59550999ef396c (diff) |
[ruby/prism] Ignore visibility flag
https://github.com/ruby/prism/commit/55b049ddac
Diffstat (limited to 'prism/prism.c')
-rw-r--r-- | prism/prism.c | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/prism/prism.c b/prism/prism.c index ea4e730ac2..bc758b49f2 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -1653,12 +1653,13 @@ pm_break_node_create(pm_parser_t *parser, const pm_token_t *keyword, pm_argument * in the various specializations of this function. */ static pm_call_node_t * -pm_call_node_create(pm_parser_t *parser) { +pm_call_node_create(pm_parser_t *parser, pm_node_flags_t flags) { pm_call_node_t *node = PM_ALLOC_NODE(parser, pm_call_node_t); *node = (pm_call_node_t) { { .type = PM_CALL_NODE, + .flags = flags, .location = PM_LOCATION_NULL_VALUE(parser), }, .receiver = NULL, @@ -1675,6 +1676,15 @@ pm_call_node_create(pm_parser_t *parser) { } /** + * Returns the value that the ignore visibility flag should be set to for the + * given receiver. + */ +static inline pm_node_flags_t +pm_call_node_ignore_visibility_flag(const pm_node_t *receiver) { + return PM_NODE_TYPE_P(receiver, PM_SELF_NODE) ? PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY : 0; +} + +/** * Allocate and initialize a new CallNode node from an aref or an aset * expression. */ @@ -1682,7 +1692,7 @@ static pm_call_node_t * pm_call_node_aref_create(pm_parser_t *parser, pm_node_t *receiver, pm_arguments_t *arguments) { pm_assert_value_expression(parser, receiver); - pm_call_node_t *node = pm_call_node_create(parser); + pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver)); node->base.location.start = receiver->location.start; node->base.location.end = pm_arguments_end(arguments); @@ -1708,7 +1718,7 @@ pm_call_node_binary_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t pm_assert_value_expression(parser, receiver); pm_assert_value_expression(parser, argument); - pm_call_node_t *node = pm_call_node_create(parser); + pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver)); node->base.location.start = MIN(receiver->location.start, argument->location.start); node->base.location.end = MAX(receiver->location.end, argument->location.end); @@ -1731,7 +1741,7 @@ static pm_call_node_t * pm_call_node_call_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *operator, pm_token_t *message, pm_arguments_t *arguments) { pm_assert_value_expression(parser, receiver); - pm_call_node_t *node = pm_call_node_create(parser); + pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver)); node->base.location.start = receiver->location.start; const uint8_t *end = pm_arguments_end(arguments); @@ -1762,7 +1772,7 @@ pm_call_node_call_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *o */ static pm_call_node_t * pm_call_node_fcall_create(pm_parser_t *parser, pm_token_t *message, pm_arguments_t *arguments) { - pm_call_node_t *node = pm_call_node_create(parser); + pm_call_node_t *node = pm_call_node_create(parser, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY); node->base.location.start = message->start; node->base.location.end = pm_arguments_end(arguments); @@ -1784,7 +1794,7 @@ static pm_call_node_t * pm_call_node_not_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *message, pm_arguments_t *arguments) { pm_assert_value_expression(parser, receiver); - pm_call_node_t *node = pm_call_node_create(parser); + pm_call_node_t *node = pm_call_node_create(parser, receiver == NULL ? 0 : pm_call_node_ignore_visibility_flag(receiver)); node->base.location.start = message->start; if (arguments->closing_loc.start != NULL) { @@ -1810,7 +1820,7 @@ static pm_call_node_t * pm_call_node_shorthand_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *operator, pm_arguments_t *arguments) { pm_assert_value_expression(parser, receiver); - pm_call_node_t *node = pm_call_node_create(parser); + pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver)); node->base.location.start = receiver->location.start; node->base.location.end = pm_arguments_end(arguments); @@ -1837,7 +1847,7 @@ static pm_call_node_t * pm_call_node_unary_create(pm_parser_t *parser, pm_token_t *operator, pm_node_t *receiver, const char *name) { pm_assert_value_expression(parser, receiver); - pm_call_node_t *node = pm_call_node_create(parser); + pm_call_node_t *node = pm_call_node_create(parser, pm_call_node_ignore_visibility_flag(receiver)); node->base.location.start = operator->start; node->base.location.end = receiver->location.end; @@ -1855,7 +1865,7 @@ pm_call_node_unary_create(pm_parser_t *parser, pm_token_t *operator, pm_node_t * */ static pm_call_node_t * pm_call_node_variable_call_create(pm_parser_t *parser, pm_token_t *message) { - pm_call_node_t *node = pm_call_node_create(parser); + pm_call_node_t *node = pm_call_node_create(parser, PM_CALL_NODE_FLAGS_IGNORE_VISIBILITY); node->base.location = PM_LOCATION_TOKEN_VALUE(message); node->message_loc = PM_OPTIONAL_LOCATION_TOKEN_VALUE(message); |