1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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
This commit is contained in:
nobu 2017-10-24 08:00:36 +00:00
parent 30f5c55890
commit 2c786bf35d
5 changed files with 3 additions and 20 deletions

View file

@ -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));

View file

@ -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);

6
node.c
View file

@ -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:

3
node.h
View file

@ -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)

View file

@ -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;