diff options
author | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-13 00:14:33 +0000 |
---|---|---|
committer | yui-knk <yui-knk@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-11-13 00:14:33 +0000 |
commit | 1ef7b0cd5a5717a1f6e18d41b85124fba312010f (patch) | |
tree | 273d5fc2c2fd83b96875021359b7afff214a97a5 /node.h | |
parent | a82aaea71902bd18b87179698d88ca4f9fa0359b (diff) |
Store last location of a node on RNode
* node.c (rb_node_init): Initialize last location with 0.
* node.h (struct rb_code_range_struct): Define a structure
which contains first location and last location of a node.
* node.h (struct RNode): Use rb_code_range_t to store last
location of a node.
* node.h (nd_column, nd_set_column, nd_lineno, nd_set_lineno):
Follow-up the change of struct RNode.
* node.h (nd_last_column, nd_set_last_column, nd_last_lineno, nd_set_last_lineno):
Define getter/setter macros for last location of RNode.
* parse.y : Set last location of tokens.
Thanks to Yusuke Endoh (mame) for design of data structures.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'node.h')
-rw-r--r-- | node.h | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -227,6 +227,11 @@ typedef struct rb_code_location_struct { int column; } rb_code_location_t; +typedef struct rb_code_range_struct { + rb_code_location_t first_loc; + rb_code_location_t last_loc; +} rb_code_range_t; + typedef struct RNode { VALUE flags; union { @@ -251,7 +256,7 @@ typedef struct RNode { long cnt; VALUE value; } u3; - rb_code_location_t nd_first_loc; + rb_code_range_t nd_loc; } NODE; #define RNODE(obj) (R_CAST(RNode)(obj)) @@ -276,10 +281,15 @@ typedef struct RNode { #define nd_set_line(n,l) \ (n)->flags=(((n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT)) -#define nd_column(n) ((int)((n)->nd_first_loc.column)) -#define nd_set_column(n, v) ((n)->nd_first_loc.column = (v)) -#define nd_lineno(n) ((int)((n)->nd_first_loc.lineno)) -#define nd_set_lineno(n, v) ((n)->nd_first_loc.lineno = (v)) +#define nd_column(n) ((int)((n)->nd_loc.first_loc.column)) +#define nd_set_column(n, v) ((n)->nd_loc.first_loc.column = (v)) +#define nd_lineno(n) ((int)((n)->nd_loc.first_loc.lineno)) +#define nd_set_lineno(n, v) ((n)->nd_loc.first_loc.lineno = (v)) + +#define nd_last_column(n) ((int)((n)->nd_loc.last_loc.column)) +#define nd_set_last_column(n, v) ((n)->nd_loc.last_loc.column = (v)) +#define nd_last_lineno(n) ((int)((n)->nd_loc.last_loc.lineno)) +#define nd_set_last_lineno(n, v) ((n)->nd_loc.last_loc.lineno = (v)) #define nd_head u1.node #define nd_alen u2.argc |