From 1ef7b0cd5a5717a1f6e18d41b85124fba312010f Mon Sep 17 00:00:00 2001 From: yui-knk Date: Mon, 13 Nov 2017 00:14:33 +0000 Subject: 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 --- node.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'node.h') diff --git a/node.h b/node.h index b778644214..a31e3b874c 100644 --- a/node.h +++ b/node.h @@ -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)<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 -- cgit v1.2.3