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

parse.y: simplified

* parse.y (primary): turned nested if-else blocks into a switch
  statement.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50399 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2015-04-29 03:49:05 +00:00
parent 810522e0ff
commit 9efec44c07

30
parse.y
View file

@ -2908,23 +2908,23 @@ primary : literal
NODE *m = NEW_ARGS_AUX(0, 0);
NODE *args, *scope;
if (nd_type($2) == NODE_MASGN) {
switch (nd_type($2)) {
case NODE_MASGN:
m->nd_next = node_assign($2, NEW_FOR(NEW_DVAR(id), 0, 0));
args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0));
}
else {
if (nd_type($2) == NODE_LASGN ||
nd_type($2) == NODE_DASGN ||
nd_type($2) == NODE_DASGN_CURR) {
$2->nd_value = NEW_DVAR(id);
m->nd_plen = 1;
m->nd_next = $2;
args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0));
}
else {
m->nd_next = node_assign(NEW_MASGN(NEW_LIST($2), 0), NEW_DVAR(id));
args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0));
}
break;
case NODE_LASGN:
case NODE_DASGN:
case NODE_DASGN_CURR:
$2->nd_value = NEW_DVAR(id);
m->nd_plen = 1;
m->nd_next = $2;
args = new_args(m, 0, 0, 0, new_args_tail(0, 0, 0));
break;
default:
m->nd_next = node_assign(NEW_MASGN(NEW_LIST($2), 0), NEW_DVAR(id));
args = new_args(m, 0, id, 0, new_args_tail(0, 0, 0));
break;
}
scope = NEW_NODE(NODE_SCOPE, tbl, $8, args);
tbl[0] = 1; tbl[1] = id;