Add nd_type_p macro

This commit is contained in:
S.H 2021-12-04 00:01:24 +09:00 committed by GitHub
parent 28fb6d6b9e
commit ec7f14d9fa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2021-12-04 00:01:53 +09:00
Merged: https://github.com/ruby/ruby/pull/5091

Merged-By: nobu <nobu@ruby-lang.org>
5 changed files with 102 additions and 101 deletions

6
ast.c
View file

@ -298,7 +298,7 @@ dump_block(rb_ast_t *ast, const NODE *node)
do {
rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
} while (node->nd_next &&
nd_type(node->nd_next) == NODE_BLOCK &&
nd_type_p(node->nd_next, NODE_BLOCK) &&
(node = node->nd_next, 1));
if (node->nd_next) {
rb_ary_push(ary, NEW_CHILD(ast, node->nd_next));
@ -313,7 +313,7 @@ dump_array(rb_ast_t *ast, const NODE *node)
VALUE ary = rb_ary_new();
rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
while (node->nd_next && nd_type(node->nd_next) == NODE_LIST) {
while (node->nd_next && nd_type_p(node->nd_next, NODE_LIST)) {
node = node->nd_next;
rb_ary_push(ary, NEW_CHILD(ast, node->nd_head));
}
@ -399,7 +399,7 @@ node_children(rb_ast_t *ast, const NODE *node)
while (1) {
rb_ary_push(ary, NEW_CHILD(ast, node->nd_1st));
if (!node->nd_2nd || nd_type(node->nd_2nd) != (int)type)
if (!node->nd_2nd || !nd_type_p(node->nd_2nd, type))
break;
node = node->nd_2nd;
}