[前][次][番号順一覧][スレッド一覧]

ruby-changes:49550

From: mame <ko1@a...>
Date: Mon, 8 Jan 2018 10:29:40 +0900 (JST)
Subject: [ruby-changes:49550] mame:r61666 (trunk): parse.y: make all NEW_NODE macros receive location

mame	2018-01-08 10:29:35 +0900 (Mon, 08 Jan 2018)

  New Revision: 61666

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61666

  Log:
    parse.y: make all NEW_NODE macros receive location
    
    This looks a big change, but just for refactoring.

  Modified files:
    trunk/node.h
    trunk/parse.y
Index: parse.y
===================================================================
--- parse.y	(revision 61665)
+++ parse.y	(revision 61666)
@@ -128,6 +128,8 @@ enum lex_state_e { https://github.com/ruby/ruby/blob/trunk/parse.y#L128
 
 typedef VALUE stack_type;
 
+rb_code_range_t NULL_LOC = { {0, -1}, {0, -1} };
+
 # define SHOW_BITSTACK(stack, name) (yydebug ? rb_parser_show_bitstack(parser, stack, name, __LINE__) : (void)0)
 # define BITSTACK_PUSH(stack, n) (((stack) = ((stack)<<1)|((n)&1)), SHOW_BITSTACK(stack, #stack"(push)"))
 # define BITSTACK_POP(stack)	 (((stack) = (stack) >> 1), SHOW_BITSTACK(stack, #stack"(pop)"))
@@ -347,7 +349,7 @@ static int parser_yyerror(struct parser_ https://github.com/ruby/ruby/blob/trunk/parse.y#L349
 
 #define CALL_Q_P(q) ((q) == TOKEN2VAL(tANDDOT))
 #define NODE_CALL_Q(q) (CALL_Q_P(q) ? NODE_QCALL : NODE_CALL)
-#define NEW_QCALL(q,r,m,a) NEW_NODE(NODE_CALL_Q(q),r,m,a)
+#define NEW_QCALL(q,r,m,a,loc) NEW_NODE(NODE_CALL_Q(q),r,m,a,loc)
 
 #define lambda_beginning_p() (lpar_beg && lpar_beg == paren_nest)
 
@@ -375,8 +377,8 @@ add_mark_object_gen(struct parser_params https://github.com/ruby/ruby/blob/trunk/parse.y#L377
 }
 #define add_mark_object(obj) add_mark_object_gen(parser, (obj))
 
-static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE);
-#define rb_node_newnode(type, a1, a2, a3) node_newnode(parser, (type), (a1), (a2), (a3))
+static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE, const rb_code_range_t*);
+#define rb_node_newnode(type, a1, a2, a3, loc) node_newnode(parser, (type), (a1), (a2), (a3), (loc))
 
 #ifndef RIPPER
 static inline void
@@ -494,7 +496,7 @@ static NODE *new_const_op_assign_gen(str https://github.com/ruby/ruby/blob/trunk/parse.y#L496
 
 static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *location);
 #define const_path_field(w, n, location) const_path_field_gen(parser, w, n, location)
-#define top_const_field(n) NEW_COLON3(n)
+#define top_const_field(n,loc) NEW_COLON3(n,loc)
 static NODE *const_decl_gen(struct parser_params *parser, NODE* path, const YYLTYPE *location);
 #define const_decl(path, location) const_decl_gen(parser, path, location)
 
@@ -614,7 +616,7 @@ ripper_new_yylval_gen(struct parser_para https://github.com/ruby/ruby/blob/trunk/parse.y#L616
 {
     add_mark_object(b);
     add_mark_object(c);
-    return (VALUE)NEW_CDECL(a, b, c);
+    return (VALUE)NEW_CDECL(a, b, c, &NULL_LOC);
 }
 #define ripper_new_yylval(a, b, c) ripper_new_yylval_gen(parser, a, b, c)
 
@@ -666,7 +668,7 @@ static VALUE new_xstring_gen(struct pars https://github.com/ruby/ruby/blob/trunk/parse.y#L668
 #define new_do_body(param, stmt, location) dispatch2(do_block, escape_Qundef(param), stmt)
 
 #define const_path_field(w, n, location) dispatch2(const_path_field, (w), (n))
-#define top_const_field(n) dispatch1(top_const_field, (n))
+#define top_const_field(n,loc) dispatch1(top_const_field, (n))
 static VALUE const_decl_gen(struct parser_params *parser, VALUE path);
 #define const_decl(path, location) const_decl_gen(parser, path)
 
@@ -888,7 +890,7 @@ new_args_gen(struct parser_params *parse https://github.com/ruby/ruby/blob/trunk/parse.y#L890
 static inline VALUE
 new_args_tail_gen(struct parser_params *parser, VALUE k, VALUE kr, VALUE b)
 {
-    NODE *t = rb_node_newnode(NODE_ARGS_AUX, k, kr, b);
+    NODE *t = rb_node_newnode(NODE_ARGS_AUX, k, kr, b, &NULL_LOC);
     add_mark_object(k);
     add_mark_object(kr);
     add_mark_object(b);
@@ -1272,12 +1274,10 @@ bodystmt	: compstmt https://github.com/ruby/ruby/blob/trunk/parse.y#L1274
 			}
 			if ($4) {
 			    if ($$) {
-				$$ = NEW_ENSURE($$, $4);
-				$$->nd_loc = @$;
+				$$ = NEW_ENSURE($$, $4, &@$);
 			    }
 			    else {
-				NODE *nil = NEW_NIL();
-				nil->nd_loc = @$;
+				NODE *nil = NEW_NIL(&@$);
 				$$ = block_append($4, nil, &@$);
 			    }
 			}
@@ -1362,8 +1362,7 @@ stmt_or_begin	: stmt https://github.com/ruby/ruby/blob/trunk/parse.y#L1362
 stmt		: keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
 		    {
 		    /*%%%*/
-			$$ = NEW_ALIAS($2, $4);
-			$$->nd_loc = @$;
+			$$ = NEW_ALIAS($2, $4, &@$);
 		    /*%
 			$$ = dispatch2(alias, $2, $4);
 		    %*/
@@ -1371,8 +1370,7 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1370
 		| keyword_alias tGVAR tGVAR
 		    {
 		    /*%%%*/
-			$$ = NEW_VALIAS($2, $3);
-			$$->nd_loc = @$;
+			$$ = NEW_VALIAS($2, $3, &@$);
 		    /*%
 			$$ = dispatch2(var_alias, $2, $3);
 		    %*/
@@ -1383,8 +1381,7 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1381
 			char buf[2];
 			buf[0] = '$';
 			buf[1] = (char)$3->nd_nth;
-			$$ = NEW_VALIAS($2, rb_intern2(buf, 2));
-			$$->nd_loc = @$;
+			$$ = NEW_VALIAS($2, rb_intern2(buf, 2), &@$);
 		    /*%
 			$$ = dispatch2(var_alias, $2, $3);
 		    %*/
@@ -1430,12 +1427,11 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1427
 		    {
 		    /*%%%*/
 			if ($1 && nd_type($1) == NODE_BEGIN) {
-			    $$ = NEW_WHILE(cond($3, &@3), $1->nd_body, 0);
+			    $$ = NEW_WHILE(cond($3, &@3), $1->nd_body, 0, &@$);
 			}
 			else {
-			    $$ = NEW_WHILE(cond($3, &@3), $1, 1);
+			    $$ = NEW_WHILE(cond($3, &@3), $1, 1, &@$);
 			}
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(while_mod, $3, $1);
 		    %*/
@@ -1444,12 +1440,11 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1440
 		    {
 		    /*%%%*/
 			if ($1 && nd_type($1) == NODE_BEGIN) {
-			    $$ = NEW_UNTIL(cond($3, &@3), $1->nd_body, 0);
+			    $$ = NEW_UNTIL(cond($3, &@3), $1->nd_body, 0, &@$);
 			}
 			else {
-			    $$ = NEW_UNTIL(cond($3, &@3), $1, 1);
+			    $$ = NEW_UNTIL(cond($3, &@3), $1, 1, &@$);
 			}
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(until_mod, $3, $1);
 		    %*/
@@ -1475,10 +1470,8 @@ stmt		: keyword_alias fitem {SET_LEX_STA https://github.com/ruby/ruby/blob/trunk/parse.y#L1470
 		    /*%%%*/
 			{
 			    NODE *scope = NEW_NODE(
-				NODE_SCOPE, 0 /* tbl */, $3 /* body */, 0 /* args */);
-			    $$ = NEW_POSTEXE(scope);
-			    scope->nd_loc = @$;
-			    $$->nd_loc = @$;
+				NODE_SCOPE, 0 /* tbl */, $3 /* body */, 0 /* args */, &@$);
+			    $$ = NEW_POSTEXE(scope, &@$);
 			}
 		    /*%
 			$$ = dispatch1(END, $3);
@@ -1534,9 +1527,8 @@ command_asgn	: lhs '=' command_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L1527
 			else if ($5 == tANDOP) {
 			    $5 = 1;
 			}
-			$$ = NEW_OP_ASGN1($1, $5, args);
+			$$ = NEW_OP_ASGN1($1, $5, args, &@$);
 			fixpos($$, $1);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(aref_field, $1, escape_Qundef($3));
 			$$ = dispatch3(opassign, $$, $5, $6);
@@ -1623,7 +1615,7 @@ expr_value	: expr https://github.com/ruby/ruby/blob/trunk/parse.y#L1615
 		    /*%%%*/
 			value_expr($1);
 			$$ = $1;
-			if (!$$) $$ = NEW_NIL();
+			if (!$$) $$ = NEW_NIL(&@$);
 		    /*%
 			$$ = $1;
 		    %*/
@@ -1717,9 +1709,8 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1709
 		| keyword_super command_args
 		    {
 		    /*%%%*/
-			$$ = NEW_SUPER($2);
+			$$ = NEW_SUPER($2, &@$);
 			fixpos($$, $2);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch1(super, $2);
 		    %*/
@@ -1736,8 +1727,7 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1727
 		| k_return call_args
 		    {
 		    /*%%%*/
-			$$ = NEW_RETURN(ret_args($2));
-			$$->nd_loc = @$;
+			$$ = NEW_RETURN(ret_args($2), &@$);
 		    /*%
 			$$ = dispatch1(return, $2);
 		    %*/
@@ -1745,8 +1735,7 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1735
 		| keyword_break call_args
 		    {
 		    /*%%%*/
-			$$ = NEW_BREAK(ret_args($2));
-			$$->nd_loc = @$;
+			$$ = NEW_BREAK(ret_args($2), &@$);
 		    /*%
 			$$ = dispatch1(break, $2);
 		    %*/
@@ -1754,8 +1743,7 @@ command		: fcall command_args       %pre https://github.com/ruby/ruby/blob/trunk/parse.y#L1743
 		| keyword_next call_args
 		    {
 		    /*%%%*/
-			$$ = NEW_NEXT(ret_args($2));
-			$$->nd_loc = @$;
+			$$ = NEW_NEXT(ret_args($2), &@$);
 		    /*%
 			$$ = dispatch1(next, $2);
 		    %*/
@@ -1963,7 +1951,7 @@ mlhs_node	: user_variable https://github.com/ruby/ruby/blob/trunk/parse.y#L1951
 		    }
 		| tCOLON3 tCONSTANT
 		    {
-			$$ = const_decl(top_const_field($2), &@$);
+			$$ = const_decl(top_const_field($2, &@$), &@$);
 		    }
 		| backref
 		    {
@@ -2018,7 +2006,7 @@ lhs		: user_variable https://github.com/ruby/ruby/blob/trunk/parse.y#L2006
 		    }
 		| tCOLON3 tCONSTANT
 		    {
-			$$ = const_decl(top_const_field($2), &@$);
+			$$ = const_decl(top_const_field($2, &@$), &@$);
 		    }
 		| backref
 		    {
@@ -2042,8 +2030,7 @@ cname		: tIDENTIFIER https://github.com/ruby/ruby/blob/trunk/parse.y#L2030
 cpath		: tCOLON3 cname
 		    {
 		    /*%%%*/
-			$$ = NEW_COLON3($2);
-			$$->nd_loc = @$;
+			$$ = NEW_COLON3($2, &@$);
 		    /*%
 			$$ = dispatch1(top_const_ref, $2);
 		    %*/
@@ -2051,8 +2038,7 @@ cpath		: tCOLON3 cname https://github.com/ruby/ruby/blob/trunk/parse.y#L2038
 		| cname
 		    {
 		    /*%%%*/
-			$$ = NEW_COLON2(0, $$);
-			$$->nd_loc = @$;
+			$$ = NEW_COLON2(0, $$, &@$);
 		    /*%
 			$$ = dispatch1(const_ref, $1);
 		    %*/
@@ -2060,8 +2046,7 @@ cpath		: tCOLON3 cname https://github.com/ruby/ruby/blob/trunk/parse.y#L2046
 		| primary_value tCOLON2 cname
 		    {
 		    /*%%%*/
-			$$ = NEW_COLON2($1, $3);
-			$$->nd_loc = @$;
+			$$ = NEW_COLON2($1, $3, &@$);
 		    /*%
 			$$ = dispatch2(const_path_ref, $1, $3);
 		    %*/
@@ -2179,8 +2164,7 @@ arg		: lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2164
 			value_expr($6);
 			$3 = make_array($3, &@3);
 			if (nd_type($3) == NODE_BLOCK_PASS) {
-			    args = NEW_ARGSCAT($3, $6);
-			    args->nd_loc = @$;
+			    args = NEW_ARGSCAT($3, $6, &@$);
 			}
 			else {
 			    args = arg_concat($3, $6, &@$);
@@ -2191,9 +2175,8 @@ arg		: lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2175
 			else if ($5 == tANDOP) {
 			    $5 = 1;
 			}
-			$$ = NEW_OP_ASGN1($1, $5, args);
+			$$ = NEW_OP_ASGN1($1, $5, args, &@$);
 			fixpos($$, $1);
-			$$->nd_loc = @$;
 		    /*%
 			$1 = dispatch2(aref_field, $1, escape_Qundef($3));
 			$$ = dispatch3(opassign, $1, $5, $6);
@@ -2227,7 +2210,7 @@ arg		: lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2210
 		    }
 		| tCOLON3 tCONSTANT tOP_ASGN arg_rhs
 		    {
-			$$ = top_const_field($2);
+			$$ = top_const_field($2, &@$);
 			$$ = new_const_op_assign($$, $3, $4, &@$);
 		    }
 		| backref tOP_ASGN arg_rhs
@@ -2240,8 +2223,7 @@ arg		: lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2223
 		    /*%%%*/
 			value_expr($1);
 			value_expr($3);
-			$$ = NEW_DOT2($1, $3);
-			$$->nd_loc = @$;
+			$$ = NEW_DOT2($1, $3, &@$);
 		    /*%
 			$$ = dispatch2(dot2, $1, $3);
 		    %*/
@@ -2251,8 +2233,7 @@ arg		: lhs '=' arg_rhs https://github.com/ruby/ruby/blob/trunk/parse.y#L2233
 		    /*%%%*/
 			value_expr($1);
 			value_expr($3);
-			$$ = NEW_DOT3($1, $3);
-			$$->nd_loc = @$;
+			$$ = NEW_DOT3($1, $3, &@$);
 		    /*%
 			$$ = dispatch2(dot3, $1, $3);
 		    %*/
@@ -2397,7 +2378,7 @@ arg_value	: arg https://github.com/ruby/ruby/blob/trunk/parse.y#L2378
 		    /*%%%*/
 			value_expr($1);
 			$$ = $1;
-			if (!$$) $$ = NEW_NIL();
+			if (!$$) $$ = NEW_NIL(&@$);
 		    /*%
 			$$ = $1;
 		    %*/
@@ -2547,8 +2528,7 @@ command_args	:   { https://github.com/ruby/ruby/blob/trunk/parse.y#L2528
 block_arg	: tAMPER arg_value
 		    {
 		    /*%%%*/
-			$$ = NEW_BLOCK_PASS($2);
-			$$->nd_loc = @$;
+			$$ = NEW_BLOCK_PASS($2, &@$);
 		    /*%
 			$$ = $2;
 		    %*/
@@ -2576,8 +2556,7 @@ args		: arg_value https://github.com/ruby/ruby/blob/trunk/parse.y#L2556
 		| tSTAR arg_value
 		    {
 		    /*%%%*/
-			$$ = NEW_SPLAT($2);
-			$$->nd_loc = @$;
+			$$ = NEW_SPLAT($2, &@$);
 		    /*%
 			$$ = arg_add_star(arg_new(), $2);
 		    %*/
@@ -2648,8 +2627,7 @@ mrhs		: args ',' arg_value https://github.com/ruby/ruby/blob/trunk/parse.y#L2627
 		| tSTAR arg_value
 		    {
 		    /*%%%*/
-			$$ = NEW_SPLAT($2);
-			$$->nd_loc = @$;
+			$$ = NEW_SPLAT($2, &@$);
 		    /*%
 			$$ = mrhs_add_star(mrhs_new(), $2);
 		    %*/
@@ -2689,8 +2667,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2667
 			CMDARG_SET($<val>1);
 		    /*%%%*/
 			if ($3 == NULL) {
-			    $$ = NEW_NIL();
-			    $$->nd_loc = @$;
+			    $$ = NEW_NIL(&@$);
 			}
 			else {
 			    set_line_body($3, $<num>2);
@@ -2734,8 +2711,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2711
 		| primary_value tCOLON2 tCONSTANT
 		    {
 		    /*%%%*/
-			$$ = NEW_COLON2($1, $3);
-			$$->nd_loc = @$;
+			$$ = NEW_COLON2($1, $3, &@$);
 		    /*%
 			$$ = dispatch2(const_path_ref, $1, $3);
 		    %*/
@@ -2743,8 +2719,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2719
 		| tCOLON3 tCONSTANT
 		    {
 		    /*%%%*/
-			$$ = NEW_COLON3($2);
-			$$->nd_loc = @$;
+			$$ = NEW_COLON3($2, &@$);
 		    /*%
 			$$ = dispatch1(top_const_ref, $2);
 		    %*/
@@ -2769,8 +2744,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2744
 		| k_return
 		    {
 		    /*%%%*/
-			$$ = NEW_RETURN(0);
-			$$->nd_loc = @$;
+			$$ = NEW_RETURN(0, &@$);
 		    /*%
 			$$ = dispatch0(return0);
 		    %*/
@@ -2786,8 +2760,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2760
 		| keyword_yield '(' rparen
 		    {
 		    /*%%%*/
-			$$ = NEW_YIELD(0);
-			$$->nd_loc = @$;
+			$$ = NEW_YIELD(0, &@$);
 		    /*%
 			$$ = dispatch1(yield, dispatch1(paren, arg_new()));
 		    %*/
@@ -2795,8 +2768,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2768
 		| keyword_yield
 		    {
 		    /*%%%*/
-			$$ = NEW_YIELD(0);
-			$$->nd_loc = @$;
+			$$ = NEW_YIELD(0, &@$);
 		    /*%
 			$$ = dispatch0(yield0);
 		    %*/
@@ -2866,9 +2838,8 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2838
 		  k_end
 		    {
 		    /*%%%*/
-			$$ = NEW_WHILE(cond($3, &@3), $6, 1);
+			$$ = NEW_WHILE(cond($3, &@3), $6, 1, &@$);
 			fixpos($$, $3);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(while, $3, $6);
 		    %*/
@@ -2878,9 +2849,8 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2849
 		  k_end
 		    {
 		    /*%%%*/
-			$$ = NEW_UNTIL(cond($3, &@3), $6, 1);
+			$$ = NEW_UNTIL(cond($3, &@3), $6, 1, &@$);
 			fixpos($$, $3);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(until, $3, $6);
 		    %*/
@@ -2890,9 +2860,8 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2860
 		  k_end
 		    {
 		    /*%%%*/
-			$$ = NEW_CASE($2, $4);
+			$$ = NEW_CASE($2, $4, &@$);
 			fixpos($$, $2);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(case, $2, $4);
 		    %*/
@@ -2900,7 +2869,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2869
 		| k_case opt_terms case_body k_end
 		    {
 		    /*%%%*/
-			$$ = NEW_CASE2($3);
+			$$ = NEW_CASE2($3, &@$);
 			nd_set_line($$, $<num>1);
 			$$->nd_loc = @$;
 		    /*%
@@ -2926,7 +2895,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2895
 			 */
 			ID id = internal_id();
 			ID *tbl = ALLOC_N(ID, 2);
-			NODE *m = NEW_ARGS_AUX(0, 0);
+			NODE *m = NEW_ARGS_AUX(0, 0, &NULL_LOC);
 			NODE *args, *scope;
 
 			switch (nd_type($2)) {
@@ -2951,8 +2920,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2920
 			    }
 			}
 			add_mark_object((VALUE)rb_imemo_alloc_new((VALUE)tbl, 0, 0, 0));
-			scope = NEW_NODE(NODE_SCOPE, tbl, $8, args);
-			scope->nd_loc = @$;
+			scope = NEW_NODE(NODE_SCOPE, tbl, $8, args, &@$);
 			tbl[0] = 1; tbl[1] = id;
 			$$ = new_for(0, $5, scope, &@$);
 			fixpos($$, $2);
@@ -2980,11 +2948,10 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2948
 		  k_end
 		    {
 		    /*%%%*/
-			$$ = NEW_CLASS($2, $5, $3);
+			$$ = NEW_CLASS($2, $5, $3, &@$);
 			$$->nd_body->nd_loc = @$;
 			set_line_body($5, $<num>4);
 			nd_set_line($$, $<num>4);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch3(class, $2, $3, $5);
 		    %*/
@@ -3003,11 +2970,10 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L2970
 		  k_end
 		    {
 		    /*%%%*/
-			$$ = NEW_SCLASS($3, $6);
+			$$ = NEW_SCLASS($3, $6, &@$);
 			$$->nd_body->nd_loc = @$;
 			set_line_body($6, nd_line($3));
 			fixpos($$, $3);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(sclass, $3, $6);
 		    %*/
@@ -3035,11 +3001,10 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L3001
 		  k_end
 		    {
 		    /*%%%*/
-			$$ = NEW_MODULE($2, $4);
+			$$ = NEW_MODULE($2, $4, &@$);
 			$$->nd_body->nd_loc = @$;
 			set_line_body($4, $<num>3);
 			nd_set_line($$, $<num>3);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(module, $2, $4);
 		    %*/
@@ -3063,11 +3028,10 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L3028
 		    /*%%%*/
 			NODE *body = remove_begin($6);
 			reduce_nodes(&body);
-			$$ = NEW_DEFN($2, $5, body);
+			$$ = NEW_DEFN($2, $5, body, &@$);
 			$$->nd_defn->nd_loc = @$;
 			set_line_body(body, $<num>1);
 			nd_set_line($$, $<num>1);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch3(def, $2, $5, $6);
 		    %*/
@@ -3091,11 +3055,10 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L3055
 		    /*%%%*/
 			NODE *body = remove_begin($8);
 			reduce_nodes(&body);
-			$$ = NEW_DEFS($2, $5, $7, body);
+			$$ = NEW_DEFS($2, $5, $7, body, &@$);
 			$$->nd_defn->nd_loc = @$;
 			set_line_body(body, $<num>1);
 			nd_set_line($$, $<num>1);
-			$$->nd_loc = @$;
 		    /*%
 			$$ = dispatch5(defs, $2, $<val>3, $5, $7, $8);
 		    %*/
@@ -3106,8 +3069,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L3069
 		| keyword_break
 		    {
 		    /*%%%*/
-			$$ = NEW_BREAK(0);
-			$$->nd_loc = @$;
+			$$ = NEW_BREAK(0, &@$);
 		    /*%
 			$$ = dispatch1(break, arg_new());
 		    %*/
@@ -3115,8 +3077,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L3077
 		| keyword_next
 		    {
 		    /*%%%*/
-			$$ = NEW_NEXT(0);
-			$$->nd_loc = @$;
+			$$ = NEW_NEXT(0, &@$);
 		    /*%
 			$$ = dispatch1(next, arg_new());
 		    %*/
@@ -3124,8 +3085,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L3085
 		| keyword_redo
 		    {
 		    /*%%%*/
-			$$ = NEW_REDO();
-			$$->nd_loc = @$;
+			$$ = NEW_REDO(&@$);
 		    /*%
 			$$ = dispatch0(redo);
 		    %*/
@@ -3133,8 +3093,7 @@ primary		: literal https://github.com/ruby/ruby/blob/trunk/parse.y#L3093
 		| keyword_retry
 		    {
 		    /*%%%*/
-			$$ = NEW_RETRY();
-			$$->nd_loc = @$;
+			$$ = NEW_RETRY(&@$);
 		    /*%
 			$$ = dispatch0(retry);
 		    %*/
@@ -3146,7 +3105,7 @@ primary_value	: primary https://github.com/ruby/ruby/blob/trunk/parse.y#L3105
 		    /*%%%*/
 			value_expr($1);
 			$$ = $1;
-			if (!$$) $$ = NEW_NIL();
+			if (!$$) $$ = NEW_NIL(&@$);
 		    /*%
 			$$ = $1;
 		    %*/
@@ -3599,9 +3558,8 @@ lambda		:   { https://github.com/ruby/ruby/blob/trunk/parse.y#L3558
 			CMDARG_SET($<val>5);
 			CMDARG_LEXPOP();
 		    /*%%%*/
-			$$ = NEW_LAMBDA($3, $6);
+			$$ = NEW_LAMBDA($3, $6, &@$);
 			nd_set_line($$, $<num>4);
-			$$->nd_loc = @$;
 			$$->nd_body->nd_loc = @$;
 		    /*%
 			$$ = dispatch2(lambda, $3, $6);
@@ -3758,8 +3716,7 @@ method_call	: fcall paren_args https://github.com/ruby/ruby/blob/trunk/parse.y#L3716
 		| keyword_super paren_args
 		    {
 		    /*%%%*/
-			$$ = NEW_SUPER($2);
-			$$->nd_loc = @$;
+			$$ = NEW_SUPER($2, &@$);
 		    /*%
 			$$ = dispatch1(super, $2);
 		    %*/
@@ -3767,8 +3724,7 @@ method_call	: fcall paren_args https://github.com/ruby/ruby/blob/trunk/parse.y#L3724
 		| keyword_super
 		    {
 		    /*%%%*/
-			$$ = NEW_Z (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]