summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryui-knk <[email protected]>2023-10-10 21:24:39 +0900
committerYuichiro Kaneko <[email protected]>2023-10-11 19:22:34 +0900
commitf9fe7aeef46fc1e7782a942aaafa2b157b5548de (patch)
treef497a3749a3a815279a32b8ca7bda246e904e465
parentb17ae8889444bc3437ec88265cf9d90c9064def4 (diff)
Extract NODE_FL_NEWLINE access to macro
-rw-r--r--compile.c2
-rw-r--r--node_dump.c2
-rw-r--r--parse.y18
-rw-r--r--rubyparser.h4
4 files changed, 15 insertions, 11 deletions
diff --git a/compile.c b/compile.c
index 6c241c5b1d..06be77d645 100644
--- a/compile.c
+++ b/compile.c
@@ -9534,7 +9534,7 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const no
/* ignore */
}
else {
- if (node->flags & NODE_FL_NEWLINE) {
+ if (nd_fl_newline(node)) {
int event = RUBY_EVENT_LINE;
ISEQ_COMPILE_DATA(iseq)->last_line = line;
if (ISEQ_COVERAGE(iseq) && ISEQ_LINE_COVERAGE(iseq)) {
diff --git a/node_dump.c b/node_dump.c
index 7bfdcaf0c3..f1800835e6 100644
--- a/node_dump.c
+++ b/node_dump.c
@@ -30,7 +30,7 @@
ruby_node_name(nd_type(node)), nd_node_id(node), nd_line(node), \
nd_first_lineno(node), nd_first_column(node), \
nd_last_lineno(node), nd_last_column(node), \
- (node->flags & NODE_FL_NEWLINE ? "*" : ""))
+ (nd_fl_newline(node) ? "*" : ""))
#define A_FIELD_HEADER(len, name, term) \
rb_str_catf(buf, "+- %.*s:"term, (len), (name))
#define D_FIELD_HEADER(len, name, term) (A_INDENT, A_FIELD_HEADER(len, name, term))
diff --git a/parse.y b/parse.y
index ef7e6631c9..527aab09e3 100644
--- a/parse.y
+++ b/parse.y
@@ -5985,7 +5985,7 @@ string_content : tSTRING_CONTENT
p->heredoc_indent = $<num>indent;
p->heredoc_line_indent = -1;
/*%%%*/
- if ($compstmt) $compstmt->flags &= ~NODE_FL_NEWLINE;
+ if ($compstmt) nd_unset_fl_newline($compstmt);
$$ = new_evstr(p, $compstmt, &@$);
/*% %*/
/*% ripper: string_embexpr!($compstmt) %*/
@@ -8790,7 +8790,7 @@ heredoc_dedent(struct parser_params *p, NODE *root)
while (str_node) {
VALUE lit = RNODE_LIT(str_node)->nd_lit;
- if (str_node->flags & NODE_FL_NEWLINE) {
+ if (nd_fl_newline(str_node)) {
dedent_string(p, lit, indent);
}
if (!prev_lit) {
@@ -9097,7 +9097,7 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
flush_str:
set_yylval_str(str);
#ifndef RIPPER
- if (bol) yylval.node->flags |= NODE_FL_NEWLINE;
+ if (bol) nd_set_fl_newline(yylval.node);
#endif
flush_string_content(p, enc);
return tSTRING_CONTENT;
@@ -9122,7 +9122,7 @@ here_document(struct parser_params *p, rb_strterm_heredoc_t *here)
p->lex.strterm = NEW_STRTERM(func | STR_FUNC_TERM, 0, 0);
set_yylval_str(str);
#ifndef RIPPER
- if (bol) yylval.node->flags |= NODE_FL_NEWLINE;
+ if (bol) nd_set_fl_newline(yylval.node);
#endif
return tSTRING_CONTENT;
}
@@ -12275,7 +12275,7 @@ newline_node(NODE *node)
{
if (node) {
node = remove_begin(node);
- node->flags |= NODE_FL_NEWLINE;
+ nd_set_fl_newline(node);
}
return node;
}
@@ -13963,7 +13963,7 @@ reduce_nodes(struct parser_params *p, NODE **body)
(reduce_nodes(p, &type(node)->n1), body = &type(node)->n2, 1))
while (node) {
- int newline = (int)(node->flags & NODE_FL_NEWLINE);
+ int newline = (int)(nd_fl_newline(node));
switch (nd_type(node)) {
end:
case NODE_NIL:
@@ -13971,11 +13971,11 @@ reduce_nodes(struct parser_params *p, NODE **body)
return;
case NODE_RETURN:
*body = node = RNODE_RETURN(node)->nd_stts;
- if (newline && node) node->flags |= NODE_FL_NEWLINE;
+ if (newline && node) nd_set_fl_newline(node);
continue;
case NODE_BEGIN:
*body = node = RNODE_BEGIN(node)->nd_body;
- if (newline && node) node->flags |= NODE_FL_NEWLINE;
+ if (newline && node) nd_set_fl_newline(node);
continue;
case NODE_BLOCK:
body = &RNODE_BLOCK(RNODE_BLOCK(node)->nd_end)->nd_head;
@@ -14005,7 +14005,7 @@ reduce_nodes(struct parser_params *p, NODE **body)
return;
}
node = *body;
- if (newline && node) node->flags |= NODE_FL_NEWLINE;
+ if (newline && node) nd_set_fl_newline(node);
}
#undef subnodes
diff --git a/rubyparser.h b/rubyparser.h
index c7a31906ea..9cad9f767f 100644
--- a/rubyparser.h
+++ b/rubyparser.h
@@ -1059,6 +1059,10 @@ typedef struct RNode_RIPPER_VALUES {
#define NODE_TYPESHIFT 8
#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
+#define nd_fl_newline(n) (n)->flags & NODE_FL_NEWLINE
+#define nd_set_fl_newline(n) (n)->flags |= NODE_FL_NEWLINE
+#define nd_unset_fl_newline(n) (n)->flags &= ~NODE_FL_NEWLINE
+
#define nd_type(n) ((int) ((RNODE(n)->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT))
#define nd_set_type(n,t) \
rb_node_set_type(n, t)