1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Rename code_range to code_location

Because the name "code_range" is ambiguous with encoding's.
Abbreviations ("crange", and "cr") are also renamed to "loc".

The traditional "code_location" (a pair of lineno and column) is
renamed to "code_position".  Abbreviations are also renamed
(first_loc to beg_pos, and last_loc to end_pos).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mame 2018-01-09 08:45:35 +00:00
parent 043e1fd559
commit 4928900814
8 changed files with 522 additions and 522 deletions

View file

@ -657,7 +657,7 @@ rb_iseq_compile_node(rb_iseq_t *iseq, const NODE *node)
CHECK(COMPILE(ret, "block body", node->nd_body));
ADD_LABEL(ret, end);
ADD_TRACE(ret, RUBY_EVENT_B_RETURN);
ISEQ_COMPILE_DATA(iseq)->last_line = iseq->body->location.code_range.last_loc.lineno;
ISEQ_COMPILE_DATA(iseq)->last_line = iseq->body->location.code_location.end_pos.lineno;
/* wide range catch handler must put at last */
ADD_CATCH_ENTRY(CATCH_TYPE_REDO, start, end, NULL, start);
@ -8692,7 +8692,7 @@ ibf_load_iseq_each(const struct ibf_load *load, rb_iseq_t *iseq, ibf_offset_t of
RB_OBJ_WRITE(iseq, &load_body->location.base_label, ibf_load_location_str(load, body->location.base_label));
RB_OBJ_WRITE(iseq, &load_body->location.label, ibf_load_location_str(load, body->location.label));
load_body->location.first_lineno = body->location.first_lineno;
load_body->location.code_range = body->location.code_range;
load_body->location.code_location = body->location.code_location;
load_body->is_entries = ZALLOC_N(union iseq_inline_storage_entry, body->is_size);
load_body->ci_entries = ibf_load_ci_entries(load, body);

66
iseq.c
View file

@ -242,7 +242,7 @@ rb_iseq_pathobj_set(const rb_iseq_t *iseq, VALUE path, VALUE realpath)
}
static rb_iseq_location_t *
iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_range_t *code_range)
iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_location_t *code_location)
{
rb_iseq_location_t *loc = &iseq->body->location;
@ -250,14 +250,14 @@ iseq_location_setup(rb_iseq_t *iseq, VALUE name, VALUE path, VALUE realpath, VAL
RB_OBJ_WRITE(iseq, &loc->label, name);
RB_OBJ_WRITE(iseq, &loc->base_label, name);
loc->first_lineno = first_lineno;
if (code_range) {
loc->code_range = *code_range;
if (code_location) {
loc->code_location = *code_location;
}
else {
loc->code_range.first_loc.lineno = 0;
loc->code_range.first_loc.column = 0;
loc->code_range.last_loc.lineno = -1;
loc->code_range.last_loc.column = -1;
loc->code_location.beg_pos.lineno = 0;
loc->code_location.beg_pos.column = 0;
loc->code_location.end_pos.lineno = -1;
loc->code_location.end_pos.column = -1;
}
return loc;
@ -297,7 +297,7 @@ rb_iseq_add_mark_object(const rb_iseq_t *iseq, VALUE obj)
static VALUE
prepare_iseq_build(rb_iseq_t *iseq,
VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_range_t *code_range,
VALUE name, VALUE path, VALUE realpath, VALUE first_lineno, const rb_code_location_t *code_location,
const rb_iseq_t *parent, enum iseq_type type,
const rb_compile_option_t *option)
{
@ -311,7 +311,7 @@ prepare_iseq_build(rb_iseq_t *iseq,
set_relation(iseq, parent);
name = rb_fstring(name);
iseq_location_setup(iseq, name, path, realpath, first_lineno, code_range);
iseq_location_setup(iseq, name, path, realpath, first_lineno, code_location);
if (iseq != iseq->body->local_iseq) {
RB_OBJ_WRITE(iseq, &iseq->body->location.base_label, iseq->body->local_iseq->body->location.label);
}
@ -525,7 +525,7 @@ rb_iseq_new_with_opt(const rb_ast_body_t *ast, VALUE name, VALUE path, VALUE rea
new_opt = option ? *option : COMPILE_OPTION_DEFAULT;
if (ast && ast->compile_option) rb_iseq_make_compile_option(&new_opt, ast->compile_option);
prepare_iseq_build(iseq, name, path, realpath, first_lineno, node ? &node->nd_crange : NULL, parent, type, &new_opt);
prepare_iseq_build(iseq, name, path, realpath, first_lineno, node ? &node->nd_loc : NULL, parent, type, &new_opt);
rb_iseq_compile_node(iseq, node);
finish_iseq_build(iseq);
@ -601,13 +601,13 @@ iseq_load(VALUE data, const rb_iseq_t *parent, VALUE opt)
rb_iseq_t *iseq = iseq_alloc();
VALUE magic, version1, version2, format_type, misc;
VALUE name, path, realpath, first_lineno, code_range;
VALUE name, path, realpath, first_lineno, code_location;
VALUE type, body, locals, params, exception;
st_data_t iseq_type;
rb_compile_option_t option;
int i = 0;
rb_code_range_t tmp_loc = { {0, 0}, {-1, -1} };
rb_code_location_t tmp_loc = { {0, 0}, {-1, -1} };
/* [magic, major_version, minor_version, format_type, misc,
* label, path, first_lineno,
@ -642,12 +642,12 @@ iseq_load(VALUE data, const rb_iseq_t *parent, VALUE opt)
rb_raise(rb_eTypeError, "unsupport type: :%"PRIsVALUE, rb_sym2str(type));
}
code_range = rb_hash_aref(misc, ID2SYM(rb_intern("code_range")));
if (RB_TYPE_P(code_range, T_ARRAY) && RARRAY_LEN(code_range) == 4) {
tmp_loc.first_loc.lineno = NUM2INT(rb_ary_entry(code_range, 0));
tmp_loc.first_loc.column = NUM2INT(rb_ary_entry(code_range, 1));
tmp_loc.last_loc.lineno = NUM2INT(rb_ary_entry(code_range, 2));
tmp_loc.last_loc.column = NUM2INT(rb_ary_entry(code_range, 3));
code_location = rb_hash_aref(misc, ID2SYM(rb_intern("code_location")));
if (RB_TYPE_P(code_location, T_ARRAY) && RARRAY_LEN(code_location) == 4) {
tmp_loc.beg_pos.lineno = NUM2INT(rb_ary_entry(code_location, 0));
tmp_loc.beg_pos.column = NUM2INT(rb_ary_entry(code_location, 1));
tmp_loc.end_pos.lineno = NUM2INT(rb_ary_entry(code_location, 2));
tmp_loc.end_pos.column = NUM2INT(rb_ary_entry(code_location, 3));
}
make_compile_option(&option, opt);
@ -792,12 +792,12 @@ rb_iseq_method_name(const rb_iseq_t *iseq)
}
void
rb_iseq_code_range(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column)
rb_iseq_code_location(const rb_iseq_t *iseq, int *beg_pos_lineno, int *beg_pos_column, int *end_pos_lineno, int *end_pos_column)
{
if (first_lineno) *first_lineno = iseq->body->location.code_range.first_loc.lineno;
if (first_column) *first_column = iseq->body->location.code_range.first_loc.column;
if (last_lineno) *last_lineno = iseq->body->location.code_range.last_loc.lineno;
if (last_column) *last_column = iseq->body->location.code_range.last_loc.column;
if (beg_pos_lineno) *beg_pos_lineno = iseq->body->location.code_location.beg_pos.lineno;
if (beg_pos_column) *beg_pos_column = iseq->body->location.code_location.beg_pos.column;
if (end_pos_lineno) *end_pos_lineno = iseq->body->location.code_location.end_pos.lineno;
if (end_pos_column) *end_pos_column = iseq->body->location.code_location.end_pos.column;
}
VALUE
@ -1702,11 +1702,11 @@ iseq_inspect(const rb_iseq_t *iseq)
else {
return rb_sprintf("#<ISeq:%s@%s:%d (%d,%d)-(%d,%d)>",
RSTRING_PTR(iseq->body->location.label), RSTRING_PTR(rb_iseq_path(iseq)),
iseq->body->location.code_range.first_loc.lineno,
iseq->body->location.code_range.first_loc.lineno,
iseq->body->location.code_range.first_loc.column,
iseq->body->location.code_range.last_loc.lineno,
iseq->body->location.code_range.last_loc.column);
iseq->body->location.code_location.beg_pos.lineno,
iseq->body->location.code_location.beg_pos.lineno,
iseq->body->location.code_location.beg_pos.column,
iseq->body->location.code_location.end_pos.lineno,
iseq->body->location.code_location.end_pos.column);
}
}
@ -2419,12 +2419,12 @@ iseq_data_to_ary(const rb_iseq_t *iseq)
rb_hash_aset(misc, ID2SYM(rb_intern("arg_size")), INT2FIX(iseq->body->param.size));
rb_hash_aset(misc, ID2SYM(rb_intern("local_size")), INT2FIX(iseq->body->local_table_size));
rb_hash_aset(misc, ID2SYM(rb_intern("stack_max")), INT2FIX(iseq->body->stack_max));
rb_hash_aset(misc, ID2SYM(rb_intern("code_range")),
rb_hash_aset(misc, ID2SYM(rb_intern("code_location")),
rb_ary_new_from_args(4,
INT2FIX(iseq->body->location.code_range.first_loc.lineno),
INT2FIX(iseq->body->location.code_range.first_loc.column),
INT2FIX(iseq->body->location.code_range.last_loc.lineno),
INT2FIX(iseq->body->location.code_range.last_loc.column)));
INT2FIX(iseq->body->location.code_location.beg_pos.lineno),
INT2FIX(iseq->body->location.code_location.beg_pos.column),
INT2FIX(iseq->body->location.code_location.end_pos.lineno),
INT2FIX(iseq->body->location.code_location.end_pos.column)));
/*
* [:magic, :major_version, :minor_version, :format_type, :misc,

2
iseq.h
View file

@ -190,7 +190,7 @@ VALUE rb_iseq_label(const rb_iseq_t *iseq);
VALUE rb_iseq_base_label(const rb_iseq_t *iseq);
VALUE rb_iseq_first_lineno(const rb_iseq_t *iseq);
VALUE rb_iseq_method_name(const rb_iseq_t *iseq);
void rb_iseq_code_range(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
void rb_iseq_code_location(const rb_iseq_t *iseq, int *first_lineno, int *first_column, int *last_lineno, int *last_column);
/* proc.c */
const rb_iseq_t *rb_method_iseq(VALUE body);

10
node.c
View file

@ -23,7 +23,7 @@
#define A_LONG(val) rb_str_catf(buf, "%ld", (val))
#define A_LIT(lit) AR(rb_inspect(lit))
#define A_NODE_HEADER(node, term) \
rb_str_catf(buf, "@ %s (line: %d, code_range: (%d,%d)-(%d,%d))%s"term, \
rb_str_catf(buf, "@ %s (line: %d, location: (%d,%d)-(%d,%d))%s"term, \
ruby_node_name(nd_type(node)), nd_line(node), \
nd_first_lineno(node), nd_first_column(node), \
nd_last_lineno(node), nd_last_column(node), \
@ -1026,10 +1026,10 @@ rb_node_init(NODE *n, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
n->u1.value = a0;
n->u2.value = a1;
n->u3.value = a2;
n->nd_crange.first_loc.lineno = 0;
n->nd_crange.first_loc.column = 0;
n->nd_crange.last_loc.lineno = 0;
n->nd_crange.last_loc.column = 0;
n->nd_loc.beg_pos.lineno = 0;
n->nd_loc.beg_pos.column = 0;
n->nd_loc.end_pos.lineno = 0;
n->nd_loc.end_pos.column = 0;
}
typedef struct node_buffer_elem_struct {

230
node.h
View file

@ -222,22 +222,22 @@ enum node_type {
#define NODE_LAST NODE_LAST
};
typedef struct rb_code_location_struct {
typedef struct rb_code_position_struct {
int lineno;
int column;
} rb_code_position_t;
typedef struct rb_code_location_struct {
rb_code_position_t beg_pos;
rb_code_position_t end_pos;
} 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;
static inline rb_code_range_t code_range_gen(rb_code_range_t *cr1, rb_code_range_t *cr2)
static inline rb_code_location_t code_loc_gen(rb_code_location_t *loc1, rb_code_location_t *loc2)
{
rb_code_range_t cr;
cr.first_loc = cr1->first_loc;
cr.last_loc = cr2->last_loc;
return cr;
rb_code_location_t loc;
loc.beg_pos = loc1->beg_pos;
loc.end_pos = loc2->end_pos;
return loc;
}
typedef struct RNode {
@ -264,7 +264,7 @@ typedef struct RNode {
long cnt;
VALUE value;
} u3;
rb_code_range_t nd_crange;
rb_code_location_t nd_loc;
} NODE;
#define RNODE(obj) (R_CAST(RNode)(obj))
@ -289,16 +289,16 @@ 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_first_column(n) ((int)((n)->nd_crange.first_loc.column))
#define nd_set_first_column(n, v) ((n)->nd_crange.first_loc.column = (v))
#define nd_first_lineno(n) ((int)((n)->nd_crange.first_loc.lineno))
#define nd_set_first_lineno(n, v) ((n)->nd_crange.first_loc.lineno = (v))
#define nd_first_column(n) ((int)((n)->nd_loc.beg_pos.column))
#define nd_set_first_column(n, v) ((n)->nd_loc.beg_pos.column = (v))
#define nd_first_lineno(n) ((int)((n)->nd_loc.beg_pos.lineno))
#define nd_set_first_lineno(n, v) ((n)->nd_loc.beg_pos.lineno = (v))
#define nd_last_column(n) ((int)((n)->nd_crange.last_loc.column))
#define nd_set_last_column(n, v) ((n)->nd_crange.last_loc.column = (v))
#define nd_last_lineno(n) ((int)((n)->nd_crange.last_loc.lineno))
#define nd_set_last_lineno(n, v) ((n)->nd_crange.last_loc.lineno = (v))
#define nd_last_loc(n) ((n)->nd_crange.last_loc)
#define nd_last_column(n) ((int)((n)->nd_loc.end_pos.column))
#define nd_set_last_column(n, v) ((n)->nd_loc.end_pos.column = (v))
#define nd_last_lineno(n) ((int)((n)->nd_loc.end_pos.lineno))
#define nd_set_last_lineno(n, v) ((n)->nd_loc.end_pos.lineno = (v))
#define nd_last_loc(n) ((n)->nd_loc.end_pos)
#define nd_set_last_loc(n, v) (nd_last_loc(n) = (v))
#define nd_head u1.node
@ -369,101 +369,101 @@ typedef struct RNode {
#define nd_compile_option u3.value
#define NEW_NODE(t,a0,a1,a2,cr) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),cr)
#define NEW_NODE(t,a0,a1,a2,loc) rb_node_newnode((t),(VALUE)(a0),(VALUE)(a1),(VALUE)(a2),loc)
#define NEW_DEFN(i,a,d,cr) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,cr),cr)
#define NEW_DEFS(r,i,a,d,cr) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,cr),cr)
#define NEW_SCOPE(a,b,cr) NEW_NODE(NODE_SCOPE,local_tbl(),b,a,cr)
#define NEW_BLOCK(a,cr) NEW_NODE(NODE_BLOCK,a,0,0,cr)
#define NEW_IF(c,t,e,cr) NEW_NODE(NODE_IF,c,t,e,cr)
#define NEW_UNLESS(c,t,e,cr) NEW_NODE(NODE_UNLESS,c,t,e,cr)
#define NEW_CASE(h,b,cr) NEW_NODE(NODE_CASE,h,b,0,cr)
#define NEW_CASE2(b,cr) NEW_NODE(NODE_CASE2,0,b,0,cr)
#define NEW_WHEN(c,t,e,cr) NEW_NODE(NODE_WHEN,c,t,e,cr)
#define NEW_WHILE(c,b,n,cr) NEW_NODE(NODE_WHILE,c,b,n,cr)
#define NEW_UNTIL(c,b,n,cr) NEW_NODE(NODE_UNTIL,c,b,n,cr)
#define NEW_FOR(v,i,b,cr) NEW_NODE(NODE_FOR,v,b,i,cr)
#define NEW_ITER(a,b,cr) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b,cr),0,cr)
#define NEW_LAMBDA(a,b,cr) NEW_NODE(NODE_LAMBDA,0,NEW_SCOPE(a,b,cr),0,cr)
#define NEW_BREAK(s,cr) NEW_NODE(NODE_BREAK,s,0,0,cr)
#define NEW_NEXT(s,cr) NEW_NODE(NODE_NEXT,s,0,0,cr)
#define NEW_REDO(cr) NEW_NODE(NODE_REDO,0,0,0,cr)
#define NEW_RETRY(cr) NEW_NODE(NODE_RETRY,0,0,0,cr)
#define NEW_BEGIN(b,cr) NEW_NODE(NODE_BEGIN,0,b,0,cr)
#define NEW_RESCUE(b,res,e,cr) NEW_NODE(NODE_RESCUE,b,res,e,cr)
#define NEW_RESBODY(a,ex,n,cr) NEW_NODE(NODE_RESBODY,n,ex,a,cr)
#define NEW_ENSURE(b,en,cr) NEW_NODE(NODE_ENSURE,b,0,en,cr)
#define NEW_RETURN(s,cr) NEW_NODE(NODE_RETURN,s,0,0,cr)
#define NEW_YIELD(a,cr) NEW_NODE(NODE_YIELD,a,0,0,cr)
#define NEW_LIST(a,cr) NEW_ARRAY(a,cr)
#define NEW_ARRAY(a,cr) NEW_NODE(NODE_ARRAY,a,1,0,cr)
#define NEW_ZARRAY(cr) NEW_NODE(NODE_ZARRAY,0,0,0,cr)
#define NEW_HASH(a,cr) NEW_NODE(NODE_HASH,a,0,0,cr)
#define NEW_MASGN(l,r,cr) NEW_NODE(NODE_MASGN,l,0,r,cr)
#define NEW_GASGN(v,val,cr) NEW_NODE(NODE_GASGN,v,val,rb_global_entry(v),cr)
#define NEW_LASGN(v,val,cr) NEW_NODE(NODE_LASGN,v,val,0,cr)
#define NEW_DASGN(v,val,cr) NEW_NODE(NODE_DASGN,v,val,0,cr)
#define NEW_DASGN_CURR(v,val,cr) NEW_NODE(NODE_DASGN_CURR,v,val,0,cr)
#define NEW_IASGN(v,val,cr) NEW_NODE(NODE_IASGN,v,val,0,cr)
#define NEW_CDECL(v,val,path,cr) NEW_NODE(NODE_CDECL,v,val,path,cr)
#define NEW_CVASGN(v,val,cr) NEW_NODE(NODE_CVASGN,v,val,0,cr)
#define NEW_OP_ASGN1(p,id,a,cr) NEW_NODE(NODE_OP_ASGN1,p,id,a,cr)
#define NEW_OP_ASGN2(r,t,i,o,val,cr) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o,t,cr),cr)
#define NEW_OP_ASGN22(i,o,t,cr) NEW_NODE(NODE_OP_ASGN2,i,o,t,cr)
#define NEW_OP_ASGN_OR(i,val,cr) NEW_NODE(NODE_OP_ASGN_OR,i,val,0,cr)
#define NEW_OP_ASGN_AND(i,val,cr) NEW_NODE(NODE_OP_ASGN_AND,i,val,0,cr)
#define NEW_OP_CDECL(v,op,val,cr) NEW_NODE(NODE_OP_CDECL,v,val,op,cr)
#define NEW_GVAR(v,cr) NEW_NODE(NODE_GVAR,v,0,rb_global_entry(v),cr)
#define NEW_LVAR(v,cr) NEW_NODE(NODE_LVAR,v,0,0,cr)
#define NEW_DVAR(v,cr) NEW_NODE(NODE_DVAR,v,0,0,cr)
#define NEW_IVAR(v,cr) NEW_NODE(NODE_IVAR,v,0,0,cr)
#define NEW_CONST(v,cr) NEW_NODE(NODE_CONST,v,0,0,cr)
#define NEW_CVAR(v,cr) NEW_NODE(NODE_CVAR,v,0,0,cr)
#define NEW_NTH_REF(n,cr) NEW_NODE(NODE_NTH_REF,0,n,0,cr)
#define NEW_BACK_REF(n,cr) NEW_NODE(NODE_BACK_REF,0,n,0,cr)
#define NEW_MATCH(c,cr) NEW_NODE(NODE_MATCH,c,0,0,cr)
#define NEW_MATCH2(n1,n2,cr) NEW_NODE(NODE_MATCH2,n1,n2,0,cr)
#define NEW_MATCH3(r,n2,cr) NEW_NODE(NODE_MATCH3,r,n2,0,cr)
#define NEW_LIT(l,cr) NEW_NODE(NODE_LIT,l,0,0,cr)
#define NEW_STR(s,cr) NEW_NODE(NODE_STR,s,0,0,cr)
#define NEW_DSTR(s,cr) NEW_NODE(NODE_DSTR,s,1,0,cr)
#define NEW_XSTR(s,cr) NEW_NODE(NODE_XSTR,s,0,0,cr)
#define NEW_DXSTR(s,cr) NEW_NODE(NODE_DXSTR,s,0,0,cr)
#define NEW_DSYM(s,cr) NEW_NODE(NODE_DSYM,s,0,0,cr)
#define NEW_EVSTR(n,cr) NEW_NODE(NODE_EVSTR,0,(n),0,cr)
#define NEW_CALL(r,m,a,cr) NEW_NODE(NODE_CALL,r,m,a,cr)
#define NEW_OPCALL(r,m,a,cr) NEW_NODE(NODE_OPCALL,r,m,a,cr)
#define NEW_FCALL(m,a,cr) NEW_NODE(NODE_FCALL,0,m,a,cr)
#define NEW_VCALL(m,cr) NEW_NODE(NODE_VCALL,0,m,0,cr)
#define NEW_SUPER(a,cr) NEW_NODE(NODE_SUPER,0,0,a,cr)
#define NEW_ZSUPER(cr) NEW_NODE(NODE_ZSUPER,0,0,0,cr)
#define NEW_ARGS_AUX(r,b,cr) NEW_NODE(NODE_ARGS_AUX,r,b,0,cr)
#define NEW_OPT_ARG(i,v,cr) NEW_NODE(NODE_OPT_ARG,i,v,0,cr)
#define NEW_KW_ARG(i,v,cr) NEW_NODE(NODE_KW_ARG,i,v,0,cr)
#define NEW_POSTARG(i,v,cr) NEW_NODE(NODE_POSTARG,i,v,0,cr)
#define NEW_ARGSCAT(a,b,cr) NEW_NODE(NODE_ARGSCAT,a,b,0,cr)
#define NEW_ARGSPUSH(a,b,cr) NEW_NODE(NODE_ARGSPUSH,a,b,0,cr)
#define NEW_SPLAT(a,cr) NEW_NODE(NODE_SPLAT,a,0,0,cr)
#define NEW_BLOCK_PASS(b,cr) NEW_NODE(NODE_BLOCK_PASS,0,b,0,cr)
#define NEW_ALIAS(n,o,cr) NEW_NODE(NODE_ALIAS,n,o,0,cr)
#define NEW_VALIAS(n,o,cr) NEW_NODE(NODE_VALIAS,n,o,0,cr)
#define NEW_UNDEF(i,cr) NEW_NODE(NODE_UNDEF,0,i,0,cr)
#define NEW_CLASS(n,b,s,cr) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b,cr),(s),cr)
#define NEW_SCLASS(r,b,cr) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b,cr),0,cr)
#define NEW_MODULE(n,b,cr) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b,cr),0,cr)
#define NEW_COLON2(c,i,cr) NEW_NODE(NODE_COLON2,c,i,0,cr)
#define NEW_COLON3(i,cr) NEW_NODE(NODE_COLON3,0,i,0,cr)
#define NEW_DOT2(b,e,cr) NEW_NODE(NODE_DOT2,b,e,0,cr)
#define NEW_DOT3(b,e,cr) NEW_NODE(NODE_DOT3,b,e,0,cr)
#define NEW_SELF(cr) NEW_NODE(NODE_SELF,0,0,0,cr)
#define NEW_NIL(cr) NEW_NODE(NODE_NIL,0,0,0,cr)
#define NEW_TRUE(cr) NEW_NODE(NODE_TRUE,0,0,0,cr)
#define NEW_FALSE(cr) NEW_NODE(NODE_FALSE,0,0,0,cr)
#define NEW_ERRINFO(cr) NEW_NODE(NODE_ERRINFO,0,0,0,cr)
#define NEW_DEFINED(e,cr) NEW_NODE(NODE_DEFINED,e,0,0,cr)
#define NEW_PREEXE(b,cr) NEW_SCOPE(b,cr)
#define NEW_POSTEXE(b,cr) NEW_NODE(NODE_POSTEXE,0,b,0,cr)
#define NEW_ATTRASGN(r,m,a,cr) NEW_NODE(NODE_ATTRASGN,r,m,a,cr)
#define NEW_DEFN(i,a,d,loc) NEW_NODE(NODE_DEFN,0,i,NEW_SCOPE(a,d,loc),loc)
#define NEW_DEFS(r,i,a,d,loc) NEW_NODE(NODE_DEFS,r,i,NEW_SCOPE(a,d,loc),loc)
#define NEW_SCOPE(a,b,loc) NEW_NODE(NODE_SCOPE,local_tbl(),b,a,loc)
#define NEW_BLOCK(a,loc) NEW_NODE(NODE_BLOCK,a,0,0,loc)
#define NEW_IF(c,t,e,loc) NEW_NODE(NODE_IF,c,t,e,loc)
#define NEW_UNLESS(c,t,e,loc) NEW_NODE(NODE_UNLESS,c,t,e,loc)
#define NEW_CASE(h,b,loc) NEW_NODE(NODE_CASE,h,b,0,loc)
#define NEW_CASE2(b,loc) NEW_NODE(NODE_CASE2,0,b,0,loc)
#define NEW_WHEN(c,t,e,loc) NEW_NODE(NODE_WHEN,c,t,e,loc)
#define NEW_WHILE(c,b,n,loc) NEW_NODE(NODE_WHILE,c,b,n,loc)
#define NEW_UNTIL(c,b,n,loc) NEW_NODE(NODE_UNTIL,c,b,n,loc)
#define NEW_FOR(v,i,b,loc) NEW_NODE(NODE_FOR,v,b,i,loc)
#define NEW_ITER(a,b,loc) NEW_NODE(NODE_ITER,0,NEW_SCOPE(a,b,loc),0,loc)
#define NEW_LAMBDA(a,b,loc) NEW_NODE(NODE_LAMBDA,0,NEW_SCOPE(a,b,loc),0,loc)
#define NEW_BREAK(s,loc) NEW_NODE(NODE_BREAK,s,0,0,loc)
#define NEW_NEXT(s,loc) NEW_NODE(NODE_NEXT,s,0,0,loc)
#define NEW_REDO(loc) NEW_NODE(NODE_REDO,0,0,0,loc)
#define NEW_RETRY(loc) NEW_NODE(NODE_RETRY,0,0,0,loc)
#define NEW_BEGIN(b,loc) NEW_NODE(NODE_BEGIN,0,b,0,loc)
#define NEW_RESCUE(b,res,e,loc) NEW_NODE(NODE_RESCUE,b,res,e,loc)
#define NEW_RESBODY(a,ex,n,loc) NEW_NODE(NODE_RESBODY,n,ex,a,loc)
#define NEW_ENSURE(b,en,loc) NEW_NODE(NODE_ENSURE,b,0,en,loc)
#define NEW_RETURN(s,loc) NEW_NODE(NODE_RETURN,s,0,0,loc)
#define NEW_YIELD(a,loc) NEW_NODE(NODE_YIELD,a,0,0,loc)
#define NEW_LIST(a,loc) NEW_ARRAY(a,loc)
#define NEW_ARRAY(a,loc) NEW_NODE(NODE_ARRAY,a,1,0,loc)
#define NEW_ZARRAY(loc) NEW_NODE(NODE_ZARRAY,0,0,0,loc)
#define NEW_HASH(a,loc) NEW_NODE(NODE_HASH,a,0,0,loc)
#define NEW_MASGN(l,r,loc) NEW_NODE(NODE_MASGN,l,0,r,loc)
#define NEW_GASGN(v,val,loc) NEW_NODE(NODE_GASGN,v,val,rb_global_entry(v),loc)
#define NEW_LASGN(v,val,loc) NEW_NODE(NODE_LASGN,v,val,0,loc)
#define NEW_DASGN(v,val,loc) NEW_NODE(NODE_DASGN,v,val,0,loc)
#define NEW_DASGN_CURR(v,val,loc) NEW_NODE(NODE_DASGN_CURR,v,val,0,loc)
#define NEW_IASGN(v,val,loc) NEW_NODE(NODE_IASGN,v,val,0,loc)
#define NEW_CDECL(v,val,path,loc) NEW_NODE(NODE_CDECL,v,val,path,loc)
#define NEW_CVASGN(v,val,loc) NEW_NODE(NODE_CVASGN,v,val,0,loc)
#define NEW_OP_ASGN1(p,id,a,loc) NEW_NODE(NODE_OP_ASGN1,p,id,a,loc)
#define NEW_OP_ASGN2(r,t,i,o,val,loc) NEW_NODE(NODE_OP_ASGN2,r,val,NEW_OP_ASGN22(i,o,t,loc),loc)
#define NEW_OP_ASGN22(i,o,t,loc) NEW_NODE(NODE_OP_ASGN2,i,o,t,loc)
#define NEW_OP_ASGN_OR(i,val,loc) NEW_NODE(NODE_OP_ASGN_OR,i,val,0,loc)
#define NEW_OP_ASGN_AND(i,val,loc) NEW_NODE(NODE_OP_ASGN_AND,i,val,0,loc)
#define NEW_OP_CDECL(v,op,val,loc) NEW_NODE(NODE_OP_CDECL,v,val,op,loc)
#define NEW_GVAR(v,loc) NEW_NODE(NODE_GVAR,v,0,rb_global_entry(v),loc)
#define NEW_LVAR(v,loc) NEW_NODE(NODE_LVAR,v,0,0,loc)
#define NEW_DVAR(v,loc) NEW_NODE(NODE_DVAR,v,0,0,loc)
#define NEW_IVAR(v,loc) NEW_NODE(NODE_IVAR,v,0,0,loc)
#define NEW_CONST(v,loc) NEW_NODE(NODE_CONST,v,0,0,loc)
#define NEW_CVAR(v,loc) NEW_NODE(NODE_CVAR,v,0,0,loc)
#define NEW_NTH_REF(n,loc) NEW_NODE(NODE_NTH_REF,0,n,0,loc)
#define NEW_BACK_REF(n,loc) NEW_NODE(NODE_BACK_REF,0,n,0,loc)
#define NEW_MATCH(c,loc) NEW_NODE(NODE_MATCH,c,0,0,loc)
#define NEW_MATCH2(n1,n2,loc) NEW_NODE(NODE_MATCH2,n1,n2,0,loc)
#define NEW_MATCH3(r,n2,loc) NEW_NODE(NODE_MATCH3,r,n2,0,loc)
#define NEW_LIT(l,loc) NEW_NODE(NODE_LIT,l,0,0,loc)
#define NEW_STR(s,loc) NEW_NODE(NODE_STR,s,0,0,loc)
#define NEW_DSTR(s,loc) NEW_NODE(NODE_DSTR,s,1,0,loc)
#define NEW_XSTR(s,loc) NEW_NODE(NODE_XSTR,s,0,0,loc)
#define NEW_DXSTR(s,loc) NEW_NODE(NODE_DXSTR,s,0,0,loc)
#define NEW_DSYM(s,loc) NEW_NODE(NODE_DSYM,s,0,0,loc)
#define NEW_EVSTR(n,loc) NEW_NODE(NODE_EVSTR,0,(n),0,loc)
#define NEW_CALL(r,m,a,loc) NEW_NODE(NODE_CALL,r,m,a,loc)
#define NEW_OPCALL(r,m,a,loc) NEW_NODE(NODE_OPCALL,r,m,a,loc)
#define NEW_FCALL(m,a,loc) NEW_NODE(NODE_FCALL,0,m,a,loc)
#define NEW_VCALL(m,loc) NEW_NODE(NODE_VCALL,0,m,0,loc)
#define NEW_SUPER(a,loc) NEW_NODE(NODE_SUPER,0,0,a,loc)
#define NEW_ZSUPER(loc) NEW_NODE(NODE_ZSUPER,0,0,0,loc)
#define NEW_ARGS_AUX(r,b,loc) NEW_NODE(NODE_ARGS_AUX,r,b,0,loc)
#define NEW_OPT_ARG(i,v,loc) NEW_NODE(NODE_OPT_ARG,i,v,0,loc)
#define NEW_KW_ARG(i,v,loc) NEW_NODE(NODE_KW_ARG,i,v,0,loc)
#define NEW_POSTARG(i,v,loc) NEW_NODE(NODE_POSTARG,i,v,0,loc)
#define NEW_ARGSCAT(a,b,loc) NEW_NODE(NODE_ARGSCAT,a,b,0,loc)
#define NEW_ARGSPUSH(a,b,loc) NEW_NODE(NODE_ARGSPUSH,a,b,0,loc)
#define NEW_SPLAT(a,loc) NEW_NODE(NODE_SPLAT,a,0,0,loc)
#define NEW_BLOCK_PASS(b,loc) NEW_NODE(NODE_BLOCK_PASS,0,b,0,loc)
#define NEW_ALIAS(n,o,loc) NEW_NODE(NODE_ALIAS,n,o,0,loc)
#define NEW_VALIAS(n,o,loc) NEW_NODE(NODE_VALIAS,n,o,0,loc)
#define NEW_UNDEF(i,loc) NEW_NODE(NODE_UNDEF,0,i,0,loc)
#define NEW_CLASS(n,b,s,loc) NEW_NODE(NODE_CLASS,n,NEW_SCOPE(0,b,loc),(s),loc)
#define NEW_SCLASS(r,b,loc) NEW_NODE(NODE_SCLASS,r,NEW_SCOPE(0,b,loc),0,loc)
#define NEW_MODULE(n,b,loc) NEW_NODE(NODE_MODULE,n,NEW_SCOPE(0,b,loc),0,loc)
#define NEW_COLON2(c,i,loc) NEW_NODE(NODE_COLON2,c,i,0,loc)
#define NEW_COLON3(i,loc) NEW_NODE(NODE_COLON3,0,i,0,loc)
#define NEW_DOT2(b,e,loc) NEW_NODE(NODE_DOT2,b,e,0,loc)
#define NEW_DOT3(b,e,loc) NEW_NODE(NODE_DOT3,b,e,0,loc)
#define NEW_SELF(loc) NEW_NODE(NODE_SELF,0,0,0,loc)
#define NEW_NIL(loc) NEW_NODE(NODE_NIL,0,0,0,loc)
#define NEW_TRUE(loc) NEW_NODE(NODE_TRUE,0,0,0,loc)
#define NEW_FALSE(loc) NEW_NODE(NODE_FALSE,0,0,0,loc)
#define NEW_ERRINFO(loc) NEW_NODE(NODE_ERRINFO,0,0,0,loc)
#define NEW_DEFINED(e,loc) NEW_NODE(NODE_DEFINED,e,0,0,loc)
#define NEW_PREEXE(b,loc) NEW_SCOPE(b,loc)
#define NEW_POSTEXE(b,loc) NEW_NODE(NODE_POSTEXE,0,b,0,loc)
#define NEW_ATTRASGN(r,m,a,loc) NEW_NODE(NODE_ATTRASGN,r,m,a,loc)
#define NODE_SPECIAL_REQUIRED_KEYWORD ((NODE *)-1)
#define NODE_SPECIAL_NO_NAME_REST ((NODE *)-1)

704
parse.y

File diff suppressed because it is too large Load diff

View file

@ -5070,7 +5070,7 @@ update_branch_coverage(VALUE data, const rb_trace_arg_t *trace_arg)
const rb_method_entry_t *
rb_resolve_me_location(const rb_method_entry_t *me, VALUE resolved_location[5])
{
VALUE path, first_lineno, first_column, last_lineno, last_column;
VALUE path, beg_pos_lineno, beg_pos_column, end_pos_lineno, end_pos_column;
retry:
switch (me->def->type) {
@ -5078,10 +5078,10 @@ rb_resolve_me_location(const rb_method_entry_t *me, VALUE resolved_location[5])
const rb_iseq_t *iseq = me->def->body.iseq.iseqptr;
rb_iseq_location_t *loc = &iseq->body->location;
path = rb_iseq_path(iseq);
first_lineno = INT2FIX(loc->code_range.first_loc.lineno);
first_column = INT2FIX(loc->code_range.first_loc.column);
last_lineno = INT2FIX(loc->code_range.last_loc.lineno);
last_column = INT2FIX(loc->code_range.last_loc.column);
beg_pos_lineno = INT2FIX(loc->code_location.beg_pos.lineno);
beg_pos_column = INT2FIX(loc->code_location.beg_pos.column);
end_pos_lineno = INT2FIX(loc->code_location.end_pos.lineno);
end_pos_column = INT2FIX(loc->code_location.end_pos.column);
break;
}
case VM_METHOD_TYPE_BMETHOD: {
@ -5091,10 +5091,10 @@ rb_resolve_me_location(const rb_method_entry_t *me, VALUE resolved_location[5])
rb_iseq_check(iseq);
path = rb_iseq_path(iseq);
loc = &iseq->body->location;
first_lineno = INT2FIX(loc->code_range.first_loc.lineno);
first_column = INT2FIX(loc->code_range.first_loc.column);
last_lineno = INT2FIX(loc->code_range.last_loc.lineno);
last_column = INT2FIX(loc->code_range.last_loc.column);
beg_pos_lineno = INT2FIX(loc->code_location.beg_pos.lineno);
beg_pos_column = INT2FIX(loc->code_location.beg_pos.column);
end_pos_lineno = INT2FIX(loc->code_location.end_pos.lineno);
end_pos_column = INT2FIX(loc->code_location.end_pos.column);
break;
}
return NULL;
@ -5117,10 +5117,10 @@ rb_resolve_me_location(const rb_method_entry_t *me, VALUE resolved_location[5])
}
if (resolved_location) {
resolved_location[0] = path;
resolved_location[1] = first_lineno;
resolved_location[2] = first_column;
resolved_location[3] = last_lineno;
resolved_location[4] = last_column;
resolved_location[1] = beg_pos_lineno;
resolved_location[2] = beg_pos_column;
resolved_location[3] = end_pos_lineno;
resolved_location[4] = end_pos_column;
}
return me;
}

View file

@ -258,7 +258,7 @@ typedef struct rb_iseq_location_struct {
VALUE base_label; /* String */
VALUE label; /* String */
VALUE first_lineno; /* TODO: may be unsigned short */
rb_code_range_t code_range;
rb_code_location_t code_location;
} rb_iseq_location_t;
#define PATHOBJ_PATH 0