ruby-changes:48279
From: nobu <ko1@a...>
Date: Tue, 24 Oct 2017 17:00:46 +0900 (JST)
Subject: [ruby-changes:48279] nobu:r60394 (trunk): Removed NODE_OPT_N
nobu 2017-10-24 17:00:36 +0900 (Tue, 24 Oct 2017) New Revision: 60394 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60394 Log: Removed NODE_OPT_N * node.h (NODE_OPT_N): removed. * parse.y (parser_append_options): expand -n option loop to while gets loop. Modified files: trunk/compile.c trunk/ext/objspace/objspace.c trunk/node.c trunk/node.h trunk/parse.y Index: compile.c =================================================================== --- compile.c (revision 60393) +++ compile.c (revision 60394) @@ -4517,7 +4517,7 @@ compile_loop(rb_iseq_t *iseq, LINK_ANCHO https://github.com/ruby/ruby/blob/trunk/compile.c#L4517 ISEQ_COMPILE_DATA(iseq)->loopval_popped = 0; push_ensure_entry(iseq, &enl, NULL, NULL); - if (type == NODE_OPT_N || node->nd_state == 1) { + if (node->nd_state == 1) { ADD_INSNL(ret, line, jump, next_label); } else { @@ -4541,17 +4541,11 @@ compile_loop(rb_iseq_t *iseq, LINK_ANCHO https://github.com/ruby/ruby/blob/trunk/compile.c#L4541 compile_branch_condition(iseq, ret, node->nd_cond, redo_label, end_label); } - else if (type == NODE_UNTIL) { + else { /* until */ compile_branch_condition(iseq, ret, node->nd_cond, end_label, redo_label); } - else { - ADD_CALL_RECEIVER(ret, line); - ADD_CALL(ret, line, idGets, INT2FIX(0)); - ADD_INSNL(ret, line, branchif, redo_label); - /* opt_n */ - } ADD_LABEL(ret, end_label); ADD_ADJUST_RESTORE(ret, adjust_label); @@ -5103,7 +5097,6 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L5097 case NODE_WHEN: CHECK(compile_when(iseq, ret, node, popped)); break; - case NODE_OPT_N: case NODE_WHILE: case NODE_UNTIL: CHECK(compile_loop(iseq, ret, node, popped, type)); Index: node.c =================================================================== --- node.c (revision 60393) +++ node.c (revision 60394) @@ -230,11 +230,6 @@ dump_node(VALUE buf, VALUE indent, int c https://github.com/ruby/ruby/blob/trunk/node.c#L230 F_NODE(nd_next, "next when clause"); return; - case NODE_OPT_N: - ANN("wrapper for -n option"); - ANN("format: ruby -ne '[nd_body]' (nd_cond is `gets')"); - ANN("example: ruby -ne 'p $_'"); - goto loop; case NODE_WHILE: ANN("while statement"); ANN("format: while [nd_cond]; [nd_body]; end"); @@ -1152,7 +1147,6 @@ rb_gc_mark_node(NODE *obj) https://github.com/ruby/ruby/blob/trunk/node.c#L1147 case NODE_IASGN: case NODE_CVASGN: case NODE_COLON3: - case NODE_OPT_N: case NODE_EVSTR: case NODE_UNDEF: case NODE_POSTEXE: Index: node.h =================================================================== --- node.h (revision 60393) +++ node.h (revision 60394) @@ -32,8 +32,6 @@ enum node_type { https://github.com/ruby/ruby/blob/trunk/node.h#L32 #define NODE_CASE NODE_CASE NODE_WHEN, #define NODE_WHEN NODE_WHEN - NODE_OPT_N, -#define NODE_OPT_N NODE_OPT_N NODE_WHILE, #define NODE_WHILE NODE_WHILE NODE_UNTIL, @@ -353,7 +351,6 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/node.h#L351 #define NEW_UNLESS(c,t,e) NEW_NODE(NODE_UNLESS,c,t,e) #define NEW_CASE(h,b) NEW_NODE(NODE_CASE,h,b,0) #define NEW_WHEN(c,t,e) NEW_NODE(NODE_WHEN,c,t,e) -#define NEW_OPT_N(b) NEW_NODE(NODE_OPT_N,0,b,0) #define NEW_WHILE(c,b,n) NEW_NODE(NODE_WHILE,c,b,n) #define NEW_UNTIL(c,b,n) NEW_NODE(NODE_UNTIL,c,b,n) #define NEW_FOR(v,i,b) NEW_NODE(NODE_FOR,v,b,i) Index: parse.y =================================================================== --- parse.y (revision 60393) +++ parse.y (revision 60394) @@ -11278,7 +11278,7 @@ parser_append_options(struct parser_para https://github.com/ruby/ruby/blob/trunk/parse.y#L11278 rb_intern("chomp!"), 0, 0), node, 0); } - node = NEW_OPT_N(node); + node = NEW_WHILE(NEW_VCALL(idGets), node, 1); } return node; Index: ext/objspace/objspace.c =================================================================== --- ext/objspace/objspace.c (revision 60393) +++ ext/objspace/objspace.c (revision 60394) @@ -377,7 +377,6 @@ count_nodes(int argc, VALUE *argv, VALUE https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace.c#L377 COUNT_NODE(NODE_UNLESS); COUNT_NODE(NODE_CASE); COUNT_NODE(NODE_WHEN); - COUNT_NODE(NODE_OPT_N); COUNT_NODE(NODE_WHILE); COUNT_NODE(NODE_UNTIL); COUNT_NODE(NODE_ITER); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/