node.c: flatten NODE_BLOCK [ci skip]
* node.c (dump_node): flatten statements in NODE_BLOCK. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56348 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
82dd08285f
commit
e3e17eb975
@ -1,3 +1,7 @@
|
|||||||
|
Wed Oct 5 15:43:32 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* node.c (dump_node): flatten statements in NODE_BLOCK.
|
||||||
|
|
||||||
Wed Oct 5 14:27:36 2016 Byron Bowerman <me@bm5k.com>
|
Wed Oct 5 14:27:36 2016 Byron Bowerman <me@bm5k.com>
|
||||||
|
|
||||||
* range.c: Add docs for max/min behavior with exclusive range.
|
* range.c: Add docs for max/min behavior with exclusive range.
|
||||||
|
23
node.c
23
node.c
@ -16,6 +16,8 @@
|
|||||||
#define AR(str) rb_str_concat(buf, (str))
|
#define AR(str) rb_str_concat(buf, (str))
|
||||||
|
|
||||||
#define A_INDENT add_indent(buf, indent)
|
#define A_INDENT add_indent(buf, indent)
|
||||||
|
#define D_INDENT rb_str_cat2(indent, next_indent)
|
||||||
|
#define D_DEDENT rb_str_resize(indent, RSTRING_LEN(indent) - 4)
|
||||||
#define A_ID(id) add_id(buf, (id))
|
#define A_ID(id) add_id(buf, (id))
|
||||||
#define A_INT(val) rb_str_catf(buf, "%d", (val))
|
#define A_INT(val) rb_str_catf(buf, "%d", (val))
|
||||||
#define A_LONG(val) rb_str_catf(buf, "%ld", (val))
|
#define A_LONG(val) rb_str_catf(buf, "%ld", (val))
|
||||||
@ -32,9 +34,9 @@
|
|||||||
#define COMPOUND_FIELD(len, name, block) \
|
#define COMPOUND_FIELD(len, name, block) \
|
||||||
do { \
|
do { \
|
||||||
D_FIELD_HEADER((len), (name), "\n"); \
|
D_FIELD_HEADER((len), (name), "\n"); \
|
||||||
rb_str_cat2(indent, next_indent); \
|
D_INDENT; \
|
||||||
block; \
|
block; \
|
||||||
rb_str_resize(indent, RSTRING_LEN(indent) - 4); \
|
D_DEDENT; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define COMPOUND_FIELD1(name, ann, block) \
|
#define COMPOUND_FIELD1(name, ann, block) \
|
||||||
@ -154,6 +156,7 @@ static void
|
|||||||
dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
|
dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
|
||||||
{
|
{
|
||||||
int field_flag;
|
int field_flag;
|
||||||
|
int i;
|
||||||
const char *next_indent = default_indent;
|
const char *next_indent = default_indent;
|
||||||
|
|
||||||
if (!node) {
|
if (!node) {
|
||||||
@ -166,9 +169,21 @@ dump_node(VALUE buf, VALUE indent, int comment, NODE *node)
|
|||||||
switch (nd_type(node)) {
|
switch (nd_type(node)) {
|
||||||
case NODE_BLOCK:
|
case NODE_BLOCK:
|
||||||
ANN("statement sequence");
|
ANN("statement sequence");
|
||||||
ANN("format: [nd_head]; [nd_next]");
|
ANN("format: [nd_head]; ...; [nd_next]");
|
||||||
ANN("example: foo; bar");
|
ANN("example: foo; bar");
|
||||||
F_NODE(nd_head, "current statement");
|
i = 0;
|
||||||
|
do {
|
||||||
|
A_INDENT;
|
||||||
|
rb_str_catf(buf, "+- nd_head (%s%d):\n",
|
||||||
|
comment ? "statement #" : "", ++i);
|
||||||
|
if (!node->nd_next) LAST_NODE;
|
||||||
|
D_INDENT;
|
||||||
|
dump_node(buf, indent, comment, node->nd_head);
|
||||||
|
D_DEDENT;
|
||||||
|
} while (node->nd_next &&
|
||||||
|
nd_type(node->nd_next) == NODE_BLOCK &&
|
||||||
|
(node = node->nd_next, 1));
|
||||||
|
if (!node->nd_next) break;
|
||||||
LAST_NODE;
|
LAST_NODE;
|
||||||
F_NODE(nd_next, "next block");
|
F_NODE(nd_next, "next block");
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user