[ruby/prism] Start using flag macros/methods exclusively
https://github.com/ruby/prism/commit/5f05a6fe83
This commit is contained in:
parent
bdb38dd9f2
commit
1f22245ed5
@ -1173,12 +1173,12 @@ pm_array_node_elements_append(pm_array_node_t *node, pm_node_t *element) {
|
||||
|
||||
// If the element is not a static literal, then the array is not a static
|
||||
// literal. Turn that flag off.
|
||||
if (PM_NODE_TYPE_P(element, PM_ARRAY_NODE) || PM_NODE_TYPE_P(element, PM_HASH_NODE) || PM_NODE_TYPE_P(element, PM_RANGE_NODE) || (element->flags & PM_NODE_FLAG_STATIC_LITERAL) == 0) {
|
||||
node->base.flags &= (pm_node_flags_t) ~PM_NODE_FLAG_STATIC_LITERAL;
|
||||
if (PM_NODE_TYPE_P(element, PM_ARRAY_NODE) || PM_NODE_TYPE_P(element, PM_HASH_NODE) || PM_NODE_TYPE_P(element, PM_RANGE_NODE) || !PM_NODE_FLAG_P(element, PM_NODE_FLAG_STATIC_LITERAL)) {
|
||||
pm_node_flag_unset((pm_node_t *)node, PM_NODE_FLAG_STATIC_LITERAL);
|
||||
}
|
||||
|
||||
if (PM_NODE_TYPE_P(element, PM_SPLAT_NODE)) {
|
||||
node->base.flags |= PM_ARRAY_NODE_FLAGS_CONTAINS_SPLAT;
|
||||
pm_node_flag_set((pm_node_t *)node, PM_ARRAY_NODE_FLAGS_CONTAINS_SPLAT);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1741,7 +1741,7 @@ pm_call_node_call_create(pm_parser_t *parser, pm_node_t *receiver, pm_token_t *o
|
||||
node->block = arguments->block;
|
||||
|
||||
if (operator->type == PM_TOKEN_AMPERSAND_DOT) {
|
||||
node->base.flags |= PM_CALL_NODE_FLAGS_SAFE_NAVIGATION;
|
||||
pm_node_flag_set((pm_node_t *)node, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION);
|
||||
}
|
||||
|
||||
node->name = pm_parser_constant_id_token(parser, message);
|
||||
@ -1815,7 +1815,7 @@ pm_call_node_shorthand_create(pm_parser_t *parser, pm_node_t *receiver, pm_token
|
||||
node->block = arguments->block;
|
||||
|
||||
if (operator->type == PM_TOKEN_AMPERSAND_DOT) {
|
||||
node->base.flags |= PM_CALL_NODE_FLAGS_SAFE_NAVIGATION;
|
||||
pm_node_flag_set((pm_node_t *)node, PM_CALL_NODE_FLAGS_SAFE_NAVIGATION);
|
||||
}
|
||||
|
||||
node->name = pm_parser_constant_id_constant(parser, "call", 4);
|
||||
@ -1862,7 +1862,7 @@ pm_call_node_variable_call_create(pm_parser_t *parser, pm_token_t *message) {
|
||||
*/
|
||||
static inline bool
|
||||
pm_call_node_variable_call_p(pm_call_node_t *node) {
|
||||
return node->base.flags & PM_CALL_NODE_FLAGS_VARIABLE_CALL;
|
||||
return PM_NODE_FLAG_P(node, PM_CALL_NODE_FLAGS_VARIABLE_CALL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3350,8 +3350,8 @@ pm_hash_node_elements_append(pm_hash_node_t *hash, pm_node_t *element) {
|
||||
|
||||
// If the element is not a static literal, then the hash is not a static
|
||||
// literal. Turn that flag off.
|
||||
if (PM_NODE_TYPE_P(element, PM_ARRAY_NODE) || PM_NODE_TYPE_P(element, PM_HASH_NODE) || PM_NODE_TYPE_P(element, PM_RANGE_NODE) || (element->flags & PM_NODE_FLAG_STATIC_LITERAL) == 0) {
|
||||
hash->base.flags &= (pm_node_flags_t) ~PM_NODE_FLAG_STATIC_LITERAL;
|
||||
if (PM_NODE_TYPE_P(element, PM_ARRAY_NODE) || PM_NODE_TYPE_P(element, PM_HASH_NODE) || PM_NODE_TYPE_P(element, PM_RANGE_NODE) || !PM_NODE_FLAG_P(element, PM_NODE_FLAG_STATIC_LITERAL)) {
|
||||
pm_node_flag_unset((pm_node_t *)hash, PM_NODE_FLAG_STATIC_LITERAL);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3808,7 +3808,7 @@ static inline void
|
||||
pm_interpolated_regular_expression_node_closing_set(pm_interpolated_regular_expression_node_t *node, const pm_token_t *closing) {
|
||||
node->closing_loc = PM_LOCATION_TOKEN_VALUE(closing);
|
||||
node->base.location.end = closing->end;
|
||||
node->base.flags |= pm_regular_expression_flags_create(closing);
|
||||
pm_node_flag_set((pm_node_t *)node, pm_regular_expression_flags_create(closing));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3958,8 +3958,8 @@ static void
|
||||
pm_keyword_hash_node_elements_append(pm_keyword_hash_node_t *hash, pm_node_t *element) {
|
||||
// If the element being added is not an AssocNode or does not have a static literal key, then
|
||||
// we want to turn the STATIC_KEYS flag off.
|
||||
if (!PM_NODE_TYPE_P(element, PM_ASSOC_NODE) || (((pm_assoc_node_t *) element)->key->flags & PM_NODE_FLAG_STATIC_LITERAL) == 0) {
|
||||
hash->base.flags &= (pm_node_flags_t) ~PM_KEYWORD_HASH_NODE_FLAGS_STATIC_KEYS;
|
||||
if (!PM_NODE_TYPE_P(element, PM_ASSOC_NODE) || !PM_NODE_FLAG_P(((pm_assoc_node_t *) element)->key, PM_NODE_FLAG_STATIC_LITERAL)) {
|
||||
pm_node_flag_unset((pm_node_t *)hash, PM_KEYWORD_HASH_NODE_FLAGS_STATIC_KEYS);
|
||||
}
|
||||
|
||||
pm_node_list_append(&hash->elements, element);
|
||||
@ -5282,7 +5282,7 @@ pm_statements_node_body_append(pm_statements_node_t *node, pm_node_t *statement)
|
||||
pm_node_list_append(&node->body, statement);
|
||||
|
||||
// Every statement gets marked as a place where a newline can occur.
|
||||
statement->flags |= PM_NODE_FLAG_NEWLINE;
|
||||
pm_node_flag_set(statement, PM_NODE_FLAG_NEWLINE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -11215,7 +11215,7 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for
|
||||
parsed_bare_hash = true;
|
||||
parse_arguments_append(parser, arguments, argument);
|
||||
if (contains_keyword_splat) {
|
||||
arguments->arguments->base.flags |= PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT;
|
||||
pm_node_flag_set((pm_node_t *)arguments->arguments, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -11335,7 +11335,7 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for
|
||||
|
||||
parse_arguments_append(parser, arguments, argument);
|
||||
if (contains_keyword_splat) {
|
||||
arguments->arguments->base.flags |= PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT;
|
||||
pm_node_flag_set((pm_node_t *)arguments->arguments, PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -12403,7 +12403,7 @@ parse_string_part(pm_parser_t *parser) {
|
||||
pm_token_t closing = not_provided(parser);
|
||||
|
||||
pm_node_t *node = (pm_node_t *) pm_string_node_create_current_string(parser, &opening, &parser->current, &closing);
|
||||
node->flags |= parse_unescaped_encoding(parser);
|
||||
pm_node_flag_set(node, parse_unescaped_encoding(parser));
|
||||
|
||||
parser_lex(parser);
|
||||
return node;
|
||||
@ -12788,7 +12788,7 @@ parse_variable_call(pm_parser_t *parser) {
|
||||
}
|
||||
|
||||
pm_call_node_t *node = pm_call_node_variable_call_create(parser, &parser->previous);
|
||||
node->base.flags |= flags;
|
||||
pm_node_flag_set((pm_node_t *)node, flags);
|
||||
|
||||
return (pm_node_t *) node;
|
||||
}
|
||||
@ -13722,7 +13722,7 @@ parse_strings(pm_parser_t *parser, pm_node_t *current) {
|
||||
|
||||
if (match2(parser, PM_TOKEN_STRING_END, PM_TOKEN_EOF)) {
|
||||
node = (pm_node_t *) pm_string_node_create_unescaped(parser, &opening, &content, &parser->current, &unescaped);
|
||||
node->flags |= parse_unescaped_encoding(parser);
|
||||
pm_node_flag_set(node, parse_unescaped_encoding(parser));
|
||||
expect1(parser, PM_TOKEN_STRING_END, PM_ERR_STRING_LITERAL_TERM);
|
||||
} else if (accept1(parser, PM_TOKEN_LABEL_END)) {
|
||||
node = (pm_node_t *) pm_symbol_node_create_unescaped(parser, &opening, &content, &parser->previous, &unescaped);
|
||||
@ -13734,7 +13734,7 @@ parse_strings(pm_parser_t *parser, pm_node_t *current) {
|
||||
pm_token_t string_closing = not_provided(parser);
|
||||
|
||||
pm_node_t *part = (pm_node_t *) pm_string_node_create_unescaped(parser, &string_opening, &parser->previous, &string_closing, &unescaped);
|
||||
part->flags |= parse_unescaped_encoding(parser);
|
||||
pm_node_flag_set(part, parse_unescaped_encoding(parser));
|
||||
pm_node_list_append(&parts, part);
|
||||
|
||||
while (!match3(parser, PM_TOKEN_STRING_END, PM_TOKEN_LABEL_END, PM_TOKEN_EOF)) {
|
||||
@ -14068,7 +14068,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
|
||||
|
||||
pm_token_t closing = not_provided(parser);
|
||||
pm_node_t *node = (pm_node_t *) pm_string_node_create_current_string(parser, &opening, &content, &closing);
|
||||
node->flags |= parse_unescaped_encoding(parser);
|
||||
pm_node_flag_set(node, parse_unescaped_encoding(parser));
|
||||
|
||||
// Characters can be followed by strings in which case they are
|
||||
// automatically concatenated.
|
||||
@ -14196,7 +14196,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
|
||||
if (parse_arguments_list(parser, &arguments, true, accepts_command_call)) {
|
||||
// Since we found arguments, we need to turn off the
|
||||
// variable call bit in the flags.
|
||||
call->base.flags &= (pm_node_flags_t) ~PM_CALL_NODE_FLAGS_VARIABLE_CALL;
|
||||
pm_node_flag_unset((pm_node_t *)call, PM_CALL_NODE_FLAGS_VARIABLE_CALL);
|
||||
|
||||
call->opening_loc = arguments.opening_loc;
|
||||
call->arguments = arguments.arguments;
|
||||
@ -14276,7 +14276,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
|
||||
// content and we're at the end of the heredoc, so we can return
|
||||
// just a string node with the heredoc opening and closing as
|
||||
// its opening and closing.
|
||||
part->flags |= parse_unescaped_encoding(parser);
|
||||
pm_node_flag_set(part, parse_unescaped_encoding(parser));
|
||||
pm_string_node_t *cast = (pm_string_node_t *) part;
|
||||
|
||||
cast->opening_loc = PM_LOCATION_TOKEN_VALUE(&opening);
|
||||
@ -15631,7 +15631,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
|
||||
pm_token_t closing = not_provided(parser);
|
||||
|
||||
pm_node_t *string = (pm_node_t *) pm_string_node_create_current_string(parser, &opening, &parser->current, &closing);
|
||||
string->flags |= parse_unescaped_encoding(parser);
|
||||
pm_node_flag_set(string, parse_unescaped_encoding(parser));
|
||||
parser_lex(parser);
|
||||
|
||||
if (current == NULL) {
|
||||
@ -15850,7 +15850,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
|
||||
|
||||
if (match1(parser, PM_TOKEN_STRING_END)) {
|
||||
pm_node_t *node = (pm_node_t *) pm_xstring_node_create_unescaped(parser, &opening, &content, &parser->current, &unescaped);
|
||||
node->flags |= parse_unescaped_encoding(parser);
|
||||
pm_node_flag_set(node, parse_unescaped_encoding(parser));
|
||||
parser_lex(parser);
|
||||
return node;
|
||||
}
|
||||
@ -15863,7 +15863,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
|
||||
pm_token_t closing = not_provided(parser);
|
||||
|
||||
pm_node_t *part = (pm_node_t *) pm_string_node_create_unescaped(parser, &opening, &parser->previous, &closing, &unescaped);
|
||||
part->flags |= parse_unescaped_encoding(parser);
|
||||
pm_node_flag_set(part, parse_unescaped_encoding(parser));
|
||||
|
||||
pm_interpolated_xstring_node_append(node, part);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user