diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-24 08:00:36 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-10-24 08:00:36 +0000 |
commit | 2c786bf35d62aa084bcb3915b0a10f2d4840459f (patch) | |
tree | 784c12f649b1e56aba2f399210414fd74ef894f1 | |
parent | 30f5c55890bc9f1db68b7b709ed04b5b10ec9946 (diff) |
Removed NODE_OPT_N
* node.h (NODE_OPT_N): removed.
* parse.y (parser_append_options): expand -n option loop to while
gets loop.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | compile.c | 11 | ||||
-rw-r--r-- | ext/objspace/objspace.c | 1 | ||||
-rw-r--r-- | node.c | 6 | ||||
-rw-r--r-- | node.h | 3 | ||||
-rw-r--r-- | parse.y | 2 |
5 files changed, 3 insertions, 20 deletions
@@ -4517,7 +4517,7 @@ compile_loop(rb_iseq_t *iseq, LINK_ANCHOR *const ret, NODE *node, int popped, co 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_ANCHOR *const ret, NODE *node, int popped, co 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_ANCHOR *const ret, NODE *node, int popp 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)); diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index c724e749fa..38995d4af6 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -377,7 +377,6 @@ count_nodes(int argc, VALUE *argv, VALUE os) 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); @@ -230,11 +230,6 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node) 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) case NODE_IASGN: case NODE_CVASGN: case NODE_COLON3: - case NODE_OPT_N: case NODE_EVSTR: case NODE_UNDEF: case NODE_POSTEXE: @@ -32,8 +32,6 @@ enum node_type { #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 { #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) @@ -11278,7 +11278,7 @@ parser_append_options(struct parser_params *parser, NODE *node) rb_intern("chomp!"), 0, 0), node, 0); } - node = NEW_OPT_N(node); + node = NEW_WHILE(NEW_VCALL(idGets), node, 1); } return node; |