diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-08 01:18:56 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-02-08 01:18:56 +0000 |
commit | 82bc167a969840729b214aa6af744d8dd03c93ec (patch) | |
tree | c4ff84db80370547a449ef77a6424e1544f8ed0e /node.c | |
parent | cb09ff25570bba16b553a19d078acc8b96d0de7c (diff) | |
download | ruby-82bc167a969840729b214aa6af744d8dd03c93ec.tar.gz |
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
Diffstat (limited to 'node.c')
-rw-r--r-- | node.c | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -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; |