mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Store lineno on RNode
* node.c (A_NODE_HEADER): Print lineno. * node.h (nd_column, nd_set_column): Store column number with 16-bit. * node.h (nd_lineno, nd_set_lineno): Define getter/setter macros for lineno of RNode. * parse.y : Set first lineno of tokens. Thanks to takeshinoda for review. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b6946d31fc
commit
7a42b03b0c
3 changed files with 747 additions and 583 deletions
2
node.c
2
node.c
|
@ -23,7 +23,7 @@
|
|||
#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))
|
||||
rb_str_catf(buf, "@ %s (line: %d. lineno: %d, column: %d)"term, ruby_node_name(nd_type(node)), nd_line(node), nd_lineno(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))
|
||||
|
|
9
node.h
9
node.h
|
@ -268,8 +268,13 @@ typedef struct RNode {
|
|||
#define nd_line(n) (int)(((SIGNED_VALUE)RNODE(n)->flags)>>NODE_LSHIFT)
|
||||
#define nd_set_line(n,l) \
|
||||
RNODE(n)->flags=((RNODE(n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT))
|
||||
#define nd_column(n) (int)(RNODE(n)->nd_reserved)
|
||||
#define nd_set_column(n, v) (RNODE(n)->nd_reserved=v)
|
||||
#define nd_column(n) (int)(RNODE(n)->nd_reserved & 0xffff)
|
||||
#define nd_set_column(n, v) \
|
||||
RNODE(n)->nd_reserved = (RNODE(n)->nd_reserved & ~0xffff) | ((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff)
|
||||
|
||||
#define nd_lineno(n) (int)((RNODE(n)->nd_reserved >> 16) & 0xffff)
|
||||
#define nd_set_lineno(n, v) \
|
||||
RNODE(n)->nd_reserved = (RNODE(n)->nd_reserved & ~0xffff0000) | (((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff) << 16)
|
||||
|
||||
#define nd_head u1.node
|
||||
#define nd_alen u2.argc
|
||||
|
|
Loading…
Reference in a new issue