summaryrefslogtreecommitdiff
path: root/node.h
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-04 15:22:18 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-11-04 15:22:18 +0000
commit0ee24acb5a9f3007f3b62f04c69427f61d57e04e (patch)
treec13881daa5fb035ca86261114564ee7b236b8107 /node.h
parent9533da6f1f306491858ba12fc630171e6ad97ae7 (diff)
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`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'node.h')
-rw-r--r--node.h17
1 files changed, 10 insertions, 7 deletions
diff --git a/node.h b/node.h
index d85f86746a..59d6d7f204 100644
--- a/node.h
+++ b/node.h
@@ -222,9 +222,13 @@ enum node_type {
#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 {
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 {
#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