ruby-changes:44216
From: nobu <ko1@a...>
Date: Thu, 29 Sep 2016 20:33:08 +0900 (JST)
Subject: [ruby-changes:44216] nobu:r56289 (trunk): parse.y: deferred_dots_gen
nobu 2016-09-29 20:33:03 +0900 (Thu, 29 Sep 2016) New Revision: 56289 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=56289 Log: parse.y: deferred_dots_gen * parse.y (deferred_dots_gen): extract for tDOT2 and tDOT3. Modified files: trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 56288) +++ parse.y (revision 56289) @@ -517,6 +517,9 @@ static NODE *match_op_gen(struct parser_ https://github.com/ruby/ruby/blob/trunk/parse.y#L517 static ID *local_tbl_gen(struct parser_params*); #define local_tbl() local_tbl_gen(parser) +static NODE *deferred_dots_gen(struct parser_params*,NODE*); +#define deferred_dots(n) deferred_dots_gen(parser, (n)) + static void fixup_nodes(NODE **); static VALUE reg_compile_gen(struct parser_params*, VALUE, int); @@ -2079,10 +2082,7 @@ arg : lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2082 value_expr($1); value_expr($3); $$ = NEW_DOT2($1, $3); - if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - $3 && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { - deferred_nodes = list_append(deferred_nodes, $$); - } + deferred_dots($$); /*% $$ = dispatch2(dot2, $1, $3); %*/ @@ -2093,10 +2093,7 @@ arg : lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2093 value_expr($1); value_expr($3); $$ = NEW_DOT3($1, $3); - if ($1 && nd_type($1) == NODE_LIT && FIXNUM_P($1->nd_lit) && - $3 && nd_type($3) == NODE_LIT && FIXNUM_P($3->nd_lit)) { - deferred_nodes = list_append(deferred_nodes, $$); - } + deferred_dots($$); /*% $$ = dispatch2(dot3, $1, $3); %*/ @@ -8972,6 +8969,18 @@ match_op_gen(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L8969 return NEW_CALL(node1, tMATCH, NEW_LIST(node2)); } +static NODE * +deferred_dots_gen(struct parser_params *parser, NODE *n) +{ + NODE *b = n->nd_beg; + NODE *e = n->nd_end; + if (b && nd_type(b) == NODE_LIT && FIXNUM_P(b->nd_lit) && + e && nd_type(e) == NODE_LIT && FIXNUM_P(e->nd_lit)) { + deferred_nodes = list_append(deferred_nodes, n); + } + return n; +} + # if WARN_PAST_SCOPE static int past_dvar_p(struct parser_params *parser, ID id) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/