B
B. K. Oxley (binkley)
I'm interested in adding more precise source location information to
NODE structs. I see:
typedef struct RNode {
/* ... */
char *nd_file;
int nd_line;
/* ... */
} NODE;
But the accessor macros for nd_line look like this (spaces added for
email clarity):
#define nd_line(n) ((unsigned int) (((RNODE(n))->flags >> NODE_LSHIFT) &
NODE_LMASK))
#define nd_set_line(n,l) \
RNODE(n)->flags=((RNODE(n)->flags & ~(-1 << NODE_LSHIFT)) | (((l) &
NODE_LMASK) << NODE_LSHIFT))
What is going on?
What I'd like to do is add an int nd_pos member to RNode to record the
precise byte position in nd_file for the node, but I'm somewhat baffled
by the utter lack of ".nd_line" or "->nd_line" in the sources. Looking
at parse.y, frequently assign the nd_line(node) macro to
ruby_sourceline, but I do not grasp how that macro uses nd_line.
Thanks,
--binkley
NODE structs. I see:
typedef struct RNode {
/* ... */
char *nd_file;
int nd_line;
/* ... */
} NODE;
But the accessor macros for nd_line look like this (spaces added for
email clarity):
#define nd_line(n) ((unsigned int) (((RNODE(n))->flags >> NODE_LSHIFT) &
NODE_LMASK))
#define nd_set_line(n,l) \
RNODE(n)->flags=((RNODE(n)->flags & ~(-1 << NODE_LSHIFT)) | (((l) &
NODE_LMASK) << NODE_LSHIFT))
What is going on?
What I'd like to do is add an int nd_pos member to RNode to record the
precise byte position in nd_file for the node, but I'm somewhat baffled
by the utter lack of ".nd_line" or "->nd_line" in the sources. Looking
at parse.y, frequently assign the nd_line(node) macro to
ruby_sourceline, but I do not grasp how that macro uses nd_line.
Thanks,
--binkley