ruby-changes:48537
From: mame <ko1@a...>
Date: Sun, 5 Nov 2017 00:22:22 +0900 (JST)
Subject: [ruby-changes:48537] mame:r60652 (trunk): Introduce `rb_code_location_t`
mame 2017-11-05 00:22:18 +0900 (Sun, 05 Nov 2017) New Revision: 60652 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60652 Log: Introduce `rb_code_location_t` `rb_code_location_t` has two integers, lineno and column, which point to one location on a code. Now `rb_code_location_t` is used instead of `VALUE nd_location`. Modified files: trunk/node.c trunk/node.h Index: node.c =================================================================== --- node.c (revision 60651) +++ node.c (revision 60652) @@ -1058,11 +1058,12 @@ void https://github.com/ruby/ruby/blob/trunk/node.c#L1058 rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2) { n->flags = T_NODE; - n->nd_location = 0; + nd_set_type(n, type); n->u1.value = a0; n->u2.value = a1; n->u3.value = a2; - nd_set_type(n, type); + n->nd_first_loc.lineno = 0; + n->nd_first_loc.column = 0; } typedef struct node_buffer_elem_struct { Index: node.h =================================================================== --- node.h (revision 60651) +++ node.h (revision 60652) @@ -222,9 +222,13 @@ enum node_type { https://github.com/ruby/ruby/blob/trunk/node.h#L222 #define NODE_LAST NODE_LAST }; +typedef struct rb_code_location_struct { + int lineno; + int column; +} rb_code_location_t; + typedef struct RNode { VALUE flags; - VALUE nd_location; /* lineno and column */ union { struct RNode *node; ID id; @@ -247,6 +251,7 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/node.h#L251 long cnt; VALUE value; } u3; + rb_code_location_t nd_first_loc; } NODE; #define RNODE(obj) (R_CAST(RNode)(obj)) @@ -270,13 +275,11 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/node.h#L275 #define nd_line(n) (int)(((SIGNED_VALUE)(n)->flags)>>NODE_LSHIFT) #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_location & 0xffff) -#define nd_set_column(n, v) \ - (n)->nd_location = ((n)->nd_location & ~0xffff) | ((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff) - -#define nd_lineno(n) (int)(((n)->nd_location >> 16) & 0xffff) -#define nd_set_lineno(n, v) \ - (n)->nd_location = ((n)->nd_location & ~0xffff0000) | (((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff) << 16) + +#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_head u1.node #define nd_alen u2.argc -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/