summaryrefslogtreecommitdiff
path: root/ruby_parser.c
diff options
context:
space:
mode:
-rw-r--r--ruby_parser.c43
1 files changed, 31 insertions, 12 deletions
@@ -1045,22 +1045,40 @@ VALUE
rb_node_const_decl_val(const NODE *node)
{
VALUE path;
- if (RNODE_CDECL(node)->nd_vid) {
- path = rb_id2str(RNODE_CDECL(node)->nd_vid);
}
- else {
- NODE *n = RNODE_CDECL(node)->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_id2str(RNODE_COLON3(n)->nd_mid));
rb_ary_push(path, rb_str_new(0, 0));
}
else {
@@ -1068,7 +1086,8 @@ rb_node_const_decl_val(const NODE *node)
rb_ary_push(path, rb_str_new_cstr("..."));
}
path = rb_ary_join(rb_ary_reverse(path), rb_str_new_cstr("::"));
- path = rb_fstring(path);
}
return path;
}