aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryui-knk <spiketeika@gmail.com>2023-05-22 21:55:49 +0900
committerYuichiro Kaneko <spiketeika@gmail.com>2023-05-23 18:05:35 +0900
commit98637d421dbe8bcf86cc2effae5e26bb96a6a4da (patch)
tree991149893428e3b074774caba9533bb221e5ca42
parentef3aa22738d934beedfda9f486f3384e5457da8b (diff)
downloadruby-98637d421dbe8bcf86cc2effae5e26bb96a6a4da.tar.gz
Move `ruby_node_name` to node.c and rename prefix of the function
-rw-r--r--ast.c4
-rw-r--r--common.mk2
-rw-r--r--compile.c10
-rw-r--r--debug.c2
-rw-r--r--iseq.c11
-rw-r--r--node.c19
-rw-r--r--node.h2
-rw-r--r--parse.y4
8 files changed, 27 insertions, 27 deletions
diff --git a/ast.c b/ast.c
index d60e5d3fcf..1cb14bc51f 100644
--- a/ast.c
+++ b/ast.c
@@ -279,7 +279,7 @@ rb_ast_node_alloc(VALUE klass)
static const char*
node_type_to_str(const NODE *node)
{
- return (ruby_node_name(nd_type(node)) + rb_strlen_lit("NODE_"));
+ return (rb_node_name(nd_type(node)) + rb_strlen_lit("NODE_"));
}
static VALUE
@@ -675,7 +675,7 @@ node_children(rb_ast_t *ast, const NODE *node)
break;
}
- rb_bug("node_children: unknown node: %s", ruby_node_name(type));
+ rb_bug("node_children: unknown node: %s", rb_node_name(type));
}
static VALUE
diff --git a/common.mk b/common.mk
index 4fc4143e48..1e9349d464 100644
--- a/common.mk
+++ b/common.mk
@@ -8200,7 +8200,6 @@ iseq.$(OBJEXT): {$(VPATH)}iseq.h
iseq.$(OBJEXT): {$(VPATH)}method.h
iseq.$(OBJEXT): {$(VPATH)}missing.h
iseq.$(OBJEXT): {$(VPATH)}node.h
-iseq.$(OBJEXT): {$(VPATH)}node_name.inc
iseq.$(OBJEXT): {$(VPATH)}onigmo.h
iseq.$(OBJEXT): {$(VPATH)}oniguruma.h
iseq.$(OBJEXT): {$(VPATH)}ractor.h
@@ -9895,6 +9894,7 @@ node.$(OBJEXT): {$(VPATH)}method.h
node.$(OBJEXT): {$(VPATH)}missing.h
node.$(OBJEXT): {$(VPATH)}node.c
node.$(OBJEXT): {$(VPATH)}node.h
+node.$(OBJEXT): {$(VPATH)}node_name.inc
node.$(OBJEXT): {$(VPATH)}ruby_assert.h
node.$(OBJEXT): {$(VPATH)}ruby_atomic.h
node.$(OBJEXT): {$(VPATH)}shape.h
diff --git a/compile.c b/compile.c
index 7ceb936f06..db455978f2 100644
--- a/compile.c
+++ b/compile.c
@@ -404,7 +404,7 @@ do { \
if (error_type != (ndtype)) { \
COMPILE_ERROR(ERROR_ARGS_AT(error_node) \
prefix ": " #ndtype " is expected, but %s", \
- ruby_node_name(error_type)); \
+ rb_node_name(error_type)); \
return errval; \
} \
} while (0)
@@ -420,7 +420,7 @@ do { \
do { \
const NODE *error_node = (node); \
COMPILE_ERROR(ERROR_ARGS_AT(error_node) prefix ": unknown node (%s)", \
- ruby_node_name(nd_type(error_node))); \
+ rb_node_name(nd_type(error_node))); \
return errval; \
} while (0)
@@ -4302,12 +4302,12 @@ compile_branch_condition(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *co
case NODE_STR:
case NODE_ZLIST:
case NODE_LAMBDA:
- /* printf("useless condition eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
+ /* printf("useless condition eliminate (%s)\n", rb_node_name(nd_type(cond))); */
ADD_INSNL(ret, cond, jump, then_label);
return COMPILE_OK;
case NODE_FALSE:
case NODE_NIL:
- /* printf("useless condition eliminate (%s)\n", ruby_node_name(nd_type(cond))); */
+ /* printf("useless condition eliminate (%s)\n", rb_node_name(nd_type(cond))); */
ADD_INSNL(ret, cond, jump, else_label);
return COMPILE_OK;
case NODE_LIST:
@@ -8910,7 +8910,7 @@ compile_op_cdecl(rb_iseq_t *iseq, LINK_ANCHOR *const ret, const NODE *const node
break;
default:
COMPILE_ERROR(ERROR_ARGS "%s: invalid node in NODE_OP_CDECL",
- ruby_node_name(nd_type(node->nd_head)));
+ rb_node_name(nd_type(node->nd_head)));
return COMPILE_NG;
}
mid = node->nd_head->nd_mid;
diff --git a/debug.c b/debug.c
index d3f41f1a3a..bb42652335 100644
--- a/debug.c
+++ b/debug.c
@@ -148,7 +148,7 @@ ruby_debug_print_node(int level, int debug_level, const char *header, const NODE
{
if (level < debug_level) {
fprintf(stderr, "DBG> %s: %s (%u)\n", header,
- ruby_node_name(nd_type(node)), nd_line(node));
+ rb_node_name(nd_type(node)), nd_line(node));
}
return (NODE *)node;
}
diff --git a/iseq.c b/iseq.c
index 81c60ae20e..bbeb537053 100644
--- a/iseq.c
+++ b/iseq.c
@@ -2704,17 +2704,6 @@ iseqw_s_disasm(VALUE klass, VALUE body)
return NIL_P(iseqw) ? Qnil : rb_iseq_disasm(iseqw_check(iseqw));
}
-const char *
-ruby_node_name(int node)
-{
- switch (node) {
-#include "node_name.inc"
- default:
- rb_bug("unknown node: %d", node);
- return 0;
- }
-}
-
static VALUE
register_label(struct st_table *table, unsigned long idx)
{
diff --git a/node.c b/node.c
index a6cb498778..65bcb5e659 100644
--- a/node.c
+++ b/node.c
@@ -29,7 +29,7 @@
#define A_LIT(lit) AR(rb_dump_literal(lit))
#define A_NODE_HEADER(node, term) \
rb_str_catf(buf, "@ %s (id: %d, line: %d, location: (%d,%d)-(%d,%d))%s"term, \
- ruby_node_name(nd_type(node)), nd_node_id(node), nd_line(node), \
+ rb_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 ? "*" : ""))
@@ -1107,7 +1107,7 @@ dump_node(VALUE buf, VALUE indent, int comment, const NODE * node)
break;
}
- rb_bug("dump_node: unknown node: %s", ruby_node_name(nd_type(node)));
+ rb_bug("dump_node: unknown node: %s", rb_node_name(nd_type(node)));
}
VALUE
@@ -1144,6 +1144,17 @@ rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
n->node_id = -1;
}
+const char *
+rb_node_name(int node)
+{
+ switch (node) {
+#include "node_name.inc"
+ default:
+ rb_bug("unknown node: %d", node);
+ return 0;
+ }
+}
+
typedef struct node_buffer_elem_struct {
struct node_buffer_elem_struct *next;
long len;
@@ -1284,7 +1295,7 @@ rb_ast_node_type_change(NODE *n, enum node_type type)
enum node_type old_type = nd_type(n);
if (nodetype_markable_p(old_type) != nodetype_markable_p(type)) {
rb_bug("node type changed: %s -> %s",
- ruby_node_name(old_type), ruby_node_name(type));
+ rb_node_name(old_type), rb_node_name(type));
}
}
@@ -1379,7 +1390,7 @@ mark_ast_value(void *ctx, NODE * node)
rb_gc_mark_movable(node->nd_rval);
break;
default:
- rb_bug("unreachable node %s", ruby_node_name(nd_type(node)));
+ rb_bug("unreachable node %s", rb_node_name(nd_type(node)));
}
}
diff --git a/node.h b/node.h
index befb1328fb..5ec98e559c 100644
--- a/node.h
+++ b/node.h
@@ -441,7 +441,7 @@ rb_ast_t *rb_parser_compile_file_path(VALUE vparser, VALUE fname, VALUE input, i
rb_ast_t *rb_parser_compile_generic(VALUE vparser, VALUE (*lex_gets)(VALUE, int), VALUE fname, VALUE input, int line);
void rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2);
-const char *ruby_node_name(int node);
+const char *rb_node_name(int node);
const struct kwtable *rb_reserved_word(const char *, unsigned int);
diff --git a/parse.y b/parse.y
index b331174a1a..71da03908a 100644
--- a/parse.y
+++ b/parse.y
@@ -1340,7 +1340,7 @@ static int looking_at_eol_p(struct parser_params *p);
%printer {
#ifndef RIPPER
if ($$) {
- rb_parser_printf(p, "%s", ruby_node_name(nd_type($$)));
+ rb_parser_printf(p, "%s", rb_node_name(nd_type($$)));
}
#else
#endif
@@ -11078,7 +11078,7 @@ symbol_append(struct parser_params *p, NODE *symbols, NODE *symbol)
RB_OBJ_WRITTEN(p->ast, Qnil, symbol->nd_lit = rb_str_intern(symbol->nd_lit));
break;
default:
- compile_error(p, "unexpected node as symbol: %s", ruby_node_name(type));
+ compile_error(p, "unexpected node as symbol: %s", rb_node_name(type));
}
return list_append(p, symbols, symbol);
}