mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
node.c: compress logop sequence
* node.c (dump_node): compress sequence of same logical binary operators, NODE_AND/NODE_OR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
026ded9384
commit
d1b386a224
1 changed files with 9 additions and 2 deletions
11
node.c
11
node.c
|
@ -158,6 +158,7 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
|
|||
int field_flag;
|
||||
int i;
|
||||
const char *next_indent = default_indent;
|
||||
enum node_type type;
|
||||
|
||||
if (!node) {
|
||||
D_NULL_NODE;
|
||||
|
@ -166,7 +167,8 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
|
|||
|
||||
D_NODE_HEADER(node);
|
||||
|
||||
switch (nd_type(node)) {
|
||||
type = nd_type(node);
|
||||
switch (type) {
|
||||
case NODE_BLOCK:
|
||||
ANN("statement sequence");
|
||||
ANN("format: [nd_head]; ...; [nd_next]");
|
||||
|
@ -334,7 +336,12 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
|
|||
ANN("format: [nd_1st] || [nd_2nd]");
|
||||
ANN("example: foo || bar");
|
||||
andor:
|
||||
F_NODE(nd_1st, "left expr");
|
||||
while (1) {
|
||||
F_NODE(nd_1st, "left expr");
|
||||
if (!node->nd_2nd || nd_type(node->nd_2nd) != type)
|
||||
break;
|
||||
node = node->nd_2nd;
|
||||
}
|
||||
LAST_NODE;
|
||||
F_NODE(nd_2nd, "right expr");
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue