Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Functions
node.c File Reference
#include "ruby/ruby.h"
#include "vm_core.h"

Go to the source code of this file.

Data Structures

struct  add_option_arg
 

Macros

#define A(str)   rb_str_cat2(buf, (str))
 
#define AR(str)   rb_str_concat(buf, (str))
 
#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_INT(val)   rb_str_catf(buf, "%d", (val))
 
#define A_LONG(val)   rb_str_catf(buf, "%ld", (val))
 
#define A_LIT(lit)   AR(rb_inspect(lit))
 
#define A_NODE_HEADER(node, term)   rb_str_catf(buf, "@ %s (line: %d, column: %d)"term, ruby_node_name(nd_type(node)), nd_line(node), nd_column(node))
 
#define A_FIELD_HEADER(len, name, term)   rb_str_catf(buf, "+- %.*s:"term, (len), (name))
 
#define D_FIELD_HEADER(len, name, term)   (A_INDENT, A_FIELD_HEADER(len, name, term))
 
#define D_NULL_NODE   (A_INDENT, A("(null node)\n"))
 
#define D_NODE_HEADER(node)   (A_INDENT, A_NODE_HEADER(node, "\n"))
 
#define COMPOUND_FIELD(len, name, block)
 
#define COMPOUND_FIELD1(name, ann, block)
 
#define FIELD_NAME_DESC(name, ann)   name " (" ann ")"
 
#define FIELD_NAME_LEN(name, ann)
 
#define SIMPLE_FIELD(len, name)
 
#define SIMPLE_FIELD1(name, ann)   SIMPLE_FIELD(FIELD_NAME_LEN(name, ann), FIELD_NAME_DESC(name, ann))
 
#define F_CUSTOM1(name, ann)   SIMPLE_FIELD1(#name, ann)
 
#define F_ID(name, ann)   SIMPLE_FIELD1(#name, ann) A_ID(node->name)
 
#define F_GENTRY(name, ann)   SIMPLE_FIELD1(#name, ann) A_ID((node->name)->id)
 
#define F_INT(name, ann)   SIMPLE_FIELD1(#name, ann) A_INT(node->name)
 
#define F_LONG(name, ann)   SIMPLE_FIELD1(#name, ann) A_LONG(node->name)
 
#define F_LIT(name, ann)   SIMPLE_FIELD1(#name, ann) A_LIT(node->name)
 
#define F_MSG(name, ann, desc)   SIMPLE_FIELD1(#name, ann) A(desc)
 
#define F_NODE(name, ann)   COMPOUND_FIELD1(#name, ann, dump_node(buf, indent, comment, node->name))
 
#define F_OPTION(name, ann)   COMPOUND_FIELD1(#name, ann, dump_option(buf, indent, node->name))
 
#define ANN(ann)
 
#define LAST_NODE   (next_indent = " ")
 
#define nd_compile_option   u3.value
 

Functions

VALUE rb_parser_dump_tree (NODE *node, int comment)
 
void rb_gc_free_node (VALUE obj)
 
size_t rb_node_memsize (VALUE obj)
 
VALUE rb_gc_mark_node (NODE *obj)
 

Macro Definition Documentation

◆ A

#define A (   str)    rb_str_cat2(buf, (str))

Definition at line 15 of file node.c.

◆ A_FIELD_HEADER

#define A_FIELD_HEADER (   len,
  name,
  term 
)    rb_str_catf(buf, "+- %.*s:"term, (len), (name))

Definition at line 27 of file node.c.

◆ A_ID

#define A_ID (   id)    add_id(buf, (id))

Definition at line 21 of file node.c.

◆ A_INDENT

#define A_INDENT   add_indent(buf, indent)

Definition at line 18 of file node.c.

◆ A_INT

#define A_INT (   val)    rb_str_catf(buf, "%d", (val))

Definition at line 22 of file node.c.

◆ A_LIT

#define A_LIT (   lit)    AR(rb_inspect(lit))

Definition at line 24 of file node.c.

◆ A_LONG

#define A_LONG (   val)    rb_str_catf(buf, "%ld", (val))

Definition at line 23 of file node.c.

◆ A_NODE_HEADER

#define A_NODE_HEADER (   node,
  term 
)    rb_str_catf(buf, "@ %s (line: %d, column: %d)"term, ruby_node_name(nd_type(node)), nd_line(node), nd_column(node))

Definition at line 25 of file node.c.

◆ ANN

#define ANN (   ann)
Value:
if (comment) { \
A_INDENT; A("| # " ann "\n"); \
}
#define A(str)
Definition: node.c:15

Definition at line 71 of file node.c.

◆ AR

#define AR (   str)    rb_str_concat(buf, (str))

Definition at line 16 of file node.c.

◆ COMPOUND_FIELD

#define COMPOUND_FIELD (   len,
  name,
  block 
)
Value:
do { \
D_FIELD_HEADER((len), (name), "\n"); \
D_INDENT; \
block; \
D_DEDENT; \
} while (0)
register unsigned int len
Definition: zonetab.h:51
const char * name
Definition: nkf.c:208

Definition at line 34 of file node.c.

◆ COMPOUND_FIELD1

#define COMPOUND_FIELD1 (   name,
  ann,
  block 
)
Value:
block)
#define FIELD_NAME_DESC(name, ann)
Definition: node.c:47
const char * name
Definition: nkf.c:208
#define COMPOUND_FIELD(len, name, block)
Definition: node.c:34
#define FIELD_NAME_LEN(name, ann)
Definition: node.c:48

Definition at line 42 of file node.c.

◆ D_DEDENT

#define D_DEDENT   rb_str_resize(indent, RSTRING_LEN(indent) - 4)

Definition at line 20 of file node.c.

◆ D_FIELD_HEADER

#define D_FIELD_HEADER (   len,
  name,
  term 
)    (A_INDENT, A_FIELD_HEADER(len, name, term))

Definition at line 29 of file node.c.

◆ D_INDENT

#define D_INDENT   rb_str_cat2(indent, next_indent)

Definition at line 19 of file node.c.

◆ D_NODE_HEADER

#define D_NODE_HEADER (   node)    (A_INDENT, A_NODE_HEADER(node, "\n"))

Definition at line 32 of file node.c.

◆ D_NULL_NODE

#define D_NULL_NODE   (A_INDENT, A("(null node)\n"))

Definition at line 31 of file node.c.

◆ F_CUSTOM1

#define F_CUSTOM1 (   name,
  ann 
)    SIMPLE_FIELD1(#name, ann)

Definition at line 58 of file node.c.

◆ F_GENTRY

#define F_GENTRY (   name,
  ann 
)    SIMPLE_FIELD1(#name, ann) A_ID((node->name)->id)

Definition at line 60 of file node.c.

◆ F_ID

#define F_ID (   name,
  ann 
)    SIMPLE_FIELD1(#name, ann) A_ID(node->name)

Definition at line 59 of file node.c.

◆ F_INT

#define F_INT (   name,
  ann 
)    SIMPLE_FIELD1(#name, ann) A_INT(node->name)

Definition at line 61 of file node.c.

◆ F_LIT

#define F_LIT (   name,
  ann 
)    SIMPLE_FIELD1(#name, ann) A_LIT(node->name)

Definition at line 63 of file node.c.

◆ F_LONG

#define F_LONG (   name,
  ann 
)    SIMPLE_FIELD1(#name, ann) A_LONG(node->name)

Definition at line 62 of file node.c.

◆ F_MSG

#define F_MSG (   name,
  ann,
  desc 
)    SIMPLE_FIELD1(#name, ann) A(desc)

Definition at line 64 of file node.c.

◆ F_NODE

#define F_NODE (   name,
  ann 
)    COMPOUND_FIELD1(#name, ann, dump_node(buf, indent, comment, node->name))

Definition at line 66 of file node.c.

◆ F_OPTION

#define F_OPTION (   name,
  ann 
)    COMPOUND_FIELD1(#name, ann, dump_option(buf, indent, node->name))

Definition at line 68 of file node.c.

◆ FIELD_NAME_DESC

#define FIELD_NAME_DESC (   name,
  ann 
)    name " (" ann ")"

Definition at line 47 of file node.c.

◆ FIELD_NAME_LEN

#define FIELD_NAME_LEN (   name,
  ann 
)
Value:
(int)( \
comment ? \
rb_strlen_lit(name))
#define FIELD_NAME_DESC(name, ann)
Definition: node.c:47
#define rb_strlen_lit(str)
Definition: intern.h:845
const char * name
Definition: nkf.c:208

Definition at line 48 of file node.c.

◆ LAST_NODE

#define LAST_NODE   (next_indent = " ")

Definition at line 76 of file node.c.

◆ nd_compile_option

#define nd_compile_option   u3.value

◆ SIMPLE_FIELD

#define SIMPLE_FIELD (   len,
  name 
)
Value:
for (D_FIELD_HEADER((len), (name), " "), field_flag = 1; \
field_flag; /* should be optimized away */ \
A("\n"), field_flag = 0)
#define D_FIELD_HEADER(len, name, term)
Definition: node.c:29
register unsigned int len
Definition: zonetab.h:51
const char * name
Definition: nkf.c:208

Definition at line 52 of file node.c.

◆ SIMPLE_FIELD1

#define SIMPLE_FIELD1 (   name,
  ann 
)    SIMPLE_FIELD(FIELD_NAME_LEN(name, ann), FIELD_NAME_DESC(name, ann))

Definition at line 57 of file node.c.

Function Documentation

◆ rb_gc_free_node()

void rb_gc_free_node ( VALUE  obj)

Definition at line 1062 of file node.c.

References nd_ainfo, nd_tbl, nd_type, NODE_ARGS, NODE_SCOPE, RNODE, and xfree().

◆ rb_gc_mark_node()

VALUE rb_gc_mark_node ( NODE obj)

◆ rb_node_memsize()

size_t rb_node_memsize ( VALUE  obj)

Definition at line 1079 of file node.c.

References nd_tbl, nd_type, NODE_ARGS, NODE_SCOPE, RNODE, and size.

◆ rb_parser_dump_tree()

VALUE rb_parser_dump_tree ( NODE node,
int  comment 
)

Definition at line 1049 of file node.c.

References add_option_arg::buf, and rb_str_new_cstr().