mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Hoisted out functions for no name rest argument symbol
This commit is contained in:
parent
6a05532315
commit
11af12026e
1 changed files with 19 additions and 8 deletions
27
ast.c
27
ast.c
|
@ -306,6 +306,20 @@ var_name(ID id)
|
||||||
return ID2SYM(id);
|
return ID2SYM(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
no_name_rest(void)
|
||||||
|
{
|
||||||
|
ID rest;
|
||||||
|
CONST_ID(rest, "NODE_SPECIAL_NO_NAME_REST");
|
||||||
|
return ID2SYM(rest);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
rest_arg(rb_ast_t *ast, const NODE *rest_arg)
|
||||||
|
{
|
||||||
|
return NODE_NAMED_REST_P(rest_arg) ? NEW_CHILD(ast, rest_arg) : no_name_rest();
|
||||||
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
node_children(rb_ast_t *ast, const NODE *node)
|
node_children(rb_ast_t *ast, const NODE *node)
|
||||||
{
|
{
|
||||||
|
@ -375,7 +389,7 @@ node_children(rb_ast_t *ast, const NODE *node)
|
||||||
else {
|
else {
|
||||||
return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_value),
|
return rb_ary_new_from_args(3, NEW_CHILD(ast, node->nd_value),
|
||||||
NEW_CHILD(ast, node->nd_head),
|
NEW_CHILD(ast, node->nd_head),
|
||||||
ID2SYM(rb_intern("NODE_SPECIAL_NO_NAME_REST")));
|
no_name_rest());
|
||||||
}
|
}
|
||||||
case NODE_LASGN:
|
case NODE_LASGN:
|
||||||
case NODE_DASGN:
|
case NODE_DASGN:
|
||||||
|
@ -535,7 +549,7 @@ node_children(rb_ast_t *ast, const NODE *node)
|
||||||
if (NODE_NAMED_REST_P(node->nd_1st)) {
|
if (NODE_NAMED_REST_P(node->nd_1st)) {
|
||||||
return rb_ary_new_from_node_args(ast, 2, node->nd_1st, node->nd_2nd);
|
return rb_ary_new_from_node_args(ast, 2, node->nd_1st, node->nd_2nd);
|
||||||
}
|
}
|
||||||
return rb_ary_new_from_args(2, ID2SYM(rb_intern("NODE_SPECIAL_NO_NAME_REST")),
|
return rb_ary_new_from_args(2, no_name_rest(),
|
||||||
NEW_CHILD(ast, node->nd_2nd));
|
NEW_CHILD(ast, node->nd_2nd));
|
||||||
case NODE_ARGS:
|
case NODE_ARGS:
|
||||||
{
|
{
|
||||||
|
@ -567,8 +581,7 @@ node_children(rb_ast_t *ast, const NODE *node)
|
||||||
case NODE_ARYPTN:
|
case NODE_ARYPTN:
|
||||||
{
|
{
|
||||||
struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
|
struct rb_ary_pattern_info *apinfo = node->nd_apinfo;
|
||||||
VALUE rest = NODE_NAMED_REST_P(apinfo->rest_arg) ? NEW_CHILD(ast, apinfo->rest_arg) :
|
VALUE rest = rest_arg(ast, apinfo->rest_arg);
|
||||||
ID2SYM(rb_intern("NODE_SPECIAL_NO_NAME_REST"));
|
|
||||||
return rb_ary_new_from_args(4,
|
return rb_ary_new_from_args(4,
|
||||||
NEW_CHILD(ast, node->nd_pconst),
|
NEW_CHILD(ast, node->nd_pconst),
|
||||||
NEW_CHILD(ast, apinfo->pre_args),
|
NEW_CHILD(ast, apinfo->pre_args),
|
||||||
|
@ -578,10 +591,8 @@ node_children(rb_ast_t *ast, const NODE *node)
|
||||||
case NODE_FNDPTN:
|
case NODE_FNDPTN:
|
||||||
{
|
{
|
||||||
struct rb_fnd_pattern_info *fpinfo = node->nd_fpinfo;
|
struct rb_fnd_pattern_info *fpinfo = node->nd_fpinfo;
|
||||||
VALUE pre_rest = NODE_NAMED_REST_P(fpinfo->pre_rest_arg) ? NEW_CHILD(ast, fpinfo->pre_rest_arg) :
|
VALUE pre_rest = rest_arg(ast, fpinfo->pre_rest_arg);
|
||||||
ID2SYM(rb_intern("NODE_SPECIAL_NO_NAME_REST"));
|
VALUE post_rest = rest_arg(ast, fpinfo->post_rest_arg);
|
||||||
VALUE post_rest = NODE_NAMED_REST_P(fpinfo->post_rest_arg) ? NEW_CHILD(ast, fpinfo->post_rest_arg) :
|
|
||||||
ID2SYM(rb_intern("NODE_SPECIAL_NO_NAME_REST"));
|
|
||||||
return rb_ary_new_from_args(4,
|
return rb_ary_new_from_args(4,
|
||||||
NEW_CHILD(ast, node->nd_pconst),
|
NEW_CHILD(ast, node->nd_pconst),
|
||||||
pre_rest,
|
pre_rest,
|
||||||
|
|
Loading…
Add table
Reference in a new issue