summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authorS.H <gamelinks007@gmail.com>2024-01-31 13:31:38 +0900
committerGitHub <noreply@github.com>2024-01-31 13:31:38 +0900
commitf3df218f48571a7ff1479a33691fdb83db1da7ea (patch)
treea1067be04574c3d97938bfee761128b4c8c0401f /parse.y
parent8041b7d9677d158850e14fc763038df30f14c16d (diff)
Introduced `rb_node_const_decl_val` function
Introduce `rb_node_const_decl_val` function to allow `rb_ary_join` and `rb_ary_reverse` functions to be removed from Universal Parser.
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y26
1 files changed, 1 insertions, 25 deletions
diff --git a/parse.y b/parse.y
index e87c98d4ff..613b86f551 100644
--- a/parse.y
+++ b/parse.y
@@ -13991,31 +13991,7 @@ const_decl_path(struct parser_params *p, NODE **dest)
NODE *n = *dest;
if (!nd_type_p(n, NODE_CALL)) {
const YYLTYPE *loc = &n->nd_loc;
- VALUE path;
- if (RNODE_CDECL(n)->nd_vid) {
- path = rb_id2str(RNODE_CDECL(n)->nd_vid);
- }
- else {
- n = RNODE_CDECL(n)->nd_else;
- path = rb_ary_new();
- for (; n && nd_type_p(n, NODE_COLON2); n = RNODE_COLON2(n)->nd_head) {
- rb_ary_push(path, rb_id2str(RNODE_COLON2(n)->nd_mid));
- }
- if (n && nd_type_p(n, NODE_CONST)) {
- // Const::Name
- rb_ary_push(path, rb_id2str(RNODE_CONST(n)->nd_vid));
- }
- else if (n && nd_type_p(n, NODE_COLON3)) {
- // ::Const::Name
- rb_ary_push(path, rb_str_new(0, 0));
- }
- else {
- // expression::Name
- rb_ary_push(path, rb_str_new_cstr("..."));
- }
- path = rb_ary_join(rb_ary_reverse(path), rb_str_new_cstr("::"));
- path = rb_fstring(path);
- }
+ VALUE path = rb_node_const_decl_val(n);
*dest = n = NEW_LIT(path, loc);
RB_OBJ_WRITTEN(p->ast, Qnil, RNODE_LIT(n)->nd_lit);
}