diff --git a/compile.c b/compile.c index 64f88c4bc2..f55ea8307a 100644 --- a/compile.c +++ b/compile.c @@ -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); diff --git a/iseq.c b/iseq.c index e49e8d9226..404446e4c2 100644 --- a/iseq.c +++ b/iseq.c @@ -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("#", 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, diff --git a/iseq.h b/iseq.h index dd276a59f6..53de21dee1 100644 --- a/iseq.h +++ b/iseq.h @@ -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); diff --git a/node.c b/node.c index 1704fcaff4..a5c04aa5fd 100644 --- a/node.c +++ b/node.c @@ -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 { diff --git a/node.h b/node.h index c2a3b91e29..ec1ae3d257 100644 --- a/node.h +++ b/node.h @@ -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)<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) diff --git a/parse.y b/parse.y index 3879668ac2..c57ef0de60 100644 --- a/parse.y +++ b/parse.y @@ -17,7 +17,7 @@ #define YYDEBUG 1 #define YYERROR_VERBOSE 1 #define YYSTACK_USE_ALLOCA 0 -#define YYLTYPE rb_code_range_t +#define YYLTYPE rb_code_location_t #define YYLTYPE_IS_DECLARED 1 #include "ruby/ruby.h" @@ -44,27 +44,27 @@ #define YYCALLOC(nelem, size) rb_parser_calloc(parser, (nelem), (size)) #define YYFREE(ptr) rb_parser_free(parser, (ptr)) #define YYFPRINTF rb_parser_printf -#define YY_LOCATION_PRINT(File, Loc) \ +#define YY_LOCATION_PRINT(File, loc) \ rb_parser_printf(parser, "%d.%d-%d.%d", \ - (Loc).first_loc.lineno, (Loc).first_loc.column,\ - (Loc).last_loc.lineno, (Loc).last_loc.column) + (loc).beg_pos.lineno, (loc).beg_pos.column,\ + (loc).end_pos.lineno, (loc).end_pos.column) #define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ if (N) \ { \ - (Current).first_loc = YYRHSLOC(Rhs, 1).first_loc; \ - (Current).last_loc = YYRHSLOC(Rhs, N).last_loc; \ + (Current).beg_pos = YYRHSLOC(Rhs, 1).beg_pos; \ + (Current).end_pos = YYRHSLOC(Rhs, N).end_pos; \ } \ else \ RUBY_SET_YYLLOC_OF_NONE(Current); \ while (0) #define RUBY_SET_YYLLOC_FROM_STRTERM_HEREDOC(Current) \ - rb_parser_set_code_range_from_strterm_heredoc(parser, &lex_strterm->u.heredoc, &(Current)) + rb_parser_set_location_from_strterm_heredoc(parser, &lex_strterm->u.heredoc, &(Current)) #define RUBY_SET_YYLLOC_OF_NONE(Current) \ - rb_parser_set_code_range_of_none(parser, &(Current)) + rb_parser_set_location_of_none(parser, &(Current)) #define RUBY_SET_YYLLOC(Current) \ - rb_parser_set_code_range(parser, &(Current)) + rb_parser_set_location(parser, &(Current)) enum lex_state_bits { EXPR_BEG_bit, /* ignore newline, +/- is a sign. */ @@ -116,7 +116,7 @@ enum lex_state_e { typedef VALUE stack_type; -static const rb_code_range_t NULL_LOC = { {0, -1}, {0, -1} }; +static const rb_code_location_t NULL_LOC = { {0, -1}, {0, -1} }; # define SHOW_BITSTACK(stack, name) (yydebug ? rb_parser_show_bitstack(parser, stack, name, __LINE__) : (void)0) # define BITSTACK_PUSH(stack, n) (((stack) = ((stack)<<1)|((n)&1)), SHOW_BITSTACK(stack, #stack"(push)")) @@ -282,7 +282,7 @@ struct parser_params { static int parser_yyerror(struct parser_params*, const YYLTYPE *yylloc, const char*); #define yyerror0(msg) parser_yyerror(parser, NULL, (msg)) -#define yyerror1(cr, msg) parser_yyerror(parser, (cr), (msg)) +#define yyerror1(loc, msg) parser_yyerror(parser, (loc), (msg)) #define yyerror(yylloc, parser, msg) parser_yyerror(parser, yylloc, msg) #define token_flush(p) ((p)->lex.ptok = (p)->lex.pcur) @@ -337,7 +337,7 @@ static int parser_yyerror(struct parser_params*, const YYLTYPE *yylloc, const ch #define CALL_Q_P(q) ((q) == TOKEN2VAL(tANDDOT)) #define NODE_CALL_Q(q) (CALL_Q_P(q) ? NODE_QCALL : NODE_CALL) -#define NEW_QCALL(q,r,m,a,cr) NEW_NODE(NODE_CALL_Q(q),r,m,a,cr) +#define NEW_QCALL(q,r,m,a,loc) NEW_NODE(NODE_CALL_Q(q),r,m,a,loc) #define lambda_beginning_p() (lpar_beg && lpar_beg == paren_nest) @@ -366,10 +366,10 @@ add_mark_object_gen(struct parser_params *parser, VALUE obj) } #define add_mark_object(obj) add_mark_object_gen(parser, (obj)) -static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE, const rb_code_range_t*); -#define rb_node_newnode(type, a1, a2, a3, cr) node_newnode(parser, (type), (a1), (a2), (a3), (cr)) +static NODE* node_newnode(struct parser_params *, enum node_type, VALUE, VALUE, VALUE, const rb_code_location_t*); +#define rb_node_newnode(type, a1, a2, a3, loc) node_newnode(parser, (type), (a1), (a2), (a3), (loc)) -static NODE *nd_set_crange(NODE *nd, const YYLTYPE *cr); +static NODE *nd_set_loc(NODE *nd, const YYLTYPE *loc); #ifndef RIPPER static inline void @@ -386,17 +386,17 @@ set_line_body(NODE *body, int line) #define yyparse ruby_yyparse static NODE *cond_gen(struct parser_params*,NODE*,int,const YYLTYPE*); -#define cond(node,cr) cond_gen(parser, (node), FALSE, cr) -#define method_cond(node,cr) cond_gen(parser, (node), TRUE, cr) -#define new_nil(cr) NEW_NIL(cr) +#define cond(node,loc) cond_gen(parser, (node), FALSE, loc) +#define method_cond(node,loc) cond_gen(parser, (node), TRUE, loc) +#define new_nil(loc) NEW_NIL(loc) static NODE *new_if_gen(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*); -#define new_if(cc,left,right,cr) new_if_gen(parser, (cc), (left), (right), (cr)) +#define new_if(cc,left,right,loc) new_if_gen(parser, (cc), (left), (right), (loc)) static NODE *new_unless_gen(struct parser_params*,NODE*,NODE*,NODE*,const YYLTYPE*); -#define new_unless(cc,left,right,cr) new_unless_gen(parser, (cc), (left), (right), (cr)) +#define new_unless(cc,left,right,loc) new_unless_gen(parser, (cc), (left), (right), (loc)) static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*); -#define logop(id,node1,node2,op_cr,cr) \ +#define logop(id,node1,node2,op_loc,loc) \ logop_gen(parser, ((id)==idAND||(id)==idANDOP)?NODE_AND:NODE_OR, \ - (node1), (node2), (op_cr), (cr)) + (node1), (node2), (op_loc), (loc)) static NODE *newline_node(NODE*); static void fixpos(NODE*,NODE*); @@ -421,36 +421,36 @@ static NODE *list_append_gen(struct parser_params*,NODE*,NODE*); #define list_append(l,i) list_append_gen(parser,(l),(i)) static NODE *list_concat(NODE*,NODE*); static NODE *arg_append_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*); -#define arg_append(h,t,cr) arg_append_gen(parser,(h),(t),(cr)) +#define arg_append(h,t,loc) arg_append_gen(parser,(h),(t),(loc)) static NODE *arg_concat_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*); -#define arg_concat(h,t,cr) arg_concat_gen(parser,(h),(t),(cr)) +#define arg_concat(h,t,loc) arg_concat_gen(parser,(h),(t),(loc)) static NODE *literal_concat_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*); -#define literal_concat(h,t,cr) literal_concat_gen(parser,(h),(t),(cr)) +#define literal_concat(h,t,loc) literal_concat_gen(parser,(h),(t),(loc)) static int literal_concat0(struct parser_params *, VALUE, VALUE); static NODE *new_evstr_gen(struct parser_params*,NODE*,const YYLTYPE*); -#define new_evstr(n, cr) new_evstr_gen(parser,(n),(cr)) +#define new_evstr(n, loc) new_evstr_gen(parser,(n),(loc)) static NODE *evstr2dstr_gen(struct parser_params*,NODE*); #define evstr2dstr(n) evstr2dstr_gen(parser,(n)) static NODE *splat_array(NODE*); static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*,const YYLTYPE*,const YYLTYPE*); -#define call_bin_op(recv,id,arg1,op_cr,cr) call_bin_op_gen(parser, (recv),(id),(arg1),(op_cr),(cr)) +#define call_bin_op(recv,id,arg1,op_loc,loc) call_bin_op_gen(parser, (recv),(id),(arg1),(op_loc),(loc)) static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID,const YYLTYPE*,const YYLTYPE*); -#define call_uni_op(recv,id,op_cr,cr) call_uni_op_gen(parser, (recv),(id),(op_cr),(cr)) -static NODE *new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_cr, const YYLTYPE *cr); -#define new_qcall(q,r,m,a,op_cr,cr) new_qcall_gen(parser,q,r,m,a,op_cr,cr) -#define new_command_qcall(q,r,m,a,op_cr,cr) new_qcall_gen(parser,q,r,m,a,op_cr,cr) +#define call_uni_op(recv,id,op_loc,loc) call_uni_op_gen(parser, (recv),(id),(op_loc),(loc)) +static NODE *new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_loc, const YYLTYPE *loc); +#define new_qcall(q,r,m,a,op_loc,loc) new_qcall_gen(parser,q,r,m,a,op_loc,loc) +#define new_command_qcall(q,r,m,a,op_loc,loc) new_qcall_gen(parser,q,r,m,a,op_loc,loc) static NODE *new_command_gen(struct parser_params*parser, NODE *m, NODE *a) {m->nd_args = a; return m;} #define new_command(m,a) new_command_gen(parser, m, a) -static NODE *method_add_block_gen(struct parser_params*parser, NODE *m, NODE *b, const YYLTYPE *cr) {b->nd_iter = m; b->nd_crange = *cr; return b;} -#define method_add_block(m,b,cr) method_add_block_gen(parser, m, b, cr) +static NODE *method_add_block_gen(struct parser_params*parser, NODE *m, NODE *b, const YYLTYPE *loc) {b->nd_iter = m; b->nd_loc = *loc; return b;} +#define method_add_block(m,b,loc) method_add_block_gen(parser, m, b, loc) static NODE *new_args_gen(struct parser_params*,NODE*,NODE*,ID,NODE*,NODE*,const YYLTYPE*); -#define new_args(f,o,r,p,t,cr) new_args_gen(parser, (f),(o),(r),(p),(t),(cr)) +#define new_args(f,o,r,p,t,loc) new_args_gen(parser, (f),(o),(r),(p),(t),(loc)) static NODE *new_args_tail_gen(struct parser_params*,NODE*,ID,ID,const YYLTYPE*); -#define new_args_tail(k,kr,b,cr) new_args_tail_gen(parser, (k),(kr),(b),(cr)) -static NODE *new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *cr); -#define new_kw_arg(k,cr) new_kw_arg_gen(parser, k, cr) +#define new_args_tail(k,kr,b,loc) new_args_tail_gen(parser, (k),(kr),(b),(loc)) +static NODE *new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *loc); +#define new_kw_arg(k,loc) new_kw_arg_gen(parser, k, loc) static VALUE negate_lit_gen(struct parser_params*, VALUE); #define negate_lit(lit) negate_lit_gen(parser, lit) @@ -458,65 +458,65 @@ static NODE *ret_args_gen(struct parser_params*,NODE*); #define ret_args(node) ret_args_gen(parser, (node)) static NODE *arg_blk_pass(NODE*,NODE*); static NODE *new_yield_gen(struct parser_params*,NODE*,const YYLTYPE*); -#define new_yield(node,cr) new_yield_gen(parser, (node), (cr)) +#define new_yield(node,loc) new_yield_gen(parser, (node), (loc)) static NODE *dsym_node_gen(struct parser_params*,NODE*,const YYLTYPE*); -#define dsym_node(node,cr) dsym_node_gen(parser, (node), (cr)) +#define dsym_node(node,loc) dsym_node_gen(parser, (node), (loc)) static NODE *gettable_gen(struct parser_params*,ID,const YYLTYPE*); -#define gettable(id,cr) gettable_gen(parser,(id),(cr)) +#define gettable(id,loc) gettable_gen(parser,(id),(loc)) static NODE *assignable_gen(struct parser_params*,ID,NODE*,const YYLTYPE*); -#define assignable(id,node,cr) assignable_gen(parser, (id), (node), (cr)) +#define assignable(id,node,loc) assignable_gen(parser, (id), (node), (loc)) static NODE *aryset_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*); -#define aryset(node1,node2,cr) aryset_gen(parser, (node1), (node2), (cr)) +#define aryset(node1,node2,loc) aryset_gen(parser, (node1), (node2), (loc)) static NODE *attrset_gen(struct parser_params*,NODE*,ID,ID,const YYLTYPE*); -#define attrset(node,q,id,cr) attrset_gen(parser, (node), (q), (id), (cr)) +#define attrset(node,q,id,loc) attrset_gen(parser, (node), (q), (id), (loc)) static void rb_backref_error_gen(struct parser_params*,NODE*); #define rb_backref_error(n) rb_backref_error_gen(parser,(n)) static NODE *node_assign_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*); -#define node_assign(node1, node2, cr) node_assign_gen(parser, (node1), (node2), (cr)) +#define node_assign(node1, node2, loc) node_assign_gen(parser, (node1), (node2), (loc)) -static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *cr); -#define new_op_assign(lhs, op, rhs, cr) new_op_assign_gen(parser, (lhs), (op), (rhs), (cr)) -static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *cr); -#define new_attr_op_assign(lhs, type, attr, op, rhs, cr) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs), (cr)) -static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *cr); -#define new_const_op_assign(lhs, op, rhs, cr) new_const_op_assign_gen(parser, (lhs), (op), (rhs), (cr)) +static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc); +#define new_op_assign(lhs, op, rhs, loc) new_op_assign_gen(parser, (lhs), (op), (rhs), (loc)) +static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc); +#define new_attr_op_assign(lhs, type, attr, op, rhs, loc) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs), (loc)) +static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc); +#define new_const_op_assign(lhs, op, rhs, loc) new_const_op_assign_gen(parser, (lhs), (op), (rhs), (loc)) -static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *cr); -#define const_path_field(w, n, cr) const_path_field_gen(parser, w, n, cr) -#define top_const_field(n,cr) NEW_COLON3(n,cr) -static NODE *const_decl_gen(struct parser_params *parser, NODE* path, const YYLTYPE *cr); -#define const_decl(path, cr) const_decl_gen(parser, path, cr) +static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *loc); +#define const_path_field(w, n, loc) const_path_field_gen(parser, w, n, loc) +#define top_const_field(n,loc) NEW_COLON3(n,loc) +static NODE *const_decl_gen(struct parser_params *parser, NODE* path, const YYLTYPE *loc); +#define const_decl(path, loc) const_decl_gen(parser, path, loc) #define var_field(n) (n) -#define backref_assign_error(n, a, cr) (rb_backref_error(n), NEW_BEGIN(0, cr)) +#define backref_assign_error(n, a, loc) (rb_backref_error(n), NEW_BEGIN(0, loc)) static NODE *opt_arg_append(NODE*, NODE*); static NODE *kwd_append(NODE*, NODE*); -static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *cr); -#define new_hash(hash, cr) new_hash_gen(parser, (hash), cr) +static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *loc); +#define new_hash(hash, loc) new_hash_gen(parser, (hash), loc) -static NODE *new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *cr); -#define new_defined(expr, cr) new_defined_gen(parser, expr, cr) +static NODE *new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *loc); +#define new_defined(expr, loc) new_defined_gen(parser, expr, loc) static NODE *new_regexp_gen(struct parser_params *, NODE *, int, const YYLTYPE *); -#define new_regexp(node, opt, cr) new_regexp_gen(parser, node, opt, cr) +#define new_regexp(node, opt, loc) new_regexp_gen(parser, node, opt, loc) -#define make_array(ary, cr) ((ary) ? (nd_set_crange(ary, cr), ary) : NEW_ZARRAY(cr)) +#define make_array(ary, loc) ((ary) ? (nd_set_loc(ary, loc), ary) : NEW_ZARRAY(loc)) -static NODE *new_xstring_gen(struct parser_params *, NODE *, const YYLTYPE *cr); -#define new_xstring(node, cr) new_xstring_gen(parser, node, cr) +static NODE *new_xstring_gen(struct parser_params *, NODE *, const YYLTYPE *loc); +#define new_xstring(node, loc) new_xstring_gen(parser, node, loc) #define new_string1(str) (str) -static NODE *new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *cr); -#define new_brace_body(param, stmt, cr) new_body_gen(parser, param, stmt, cr) -#define new_do_body(param, stmt, cr) new_body_gen(parser, param, stmt, cr) +static NODE *new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *loc); +#define new_brace_body(param, stmt, loc) new_body_gen(parser, param, stmt, loc) +#define new_do_body(param, stmt, loc) new_body_gen(parser, param, stmt, loc) static NODE *match_op_gen(struct parser_params*,NODE*,NODE*,const YYLTYPE*,const YYLTYPE*); -#define match_op(node1,node2,op_cr,cr) match_op_gen(parser, (node1), (node2), (op_cr), (cr)) +#define match_op(node1,node2,op_loc,loc) match_op_gen(parser, (node1), (node2), (op_loc), (loc)) static ID *local_tbl_gen(struct parser_params*); #define local_tbl() local_tbl_gen(parser) @@ -527,8 +527,8 @@ static void reg_fragment_setenc_gen(struct parser_params*, VALUE, int); #define reg_fragment_setenc(str,options) reg_fragment_setenc_gen(parser, (str), (options)) static int reg_fragment_check_gen(struct parser_params*, VALUE, int); #define reg_fragment_check(str,options) reg_fragment_check_gen(parser, (str), (options)) -static NODE *reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, const YYLTYPE *cr); -#define reg_named_capture_assign(regexp,cr) reg_named_capture_assign_gen(parser,(regexp),cr) +static NODE *reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, const YYLTYPE *loc); +#define reg_named_capture_assign(regexp,loc) reg_named_capture_assign_gen(parser,(regexp),loc) static NODE *parser_heredoc_dedent(struct parser_params*,NODE*); # define heredoc_dedent(str) parser_heredoc_dedent(parser, (str)) @@ -562,48 +562,48 @@ static ID ripper_get_id(VALUE); static VALUE ripper_get_value(VALUE); #define get_value(val) ripper_get_value(val) static VALUE assignable_gen(struct parser_params*,VALUE); -#define assignable(lhs,node,cr) assignable_gen(parser, (lhs)) +#define assignable(lhs,node,loc) assignable_gen(parser, (lhs)) static int id_is_var_gen(struct parser_params *parser, ID id); #define id_is_var(id) id_is_var_gen(parser, (id)) -#define method_cond(node,cr) (node) -#define call_bin_op(recv,id,arg1,op_cr,cr) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1)) -#define match_op(node1,node2,op_cr,cr) call_bin_op((node1), idEqTilde, (node2), op_cr, cr) -#define call_uni_op(recv,id,op_cr,cr) dispatch2(unary, STATIC_ID2SYM(id), (recv)) -#define logop(id,node1,node2,op_cr,cr) call_bin_op((node1), (id), (node2), op_cr, cr) -#define node_assign(node1, node2, cr) dispatch2(assign, (node1), (node2)) +#define method_cond(node,loc) (node) +#define call_bin_op(recv,id,arg1,op_loc,loc) dispatch3(binary, (recv), STATIC_ID2SYM(id), (arg1)) +#define match_op(node1,node2,op_loc,loc) call_bin_op((node1), idEqTilde, (node2), op_loc, loc) +#define call_uni_op(recv,id,op_loc,loc) dispatch2(unary, STATIC_ID2SYM(id), (recv)) +#define logop(id,node1,node2,op_loc,loc) call_bin_op((node1), (id), (node2), op_loc, loc) +#define node_assign(node1, node2, loc) dispatch2(assign, (node1), (node2)) static VALUE new_qcall_gen(struct parser_params *parser, VALUE q, VALUE r, VALUE m, VALUE a); -#define new_qcall(q,r,m,a,op_cr,cr) new_qcall_gen(parser, (r), (q), (m), (a)) -#define new_command_qcall(q,r,m,a,op_cr,cr) dispatch4(command_call, (r), (q), (m), (a)) +#define new_qcall(q,r,m,a,op_loc,loc) new_qcall_gen(parser, (r), (q), (m), (a)) +#define new_command_qcall(q,r,m,a,op_loc,loc) dispatch4(command_call, (r), (q), (m), (a)) #define new_command(m,a) dispatch2(command, (m), (a)); -#define new_nil(cr) Qnil +#define new_nil(loc) Qnil static VALUE new_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE op, VALUE rhs); -#define new_op_assign(lhs, op, rhs, cr) new_op_assign_gen(parser, (lhs), (op), (rhs)) +#define new_op_assign(lhs, op, rhs, loc) new_op_assign_gen(parser, (lhs), (op), (rhs)) static VALUE new_attr_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE type, VALUE attr, VALUE op, VALUE rhs); -#define new_attr_op_assign(lhs, type, attr, op, rhs, cr) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs)) -#define new_const_op_assign(lhs, op, rhs, cr) new_op_assign(lhs, op, rhs, cr) +#define new_attr_op_assign(lhs, type, attr, op, rhs, loc) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs)) +#define new_const_op_assign(lhs, op, rhs, loc) new_op_assign(lhs, op, rhs, loc) static VALUE new_regexp_gen(struct parser_params *, VALUE, VALUE); -#define new_regexp(node, opt, cr) new_regexp_gen(parser, node, opt) +#define new_regexp(node, opt, loc) new_regexp_gen(parser, node, opt) static VALUE new_xstring_gen(struct parser_params *, VALUE); -#define new_xstring(str, cr) new_xstring_gen(parser, str) +#define new_xstring(str, loc) new_xstring_gen(parser, str) #define new_string1(str) dispatch1(string_literal, str) -#define new_brace_body(param, stmt, cr) dispatch2(brace_block, escape_Qundef(param), stmt) -#define new_do_body(param, stmt, cr) dispatch2(do_block, escape_Qundef(param), stmt) +#define new_brace_body(param, stmt, loc) dispatch2(brace_block, escape_Qundef(param), stmt) +#define new_do_body(param, stmt, loc) dispatch2(do_block, escape_Qundef(param), stmt) -#define const_path_field(w, n, cr) dispatch2(const_path_field, (w), (n)) -#define top_const_field(n,cr) dispatch1(top_const_field, (n)) +#define const_path_field(w, n, loc) dispatch2(const_path_field, (w), (n)) +#define top_const_field(n,loc) dispatch1(top_const_field, (n)) static VALUE const_decl_gen(struct parser_params *parser, VALUE path); -#define const_decl(path, cr) const_decl_gen(parser, path) +#define const_decl(path, loc) const_decl_gen(parser, path) static VALUE var_field_gen(struct parser_params *parser, VALUE a); #define var_field(a) var_field_gen(parser, (a)) static VALUE assign_error_gen(struct parser_params *parser, VALUE a); #define assign_error(a) assign_error_gen(parser, (a)) -#define backref_assign_error(n, a, cr) assign_error(a) +#define backref_assign_error(n, a, loc) assign_error(a) #define block_dup_check(n1,n2) ((void)(n1), (void)(n2)) #define fixpos(n1,n2) ((void)(n1), (void)(n2)) @@ -624,9 +624,9 @@ enum lex_state_e rb_parser_trace_lex_state(struct parser_params *, enum lex_stat VALUE rb_parser_lex_state_name(enum lex_state_e state); void rb_parser_show_bitstack(struct parser_params *, stack_type, const char *, int); PRINTF_ARGS(void rb_parser_fatal(struct parser_params *parser, const char *fmt, ...), 2, 3); -void rb_parser_set_code_range_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc); -void rb_parser_set_code_range_of_none(struct parser_params *parser, YYLTYPE *yylloc); -void rb_parser_set_code_range(struct parser_params *parser, YYLTYPE *yylloc); +void rb_parser_set_location_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc); +void rb_parser_set_location_of_none(struct parser_params *parser, YYLTYPE *yylloc); +void rb_parser_set_location(struct parser_params *parser, YYLTYPE *yylloc); RUBY_SYMBOL_EXPORT_END static ID formal_argument_gen(struct parser_params*, ID); @@ -801,7 +801,7 @@ static void ripper_error_gen(struct parser_params *parser); #define method_optarg(m,a) ((a)==Qundef ? (m) : dispatch2(method_add_arg,(m),(a))) #define method_arg(m,a) dispatch2(method_add_arg,(m),(a)) -#define method_add_block(m,b,cr) dispatch2(method_add_block, (m), (b)) +#define method_add_block(m,b,loc) dispatch2(method_add_block, (m), (b)) #define escape_Qundef(x) ((x)==Qundef ? Qnil : (x)) @@ -812,7 +812,7 @@ new_args_gen(struct parser_params *parser, VALUE f, VALUE o, VALUE r, VALUE p, V VALUE k = t->u1.value, kr = t->u2.value, b = t->u3.value; return params_new(f, o, r, p, k, kr, escape_Qundef(b)); } -#define new_args(f,o,r,p,t,cr) new_args_gen(parser, (f),(o),(r),(p),(t)) +#define new_args(f,o,r,p,t,loc) new_args_gen(parser, (f),(o),(r),(p),(t)) static inline VALUE new_args_tail_gen(struct parser_params *parser, VALUE k, VALUE kr, VALUE b) @@ -823,9 +823,9 @@ new_args_tail_gen(struct parser_params *parser, VALUE k, VALUE kr, VALUE b) add_mark_object(b); return (VALUE)t; } -#define new_args_tail(k,kr,b,cr) new_args_tail_gen(parser, (k),(kr),(b)) +#define new_args_tail(k,kr,b,loc) new_args_tail_gen(parser, (k),(kr),(b)) -#define new_defined(expr,cr) dispatch1(defined, (expr)) +#define new_defined(expr,loc) dispatch1(defined, (expr)) static VALUE parser_heredoc_dedent(struct parser_params*,VALUE); # define heredoc_dedent(str) parser_heredoc_dedent(parser, (str)) @@ -1380,8 +1380,8 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem { /*%%%*/ NODE *resq; - YYLTYPE cr = code_range_gen(&@2, &@3); - resq = NEW_RESBODY(0, remove_begin($3), 0, &cr); + YYLTYPE loc = code_loc_gen(&@2, &@3); + resq = NEW_RESBODY(0, remove_begin($3), 0, &loc); $$ = NEW_RESCUE(remove_begin($1), resq, 0, &@$); /*% $$ = dispatch2(rescue_mod, $1, $3); @@ -1466,10 +1466,10 @@ command_asgn : lhs '=' command_rhs | primary_value tCOLON2 tCONSTANT tOP_ASGN command_rhs { /*%%%*/ - YYLTYPE cr = code_range_gen(&@1, &@3); + YYLTYPE loc = code_loc_gen(&@1, &@3); /*% %*/ - $$ = const_path_field($1, $3, &cr); + $$ = const_path_field($1, $3, &loc); $$ = new_const_op_assign($$, $4, $5, &@$); } | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_rhs @@ -1495,9 +1495,9 @@ command_rhs : command_call %prec tOP_ASGN | command_call modifier_rescue stmt { /*%%%*/ - YYLTYPE cr = code_range_gen(&@2, &@3); + YYLTYPE loc = code_loc_gen(&@2, &@3); value_expr($1); - $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &cr), 0, &@$); + $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &loc), 0, &@$); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ @@ -1552,8 +1552,8 @@ cmd_brace_block : tLBRACE_ARG brace_body '}' { $$ = $2; /*%%%*/ - $$->nd_body->nd_crange = code_range_gen(&@1, &@3); - nd_set_line($$, @1.last_loc.lineno); + $$->nd_body->nd_loc = code_loc_gen(&@1, &@3); + nd_set_line($$, @1.end_pos.lineno); /*% %*/ } ; @@ -2101,10 +2101,10 @@ arg : lhs '=' arg_rhs | primary_value tCOLON2 tCONSTANT tOP_ASGN arg_rhs { /*%%%*/ - YYLTYPE cr = code_range_gen(&@1, &@3); + YYLTYPE loc = code_loc_gen(&@1, &@3); /*% %*/ - $$ = const_path_field($1, $3, &cr); + $$ = const_path_field($1, $3, &loc); $$ = new_const_op_assign($$, $4, $5, &@$); } | tCOLON3 tCONSTANT tOP_ASGN arg_rhs @@ -2318,9 +2318,9 @@ arg_rhs : arg %prec tOP_ASGN | arg modifier_rescue arg { /*%%%*/ - YYLTYPE cr = code_range_gen(&@2, &@3); + YYLTYPE loc = code_loc_gen(&@2, &@3); value_expr($1); - $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &cr), 0, &@$); + $$ = NEW_RESCUE($1, NEW_RESBODY(0, remove_begin($3), 0, &loc), 0, &@$); /*% $$ = dispatch2(rescue_mod, $1, $3); %*/ @@ -2563,10 +2563,10 @@ primary : literal $$ = NEW_NIL(&@$); } else { - set_line_body($3, @1.last_loc.lineno); + set_line_body($3, @1.end_pos.lineno); $$ = NEW_BEGIN($3, &@$); } - nd_set_line($$, @1.last_loc.lineno); + nd_set_line($$, @1.end_pos.lineno); /*% $$ = dispatch1(begin, $3); %*/ @@ -2822,8 +2822,8 @@ primary : literal | k_class cpath superclass { if (in_def) { - YYLTYPE cr = code_range_gen(&@1, &@2); - yyerror1(&cr, "class definition in method body"); + YYLTYPE loc = code_loc_gen(&@1, &@2); + yyerror1(&loc, "class definition in method body"); } $1 = in_class; in_class = 1; @@ -2834,9 +2834,9 @@ primary : literal { /*%%%*/ $$ = NEW_CLASS($2, $5, $3, &@$); - nd_set_line($$->nd_body, @6.last_loc.lineno); - set_line_body($5, @3.last_loc.lineno); - nd_set_line($$, @3.last_loc.lineno); + nd_set_line($$->nd_body, @6.end_pos.lineno); + set_line_body($5, @3.end_pos.lineno); + nd_set_line($$, @3.end_pos.lineno); /*% $$ = dispatch3(class, $2, $3, $5); %*/ @@ -2856,7 +2856,7 @@ primary : literal { /*%%%*/ $$ = NEW_SCLASS($3, $6, &@$); - nd_set_line($$->nd_body, @7.last_loc.lineno); + nd_set_line($$->nd_body, @7.end_pos.lineno); set_line_body($6, nd_line($3)); fixpos($$, $3); /*% @@ -2869,8 +2869,8 @@ primary : literal | k_module cpath { if (in_def) { - YYLTYPE cr = code_range_gen(&@1, &@2); - yyerror1(&cr, "module definition in method body"); + YYLTYPE loc = code_loc_gen(&@1, &@2); + yyerror1(&loc, "module definition in method body"); } $1 = in_class; in_class = 1; @@ -2881,9 +2881,9 @@ primary : literal { /*%%%*/ $$ = NEW_MODULE($2, $4, &@$); - nd_set_line($$->nd_body, @5.last_loc.lineno); - set_line_body($4, @2.last_loc.lineno); - nd_set_line($$, @2.last_loc.lineno); + nd_set_line($$->nd_body, @5.end_pos.lineno); + set_line_body($4, @2.end_pos.lineno); + nd_set_line($$, @2.end_pos.lineno); /*% $$ = dispatch2(module, $2, $4); %*/ @@ -2908,8 +2908,8 @@ primary : literal NODE *body = remove_begin($6); reduce_nodes(&body); $$ = NEW_DEFN($2, $5, body, &@$); - nd_set_line($$->nd_defn, @7.last_loc.lineno); - set_line_body(body, @1.first_loc.lineno); + nd_set_line($$->nd_defn, @7.end_pos.lineno); + set_line_body(body, @1.beg_pos.lineno); /*% $$ = dispatch3(def, $2, $5, $6); %*/ @@ -2934,8 +2934,8 @@ primary : literal NODE *body = remove_begin($8); reduce_nodes(&body); $$ = NEW_DEFS($2, $5, $7, body, &@$); - nd_set_line($$->nd_defn, @9.last_loc.lineno); - set_line_body(body, @1.first_loc.lineno); + nd_set_line($$->nd_defn, @9.end_pos.lineno); + set_line_body(body, @1.beg_pos.lineno); /*% $$ = dispatch5(defs, $2, $3, $5, $7, $8); %*/ @@ -3425,8 +3425,8 @@ lambda : { CMDARG_LEXPOP(); /*%%%*/ $$ = NEW_LAMBDA($3, $5, &@$); - nd_set_line($$->nd_body, @5.last_loc.lineno); - nd_set_line($$, @3.last_loc.lineno); + nd_set_line($$->nd_body, @5.end_pos.lineno); + nd_set_line($$, @3.end_pos.lineno); /*% $$ = dispatch2(lambda, $3, $5); %*/ @@ -3463,8 +3463,8 @@ do_block : keyword_do_block do_body keyword_end { $$ = $2; /*%%%*/ - $$->nd_body->nd_crange = code_range_gen(&@1, &@3); - nd_set_line($$, @1.last_loc.lineno); + $$->nd_body->nd_loc = code_loc_gen(&@1, &@3); + nd_set_line($$, @1.end_pos.lineno); /*% %*/ } ; @@ -3519,7 +3519,7 @@ method_call : fcall paren_args /*%%%*/ $$ = $1; $$->nd_args = $2; - nd_set_last_loc($1, @2.last_loc); + nd_set_last_loc($1, @2.end_pos); /*% $$ = method_arg(dispatch1(fcall, $1), $2); %*/ @@ -3527,12 +3527,12 @@ method_call : fcall paren_args | primary_value call_op operation2 opt_paren_args { $$ = new_qcall($2, $1, $3, $4, &@3, &@$); - nd_set_line($$, @3.last_loc.lineno); + nd_set_line($$, @3.end_pos.lineno); } | primary_value tCOLON2 operation2 paren_args { $$ = new_qcall(ID2VAL(idCOLON2), $1, $3, $4, &@3, &@$); - nd_set_line($$, @3.last_loc.lineno); + nd_set_line($$, @3.end_pos.lineno); } | primary_value tCOLON2 operation3 { @@ -3541,12 +3541,12 @@ method_call : fcall paren_args | primary_value call_op paren_args { $$ = new_qcall($2, $1, ID2VAL(idCall), $3, &@2, &@$); - nd_set_line($$, @2.last_loc.lineno); + nd_set_line($$, @2.end_pos.lineno); } | primary_value tCOLON2 paren_args { $$ = new_qcall(ID2VAL(idCOLON2), $1, ID2VAL(idCall), $3, &@2, &@$); - nd_set_line($$, @2.last_loc.lineno); + nd_set_line($$, @2.end_pos.lineno); } | keyword_super paren_args { @@ -3582,16 +3582,16 @@ brace_block : '{' brace_body '}' { $$ = $2; /*%%%*/ - $$->nd_body->nd_crange = code_range_gen(&@1, &@3); - nd_set_line($$, @1.last_loc.lineno); + $$->nd_body->nd_loc = code_loc_gen(&@1, &@3); + nd_set_line($$, @1.end_pos.lineno); /*% %*/ } | keyword_do do_body keyword_end { $$ = $2; /*%%%*/ - $$->nd_body->nd_crange = code_range_gen(&@1, &@3); - nd_set_line($$, @1.last_loc.lineno); + $$->nd_body->nd_loc = code_loc_gen(&@1, &@3); + nd_set_line($$, @1.end_pos.lineno); /*% %*/ } ; @@ -3724,7 +3724,7 @@ strings : string string : tCHAR { /*%%%*/ - nd_set_crange($$, &@$); + nd_set_loc($$, &@$); /*% %*/ } @@ -3743,7 +3743,7 @@ string1 : tSTRING_BEG string_contents tSTRING_END { $$ = new_string1(heredoc_dedent($2)); /*%%%*/ - if ($$) nd_set_crange($$, &@$); + if ($$) nd_set_loc($$, &@$); /*% %*/ } @@ -3874,7 +3874,7 @@ qword_list : /* none */ | qword_list tSTRING_CONTENT ' ' { /*%%%*/ - nd_set_crange($2, &@2); + nd_set_loc($2, &@2); $$ = list_append($1, $2); /*% $$ = dispatch2(qwords_add, $1, $2); @@ -3897,7 +3897,7 @@ qsym_list : /* none */ lit = $2->nd_lit; nd_set_type($2, NODE_LIT); add_mark_object($2->nd_lit = ID2SYM(rb_intern_str(lit))); - nd_set_crange($2, &@2); + nd_set_loc($2, &@2); $$ = list_append($1, $2); /*% $$ = dispatch2(qsymbols_add, $1, $2); @@ -3993,7 +3993,7 @@ regexp_contents: /* none */ string_content : tSTRING_CONTENT { /*%%%*/ - nd_set_crange($$, &@$); + nd_set_loc($$, &@$); /*% %*/ } @@ -4009,7 +4009,7 @@ string_content : tSTRING_CONTENT lex_strterm = $2; /*%%%*/ $$ = NEW_EVSTR($3, &@$); - nd_set_line($$, @3.last_loc.lineno); + nd_set_line($$, @3.end_pos.lineno); /*% $$ = dispatch1(string_dvar, $3); %*/ @@ -4126,28 +4126,28 @@ numeric : simple_numeric simple_numeric : tINTEGER { /*%%%*/ - nd_set_crange($$, &@$); + nd_set_loc($$, &@$); /*% %*/ } | tFLOAT { /*%%%*/ - nd_set_crange($$, &@$); + nd_set_loc($$, &@$); /*% %*/ } | tRATIONAL { /*%%%*/ - nd_set_crange($$, &@$); + nd_set_loc($$, &@$); /*% %*/ } | tIMAGINARY { /*%%%*/ - nd_set_crange($$, &@$); + nd_set_loc($$, &@$); /*% %*/ } @@ -4205,14 +4205,14 @@ var_lhs : user_variable backref : tNTH_REF { /*%%%*/ - nd_set_crange($$, &@$); + nd_set_loc($$, &@$); /*% %*/ } | tBACK_REF { /*%%%*/ - nd_set_crange($$, &@$); + nd_set_loc($$, &@$); /*% %*/ } @@ -4424,18 +4424,18 @@ f_arg_item : f_arg_asgn { ID tid = internal_id(); /*%%%*/ - YYLTYPE cr; - cr.first_loc = @2.first_loc; - cr.last_loc = @2.first_loc; + YYLTYPE loc; + loc.beg_pos = @2.beg_pos; + loc.end_pos = @2.beg_pos; /*% %*/ arg_var(tid); /*%%%*/ if (dyna_in_block()) { - $2->nd_value = NEW_DVAR(tid, &cr); + $2->nd_value = NEW_DVAR(tid, &loc); } else { - $2->nd_value = NEW_LVAR(tid, &cr); + $2->nd_value = NEW_LVAR(tid, &loc); } $$ = NEW_ARGS_AUX(tid, 1, &NULL_LOC); $$->nd_next = $2; @@ -4806,8 +4806,8 @@ assoc : arg_value tASSOC arg_value | tSTRING_BEG string_contents tLABEL_END arg_value { /*%%%*/ - YYLTYPE cr = code_range_gen(&@1, &@3); - $$ = list_append(NEW_LIST(dsym_node($2, &cr), &cr), $4); + YYLTYPE loc = code_loc_gen(&@1, &@3); + $$ = list_append(NEW_LIST(dsym_node($2, &loc), &loc), $4); /*% $$ = dispatch2(assoc_new, dispatch1(dyna_symbol, $2), $4); %*/ @@ -5115,10 +5115,10 @@ parser_yyerror(struct parser_params *parser, const YYLTYPE *yylloc, const char * RUBY_SET_YYLLOC(current); yylloc = ¤t; } - else if ((ruby_sourceline != yylloc->first_loc.lineno && - ruby_sourceline != yylloc->last_loc.lineno) || - (yylloc->first_loc.lineno == yylloc->last_loc.lineno && - yylloc->first_loc.column == yylloc->last_loc.column)) { + else if ((ruby_sourceline != yylloc->beg_pos.lineno && + ruby_sourceline != yylloc->end_pos.lineno) || + (yylloc->beg_pos.lineno == yylloc->end_pos.lineno && + yylloc->beg_pos.column == yylloc->end_pos.column)) { compile_error(PARSER_ARG "%s", msg); return 0; } @@ -5128,8 +5128,8 @@ parser_yyerror(struct parser_params *parser, const YYLTYPE *yylloc, const char * if (--pend > lex_pbeg && pend[-1] == '\r') --pend; } - pt = (ruby_sourceline == yylloc->last_loc.lineno) ? - lex_pbeg + yylloc->last_loc.column : lex_pend; + pt = (ruby_sourceline == yylloc->end_pos.lineno) ? + lex_pbeg + yylloc->end_pos.column : lex_pend; p = pe = pt < pend ? pt : pend; lim = p - lex_pbeg > max_line_margin ? p - max_line_margin : lex_pbeg; while ((lim < p) && (*(p-1) != '\n')) p--; @@ -5149,12 +5149,12 @@ parser_yyerror(struct parser_params *parser, const YYLTYPE *yylloc, const char * } } pb = lex_pbeg; - if (ruby_sourceline == yylloc->first_loc.lineno) { - pb += yylloc->first_loc.column; + if (ruby_sourceline == yylloc->beg_pos.lineno) { + pb += yylloc->beg_pos.column; if (pb > pt) pb = pt; } if (pb < p) pb = p; - if (len <= 4 && yylloc->first_loc.lineno == yylloc->last_loc.lineno) { + if (len <= 4 && yylloc->beg_pos.lineno == yylloc->end_pos.lineno) { compile_error(PARSER_ARG "%s", msg); } else if (!parser->error_buffer && rb_stderr_tty_p()) { @@ -8717,21 +8717,21 @@ yylex(YYSTYPE *lval, YYLTYPE *yylloc, struct parser_params *parser) #define LVAR_USED ((ID)1 << (sizeof(ID) * CHAR_BIT - 1)) static NODE* -node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE a1, VALUE a2, const rb_code_range_t *cr) +node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE a1, VALUE a2, const rb_code_location_t *loc) { NODE *n = rb_ast_newnode(parser->ast); rb_node_init(n, type, a0, a1, a2); - nd_set_crange(n, cr); + nd_set_loc(n, loc); return n; } static NODE * -nd_set_crange(NODE *nd, const YYLTYPE *cr) +nd_set_loc(NODE *nd, const YYLTYPE *loc) { - nd->nd_crange = *cr; - nd_set_line(nd, cr->first_loc.lineno); + nd->nd_loc = *loc; + nd_set_line(nd, loc->beg_pos.lineno); return nd; } @@ -8798,7 +8798,7 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail) parser_warning(h, "unused literal ignored"); return tail; default: - h = end = NEW_BLOCK(head, &head->nd_crange); + h = end = NEW_BLOCK(head, &head->nd_loc); end->nd_end = end; head = end; break; @@ -8824,7 +8824,7 @@ block_append_gen(struct parser_params *parser, NODE *head, NODE *tail) } if (nd_type(tail) != NODE_BLOCK) { - tail = NEW_BLOCK(tail, &tail->nd_crange); + tail = NEW_BLOCK(tail, &tail->nd_loc); tail->nd_end = tail; } end->nd_next = tail; @@ -8839,7 +8839,7 @@ list_append_gen(struct parser_params *parser, NODE *list, NODE *item) { NODE *last; - if (list == 0) return NEW_LIST(item, &item->nd_crange); + if (list == 0) return NEW_LIST(item, &item->nd_loc); if (list->nd_next) { last = list->nd_next->nd_end; } @@ -8848,7 +8848,7 @@ list_append_gen(struct parser_params *parser, NODE *list, NODE *item) } list->nd_alen += 1; - last->nd_next = NEW_LIST(item, &item->nd_crange); + last->nd_next = NEW_LIST(item, &item->nd_loc); list->nd_next->nd_end = last->nd_next; nd_set_last_loc(list, nd_last_loc(item)); @@ -8901,7 +8901,7 @@ literal_concat0(struct parser_params *parser, VALUE head, VALUE tail) /* concat two string literals */ static NODE * -literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, const YYLTYPE *cr) +literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, const YYLTYPE *loc) { enum node_type htype; NODE *headlast; @@ -8912,7 +8912,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, const Y htype = nd_type(head); if (htype == NODE_EVSTR) { - NODE *node = NEW_DSTR(add_mark_object(STR_NEW0()), cr); + NODE *node = NEW_DSTR(add_mark_object(STR_NEW0()), loc); head = list_append(node, head); htype = NODE_DSTR; } @@ -8975,7 +8975,7 @@ literal_concat_gen(struct parser_params *parser, NODE *head, NODE *tail, const Y } else { nd_set_type(tail, NODE_ARRAY); - tail->nd_head = NEW_STR(tail->nd_lit, cr); + tail->nd_head = NEW_STR(tail->nd_lit, loc); list_concat(head, tail); } break; @@ -8995,13 +8995,13 @@ static NODE * evstr2dstr_gen(struct parser_params *parser, NODE *node) { if (nd_type(node) == NODE_EVSTR) { - node = list_append(NEW_DSTR(add_mark_object(STR_NEW0()), &node->nd_crange), node); + node = list_append(NEW_DSTR(add_mark_object(STR_NEW0()), &node->nd_loc), node); } return node; } static NODE * -new_evstr_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr) +new_evstr_gen(struct parser_params *parser, NODE *node, const YYLTYPE *loc) { NODE *head = node; @@ -9011,45 +9011,45 @@ new_evstr_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr) return node; } } - return NEW_EVSTR(head, cr); + return NEW_EVSTR(head, loc); } static NODE * call_bin_op_gen(struct parser_params *parser, NODE *recv, ID id, NODE *arg1, - const YYLTYPE *op_cr, const YYLTYPE *cr) + const YYLTYPE *op_loc, const YYLTYPE *loc) { NODE *expr; value_expr(recv); value_expr(arg1); - expr = NEW_OPCALL(recv, id, NEW_LIST(arg1, &arg1->nd_crange), cr); - nd_set_line(expr, op_cr->first_loc.lineno); + expr = NEW_OPCALL(recv, id, NEW_LIST(arg1, &arg1->nd_loc), loc); + nd_set_line(expr, op_loc->beg_pos.lineno); return expr; } static NODE * -call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id, const YYLTYPE *op_cr, const YYLTYPE *cr) +call_uni_op_gen(struct parser_params *parser, NODE *recv, ID id, const YYLTYPE *op_loc, const YYLTYPE *loc) { NODE *opcall; value_expr(recv); - opcall = NEW_OPCALL(recv, id, 0, cr); - nd_set_line(opcall, op_cr->first_loc.lineno); + opcall = NEW_OPCALL(recv, id, 0, loc); + nd_set_line(opcall, op_loc->beg_pos.lineno); return opcall; } static NODE * -new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_cr, const YYLTYPE *cr) +new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, const YYLTYPE *op_loc, const YYLTYPE *loc) { - NODE *qcall = NEW_QCALL(atype, recv, mid, args, cr); - nd_set_line(qcall, op_cr->first_loc.lineno); + NODE *qcall = NEW_QCALL(atype, recv, mid, args, loc); + nd_set_line(qcall, op_loc->beg_pos.lineno); return qcall; } #define nd_once_body(node) (nd_type(node) == NODE_ONCE ? (node)->nd_body : node) static NODE* -match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *op_cr, const YYLTYPE *cr) +match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *op_loc, const YYLTYPE *loc) { NODE *n; - int line = op_cr->first_loc.lineno; + int line = op_loc->beg_pos.lineno; value_expr(node1); value_expr(node2); @@ -9057,7 +9057,7 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTY switch (nd_type(n)) { case NODE_DREGX: { - NODE *match = NEW_MATCH2(node1, node2, cr); + NODE *match = NEW_MATCH2(node1, node2, loc); nd_set_line(match, line); return match; } @@ -9065,8 +9065,8 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTY case NODE_LIT: if (RB_TYPE_P(n->nd_lit, T_REGEXP)) { const VALUE lit = n->nd_lit; - NODE *match = NEW_MATCH2(node1, node2, cr); - match->nd_args = reg_named_capture_assign(lit, cr); + NODE *match = NEW_MATCH2(node1, node2, loc); + match->nd_args = reg_named_capture_assign(lit, loc); nd_set_line(match, line); return match; } @@ -9081,12 +9081,12 @@ match_op_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTY if (!RB_TYPE_P(n->nd_lit, T_REGEXP)) break; /* fallthru */ case NODE_DREGX: - match3 = NEW_MATCH3(node2, node1, cr); + match3 = NEW_MATCH3(node2, node1, loc); return match3; } } - n = NEW_CALL(node1, tMATCH, NEW_LIST(node2, &node2->nd_crange), cr); + n = NEW_CALL(node1, tMATCH, NEW_LIST(node2, &node2->nd_loc), loc); nd_set_line(n, line); return n; } @@ -9112,28 +9112,28 @@ past_dvar_p(struct parser_params *parser, ID id) } while (0) static NODE* -gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *cr) +gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *loc) { ID *vidp = NULL; NODE *node; switch (id) { case keyword_self: - return NEW_SELF(cr); + return NEW_SELF(loc); case keyword_nil: - return NEW_NIL(cr); + return NEW_NIL(loc); case keyword_true: - return NEW_TRUE(cr); + return NEW_TRUE(loc); case keyword_false: - return NEW_FALSE(cr); + return NEW_FALSE(loc); case keyword__FILE__: WARN_LOCATION("__FILE__"); - node = NEW_STR(add_mark_object(rb_str_dup(ruby_sourcefile_string)), cr); + node = NEW_STR(add_mark_object(rb_str_dup(ruby_sourcefile_string)), loc); return node; case keyword__LINE__: WARN_LOCATION("__LINE__"); - return NEW_LIT(INT2FIX(tokline), cr); + return NEW_LIT(INT2FIX(tokline), loc); case keyword__ENCODING__: - return NEW_LIT(add_mark_object(rb_enc_from_encoding(current_enc)), cr); + return NEW_LIT(add_mark_object(rb_enc_from_encoding(current_enc)), loc); } switch (id_type(id)) { case ID_LOCAL: @@ -9142,7 +9142,7 @@ gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *cr) rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id)); } if (vidp) *vidp |= LVAR_USED; - node = NEW_DVAR(id, cr); + node = NEW_DVAR(id, loc); return node; } if (local_id_ref(id, vidp)) { @@ -9150,7 +9150,7 @@ gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *cr) rb_warn1("circular argument reference - %"PRIsWARN, rb_id2str(id)); } if (vidp) *vidp |= LVAR_USED; - node = NEW_LVAR(id, cr); + node = NEW_LVAR(id, loc); return node; } # if WARN_PAST_SCOPE @@ -9159,15 +9159,15 @@ gettable_gen(struct parser_params *parser, ID id, const YYLTYPE *cr) } # endif /* method call without arguments */ - return NEW_VCALL(id, cr); + return NEW_VCALL(id, loc); case ID_GLOBAL: - return NEW_GVAR(id, cr); + return NEW_GVAR(id, loc); case ID_INSTANCE: - return NEW_IVAR(id, cr); + return NEW_IVAR(id, loc); case ID_CONST: - return NEW_CONST(id, cr); + return NEW_CONST(id, loc); case ID_CLASS: - return NEW_CVAR(id, cr); + return NEW_CVAR(id, loc); } compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to get", rb_id2str(id)); return 0; @@ -9177,11 +9177,11 @@ static NODE * opt_arg_append(NODE *opt_list, NODE *opt) { NODE *opts = opt_list; - opts->nd_crange.last_loc = opt->nd_crange.last_loc; + opts->nd_loc.end_pos = opt->nd_loc.end_pos; while (opts->nd_next) { opts = opts->nd_next; - opts->nd_crange.last_loc = opt->nd_crange.last_loc; + opts->nd_loc.end_pos = opt->nd_loc.end_pos; } opts->nd_next = opt; @@ -9193,10 +9193,10 @@ kwd_append(NODE *kwlist, NODE *kw) { if (kwlist) { NODE *kws = kwlist; - kws->nd_crange.last_loc = kw->nd_crange.last_loc; + kws->nd_loc.end_pos = kw->nd_loc.end_pos; while (kws->nd_next) { kws = kws->nd_next; - kws->nd_crange.last_loc = kw->nd_crange.last_loc; + kws->nd_loc.end_pos = kw->nd_loc.end_pos; } kws->nd_next = kw; } @@ -9204,35 +9204,35 @@ kwd_append(NODE *kwlist, NODE *kw) } static NODE * -new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *cr) +new_defined_gen(struct parser_params *parser, NODE *expr, const YYLTYPE *loc) { - return NEW_DEFINED(remove_begin_all(expr), cr); + return NEW_DEFINED(remove_begin_all(expr), loc); } static NODE * -new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLTYPE *cr) +new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLTYPE *loc) { NODE *list, *prev; VALUE lit; if (!node) { - return NEW_LIT(add_mark_object(reg_compile(STR_NEW0(), options)), cr); + return NEW_LIT(add_mark_object(reg_compile(STR_NEW0(), options)), loc); } switch (nd_type(node)) { case NODE_STR: { VALUE src = node->nd_lit; nd_set_type(node, NODE_LIT); - nd_set_crange(node, cr); + nd_set_loc(node, loc); add_mark_object(node->nd_lit = reg_compile(src, options)); } break; default: add_mark_object(lit = STR_NEW0()); - node = NEW_NODE(NODE_DSTR, lit, 1, NEW_LIST(node, cr), cr); + node = NEW_NODE(NODE_DSTR, lit, 1, NEW_LIST(node, loc), loc); case NODE_DSTR: nd_set_type(node, NODE_DREGX); - nd_set_crange(node, cr); + nd_set_loc(node, loc); node->nd_cflag = options & RE_OPTION_MASK; if (!NIL_P(node->nd_lit)) reg_fragment_check(node->nd_lit, options); for (list = (prev = node)->nd_next; list; list = list->nd_next) { @@ -9264,7 +9264,7 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLT add_mark_object(node->nd_lit = reg_compile(src, options)); } if (options & RE_OPTION_ONCE) { - node = NEW_NODE(NODE_ONCE, 0, node, 0, cr); + node = NEW_NODE(NODE_ONCE, 0, node, 0, loc); } break; } @@ -9272,41 +9272,41 @@ new_regexp_gen(struct parser_params *parser, NODE *node, int options, const YYLT } static NODE * -new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *cr) +new_kw_arg_gen(struct parser_params *parser, NODE *k, const YYLTYPE *loc) { if (!k) return 0; - return NEW_KW_ARG(0, (k), cr); + return NEW_KW_ARG(0, (k), loc); } static NODE * -new_xstring_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr) +new_xstring_gen(struct parser_params *parser, NODE *node, const YYLTYPE *loc) { if (!node) { VALUE lit = STR_NEW0(); - NODE *xstr = NEW_XSTR(lit, cr); + NODE *xstr = NEW_XSTR(lit, loc); add_mark_object(lit); return xstr; } switch (nd_type(node)) { case NODE_STR: nd_set_type(node, NODE_XSTR); - nd_set_crange(node, cr); + nd_set_loc(node, loc); break; case NODE_DSTR: nd_set_type(node, NODE_DXSTR); - nd_set_crange(node, cr); + nd_set_loc(node, loc); break; default: - node = NEW_NODE(NODE_DXSTR, Qnil, 1, NEW_LIST(node, cr), cr); + node = NEW_NODE(NODE_DXSTR, Qnil, 1, NEW_LIST(node, loc), loc); break; } return node; } static NODE * -new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *cr) +new_body_gen(struct parser_params *parser, NODE *param, NODE *stmt, const YYLTYPE *loc) { - return NEW_ITER(param, stmt, cr); + return NEW_ITER(param, stmt, loc); } #else /* !RIPPER */ static int @@ -9471,33 +9471,33 @@ rb_parser_fatal(struct parser_params *parser, const char *fmt, ...) } void -rb_parser_set_code_range_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc) +rb_parser_set_location_from_strterm_heredoc(struct parser_params *parser, rb_strterm_heredoc_t *here, YYLTYPE *yylloc) { const char *eos = RSTRING_PTR(here->term); int term_len = (int)eos[0]; - yylloc->first_loc.lineno = (int)here->sourceline; - yylloc->first_loc.column = (int)(here->u3.lastidx - term_len); - yylloc->last_loc.lineno = (int)here->sourceline; - yylloc->last_loc.column = (int)(here->u3.lastidx); + yylloc->beg_pos.lineno = (int)here->sourceline; + yylloc->beg_pos.column = (int)(here->u3.lastidx - term_len); + yylloc->end_pos.lineno = (int)here->sourceline; + yylloc->end_pos.column = (int)(here->u3.lastidx); } void -rb_parser_set_code_range_of_none(struct parser_params *parser, YYLTYPE *yylloc) +rb_parser_set_location_of_none(struct parser_params *parser, YYLTYPE *yylloc) { - yylloc->first_loc.lineno = ruby_sourceline; - yylloc->first_loc.column = (int)(parser->tokp - lex_pbeg); - yylloc->last_loc.lineno = ruby_sourceline; - yylloc->last_loc.column = (int)(parser->tokp - lex_pbeg); + yylloc->beg_pos.lineno = ruby_sourceline; + yylloc->beg_pos.column = (int)(parser->tokp - lex_pbeg); + yylloc->end_pos.lineno = ruby_sourceline; + yylloc->end_pos.column = (int)(parser->tokp - lex_pbeg); } void -rb_parser_set_code_range(struct parser_params *parser, YYLTYPE *yylloc) +rb_parser_set_location(struct parser_params *parser, YYLTYPE *yylloc) { - yylloc->first_loc.lineno = ruby_sourceline; - yylloc->first_loc.column = (int)(parser->tokp - lex_pbeg); - yylloc->last_loc.lineno = ruby_sourceline; - yylloc->last_loc.column = (int)(lex_p - lex_pbeg); + yylloc->beg_pos.lineno = ruby_sourceline; + yylloc->beg_pos.column = (int)(parser->tokp - lex_pbeg); + yylloc->end_pos.lineno = ruby_sourceline; + yylloc->end_pos.column = (int)(lex_p - lex_pbeg); } #endif /* !RIPPER */ @@ -9506,77 +9506,77 @@ static VALUE assignable_gen(struct parser_params *parser, VALUE lhs) #else static NODE* -assignable_gen(struct parser_params *parser, ID id, NODE *val, const YYLTYPE *cr) +assignable_gen(struct parser_params *parser, ID id, NODE *val, const YYLTYPE *loc) #endif { #ifdef RIPPER ID id = get_id(lhs); # define assignable_result(x) (lhs) # define assignable_error() (lhs) -# define parser_yyerror(parser, cr, x) (lhs = assign_error_gen(parser, lhs)) +# define parser_yyerror(parser, loc, x) (lhs = assign_error_gen(parser, lhs)) #else # define assignable_result(x) (x) -# define assignable_error() NEW_BEGIN(0, cr) +# define assignable_error() NEW_BEGIN(0, loc) #endif if (!id) return assignable_error(); switch (id) { case keyword_self: - yyerror1(cr, "Can't change the value of self"); + yyerror1(loc, "Can't change the value of self"); goto error; case keyword_nil: - yyerror1(cr, "Can't assign to nil"); + yyerror1(loc, "Can't assign to nil"); goto error; case keyword_true: - yyerror1(cr, "Can't assign to true"); + yyerror1(loc, "Can't assign to true"); goto error; case keyword_false: - yyerror1(cr, "Can't assign to false"); + yyerror1(loc, "Can't assign to false"); goto error; case keyword__FILE__: - yyerror1(cr, "Can't assign to __FILE__"); + yyerror1(loc, "Can't assign to __FILE__"); goto error; case keyword__LINE__: - yyerror1(cr, "Can't assign to __LINE__"); + yyerror1(loc, "Can't assign to __LINE__"); goto error; case keyword__ENCODING__: - yyerror1(cr, "Can't assign to __ENCODING__"); + yyerror1(loc, "Can't assign to __ENCODING__"); goto error; } switch (id_type(id)) { case ID_LOCAL: if (dyna_in_block()) { if (dvar_curr(id)) { - return assignable_result(NEW_DASGN_CURR(id, val, cr)); + return assignable_result(NEW_DASGN_CURR(id, val, loc)); } else if (dvar_defined(id)) { - return assignable_result(NEW_DASGN(id, val, cr)); + return assignable_result(NEW_DASGN(id, val, loc)); } else if (local_id(id)) { - return assignable_result(NEW_LASGN(id, val, cr)); + return assignable_result(NEW_LASGN(id, val, loc)); } else { dyna_var(id); - return assignable_result(NEW_DASGN_CURR(id, val, cr)); + return assignable_result(NEW_DASGN_CURR(id, val, loc)); } } else { if (!local_id(id)) { local_var(id); } - return assignable_result(NEW_LASGN(id, val, cr)); + return assignable_result(NEW_LASGN(id, val, loc)); } break; case ID_GLOBAL: - return assignable_result(NEW_GASGN(id, val, cr)); + return assignable_result(NEW_GASGN(id, val, loc)); case ID_INSTANCE: - return assignable_result(NEW_IASGN(id, val, cr)); + return assignable_result(NEW_IASGN(id, val, loc)); case ID_CONST: if (!in_def) - return assignable_result(NEW_CDECL(id, val, 0, cr)); - yyerror1(cr, "dynamic constant assignment"); + return assignable_result(NEW_CDECL(id, val, 0, loc)); + yyerror1(loc, "dynamic constant assignment"); break; case ID_CLASS: - return assignable_result(NEW_CVASGN(id, val, cr)); + return assignable_result(NEW_CVASGN(id, val, loc)); default: compile_error(PARSER_ARG "identifier %"PRIsVALUE" is not valid to set", rb_id2str(id)); } @@ -9644,9 +9644,9 @@ new_bv_gen(struct parser_params *parser, ID name) #ifndef RIPPER static NODE * -aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx, const YYLTYPE *cr) +aryset_gen(struct parser_params *parser, NODE *recv, NODE *idx, const YYLTYPE *loc) { - return NEW_ATTRASGN(recv, tASET, idx, cr); + return NEW_ATTRASGN(recv, tASET, idx, loc); } static void @@ -9658,10 +9658,10 @@ block_dup_check_gen(struct parser_params *parser, NODE *node1, NODE *node2) } static NODE * -attrset_gen(struct parser_params *parser, NODE *recv, ID atype, ID id, const YYLTYPE *cr) +attrset_gen(struct parser_params *parser, NODE *recv, ID atype, ID id, const YYLTYPE *loc) { if (!CALL_Q_P(atype)) id = rb_id_attrset(id); - return NEW_ATTRASGN(recv, id, 0, cr); + return NEW_ATTRASGN(recv, id, 0, loc); } static void @@ -9678,19 +9678,19 @@ rb_backref_error_gen(struct parser_params *parser, NODE *node) } static NODE * -arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *cr) +arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *loc) { if (!node2) return node1; switch (nd_type(node1)) { case NODE_BLOCK_PASS: if (node1->nd_head) - node1->nd_head = arg_concat(node1->nd_head, node2, cr); + node1->nd_head = arg_concat(node1->nd_head, node2, loc); else - node1->nd_head = NEW_LIST(node2, cr); + node1->nd_head = NEW_LIST(node2, loc); return node1; case NODE_ARGSPUSH: if (nd_type(node2) != NODE_ARRAY) break; - node1->nd_body = list_concat(NEW_LIST(node1->nd_body, cr), node2); + node1->nd_body = list_concat(NEW_LIST(node1->nd_body, loc), node2); nd_set_type(node1, NODE_ARGSCAT); return node1; case NODE_ARGSCAT: @@ -9699,27 +9699,27 @@ arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYL node1->nd_body = list_concat(node1->nd_body, node2); return node1; } - return NEW_ARGSCAT(node1, node2, cr); + return NEW_ARGSCAT(node1, node2, loc); } static NODE * -arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *cr) +arg_append_gen(struct parser_params *parser, NODE *node1, NODE *node2, const YYLTYPE *loc) { - if (!node1) return NEW_LIST(node2, &node2->nd_crange); + if (!node1) return NEW_LIST(node2, &node2->nd_loc); switch (nd_type(node1)) { case NODE_ARRAY: return list_append(node1, node2); case NODE_BLOCK_PASS: - node1->nd_head = arg_append(node1->nd_head, node2, cr); - node1->nd_crange.last_loc = node1->nd_head->nd_crange.last_loc; + node1->nd_head = arg_append(node1->nd_head, node2, loc); + node1->nd_loc.end_pos = node1->nd_head->nd_loc.end_pos; return node1; case NODE_ARGSPUSH: - node1->nd_body = list_append(NEW_LIST(node1->nd_body, &node1->nd_body->nd_crange), node2); - node1->nd_crange.last_loc = node1->nd_body->nd_crange.last_loc; + node1->nd_body = list_append(NEW_LIST(node1->nd_body, &node1->nd_body->nd_loc), node2); + node1->nd_loc.end_pos = node1->nd_body->nd_loc.end_pos; nd_set_type(node1, NODE_ARGSCAT); return node1; } - return NEW_ARGSPUSH(node1, node2, cr); + return NEW_ARGSPUSH(node1, node2, loc); } static NODE * @@ -9758,7 +9758,7 @@ mark_lvar_used(struct parser_params *parser, NODE *rhs) } static NODE * -node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, const YYLTYPE *cr) +node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, const YYLTYPE *loc) { if (!lhs) return 0; @@ -9772,12 +9772,12 @@ node_assign_gen(struct parser_params *parser, NODE *lhs, NODE *rhs, const YYLTYP case NODE_CDECL: case NODE_CVASGN: lhs->nd_value = rhs; - nd_set_crange(lhs, cr); + nd_set_loc(lhs, loc); break; case NODE_ATTRASGN: - lhs->nd_args = arg_append(lhs->nd_args, rhs, cr); - nd_set_crange(lhs, cr); + lhs->nd_args = arg_append(lhs->nd_args, rhs, loc); + nd_set_loc(lhs, loc); break; default: @@ -9803,7 +9803,7 @@ value_expr_gen(struct parser_params *parser, NODE *node) case NODE_NEXT: case NODE_REDO: case NODE_RETRY: - if (!cond) yyerror1(&node->nd_crange, "void value expression"); + if (!cond) yyerror1(&node->nd_loc, "void value expression"); /* or "control never reach"? */ return FALSE; @@ -10096,7 +10096,7 @@ warning_unless_e_option(struct parser_params *parser, NODE *node, const char *st static NODE *cond0(struct parser_params*,NODE*,int,const YYLTYPE*); static NODE* -range_op(struct parser_params *parser, NODE *node, const YYLTYPE *cr) +range_op(struct parser_params *parser, NODE *node, const YYLTYPE *loc) { enum node_type type; @@ -10106,9 +10106,9 @@ range_op(struct parser_params *parser, NODE *node, const YYLTYPE *cr) value_expr(node); if (type == NODE_LIT && FIXNUM_P(node->nd_lit)) { warn_unless_e_option(parser, node, "integer literal in conditional range"); - return NEW_CALL(node, tEQ, NEW_LIST(NEW_GVAR(rb_intern("$."), cr), cr), cr); + return NEW_CALL(node, tEQ, NEW_LIST(NEW_GVAR(rb_intern("$."), loc), loc), loc); } - return cond0(parser, node, FALSE, cr); + return cond0(parser, node, FALSE, loc); } static int @@ -10133,7 +10133,7 @@ literal_node(NODE *node) } static NODE* -cond0(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *cr) +cond0(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *loc) { if (node == 0) return 0; if (!(node = nd_once_body(node))) return 0; @@ -10151,19 +10151,19 @@ cond0(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *cr if (!method_op) warning_unless_e_option(parser, node, "regex literal in condition"); - return NEW_MATCH2(node, NEW_GVAR(idLASTLINE, cr), cr); + return NEW_MATCH2(node, NEW_GVAR(idLASTLINE, loc), loc); } case NODE_AND: case NODE_OR: - node->nd_1st = cond0(parser, node->nd_1st, FALSE, cr); - node->nd_2nd = cond0(parser, node->nd_2nd, FALSE, cr); + node->nd_1st = cond0(parser, node->nd_1st, FALSE, loc); + node->nd_2nd = cond0(parser, node->nd_2nd, FALSE, loc); break; case NODE_DOT2: case NODE_DOT3: - node->nd_beg = range_op(parser, node->nd_beg, cr); - node->nd_end = range_op(parser, node->nd_end, cr); + node->nd_beg = range_op(parser, node->nd_beg, loc); + node->nd_end = range_op(parser, node->nd_end, loc); if (nd_type(node) == NODE_DOT2) nd_set_type(node,NODE_FLIP2); else if (nd_type(node) == NODE_DOT3) nd_set_type(node, NODE_FLIP3); if (!method_op && !e_option_supplied(parser)) { @@ -10196,31 +10196,31 @@ cond0(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *cr } static NODE* -cond_gen(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *cr) +cond_gen(struct parser_params *parser, NODE *node, int method_op, const YYLTYPE *loc) { if (node == 0) return 0; - return cond0(parser, node, method_op, cr); + return cond0(parser, node, method_op, loc); } static NODE* -new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *cr) +new_if_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc) { if (!cc) return right; - cc = cond0(parser, cc, FALSE, cr); - return newline_node(NEW_IF(cc, left, right, cr)); + cc = cond0(parser, cc, FALSE, loc); + return newline_node(NEW_IF(cc, left, right, loc)); } static NODE* -new_unless_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *cr) +new_unless_gen(struct parser_params *parser, NODE *cc, NODE *left, NODE *right, const YYLTYPE *loc) { if (!cc) return right; - cc = cond0(parser, cc, FALSE, cr); - return newline_node(NEW_UNLESS(cc, left, right, cr)); + cc = cond0(parser, cc, FALSE, loc); + return newline_node(NEW_UNLESS(cc, left, right, loc)); } static NODE* logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *right, - const YYLTYPE *op_cr, const YYLTYPE *cr) + const YYLTYPE *op_loc, const YYLTYPE *loc) { NODE *op; value_expr(left); @@ -10229,13 +10229,13 @@ logop_gen(struct parser_params *parser, enum node_type type, NODE *left, NODE *r while ((second = node->nd_2nd) != 0 && (enum node_type)nd_type(second) == type) { node = second; } - node->nd_2nd = NEW_NODE(type, second, right, 0, cr); - nd_set_line(node->nd_2nd, op_cr->first_loc.lineno); - left->nd_crange.last_loc = cr->last_loc; + node->nd_2nd = NEW_NODE(type, second, right, 0, loc); + nd_set_line(node->nd_2nd, op_loc->beg_pos.lineno); + left->nd_loc.end_pos = loc->end_pos; return left; } - op = NEW_NODE(type, left, right, 0, cr); - nd_set_line(op, op_cr->first_loc.lineno); + op = NEW_NODE(type, left, right, 0, loc); + nd_set_line(op, op_loc->beg_pos.lineno); return op; } @@ -10265,11 +10265,11 @@ ret_args_gen(struct parser_params *parser, NODE *node) } static NODE * -new_yield_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr) +new_yield_gen(struct parser_params *parser, NODE *node, const YYLTYPE *loc) { if (node) no_blockarg(parser, node); - return NEW_YIELD(node, cr); + return NEW_YIELD(node, loc); } static VALUE @@ -10321,7 +10321,7 @@ arg_blk_pass(NODE *node1, NODE *node2) static NODE* -new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, NODE *tail, const YYLTYPE *cr) +new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, NODE *tail, const YYLTYPE *loc) { int saved_line = ruby_sourceline; struct rb_args_info *args = tail->nd_ainfo; @@ -10338,13 +10338,13 @@ new_args_gen(struct parser_params *parser, NODE *m, NODE *o, ID r, NODE *p, NODE args->opt_args = o; ruby_sourceline = saved_line; - nd_set_crange(tail, cr); + nd_set_loc(tail, loc); return tail; } static NODE* -new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, const YYLTYPE *cr) +new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, const YYLTYPE *loc) { int saved_line = ruby_sourceline; struct rb_args_info *args; @@ -10398,14 +10398,14 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, const YYLT if (kr) arg_var(kr); if (b) arg_var(b); - args->kw_rest_arg = NEW_DVAR(kr, cr); + args->kw_rest_arg = NEW_DVAR(kr, loc); args->kw_rest_arg->nd_cflag = kw_bits; } else if (kr) { if (b) vtable_pop(lvtbl->args, 1); /* reorder */ arg_var(kr); if (b) arg_var(b); - args->kw_rest_arg = NEW_DVAR(kr, cr); + args->kw_rest_arg = NEW_DVAR(kr, loc); } ruby_sourceline = saved_line; @@ -10413,27 +10413,27 @@ new_args_tail_gen(struct parser_params *parser, NODE *k, ID kr, ID b, const YYLT } static NODE* -dsym_node_gen(struct parser_params *parser, NODE *node, const YYLTYPE *cr) +dsym_node_gen(struct parser_params *parser, NODE *node, const YYLTYPE *loc) { VALUE lit; if (!node) { - return NEW_LIT(ID2SYM(idNULL), cr); + return NEW_LIT(ID2SYM(idNULL), loc); } switch (nd_type(node)) { case NODE_DSTR: nd_set_type(node, NODE_DSYM); - nd_set_crange(node, cr); + nd_set_loc(node, loc); break; case NODE_STR: lit = node->nd_lit; add_mark_object(node->nd_lit = ID2SYM(rb_intern_str(lit))); nd_set_type(node, NODE_LIT); - nd_set_crange(node, cr); + nd_set_loc(node, loc); break; default: - node = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST(node, cr), cr); + node = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST(node, loc), loc); break; } return node; @@ -10488,26 +10488,26 @@ remove_duplicate_keys(struct parser_params *parser, NODE *hash) } static NODE * -new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *cr) +new_hash_gen(struct parser_params *parser, NODE *hash, const YYLTYPE *loc) { if (hash) hash = remove_duplicate_keys(parser, hash); - return NEW_HASH(hash, cr); + return NEW_HASH(hash, loc); } #endif /* !RIPPER */ #ifndef RIPPER static NODE * -new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *cr) +new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc) { NODE *asgn; if (lhs) { ID vid = lhs->nd_vid; - YYLTYPE lhs_cr = lhs->nd_crange; + YYLTYPE lhs_loc = lhs->nd_loc; if (op == tOROP) { lhs->nd_value = rhs; - nd_set_crange(lhs, cr); - asgn = NEW_OP_ASGN_OR(gettable(vid, &lhs_cr), lhs, cr); + nd_set_loc(lhs, loc); + asgn = NEW_OP_ASGN_OR(gettable(vid, &lhs_loc), lhs, loc); if (is_notop_id(vid)) { switch (id_type(vid)) { case ID_GLOBAL: @@ -10519,60 +10519,60 @@ new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, con } else if (op == tANDOP) { lhs->nd_value = rhs; - nd_set_crange(lhs, cr); - asgn = NEW_OP_ASGN_AND(gettable(vid, &lhs_cr), lhs, cr); + nd_set_loc(lhs, loc); + asgn = NEW_OP_ASGN_AND(gettable(vid, &lhs_loc), lhs, loc); } else { asgn = lhs; - asgn->nd_value = NEW_CALL(gettable(vid, &lhs_cr), op, NEW_LIST(rhs, &rhs->nd_crange), cr); - nd_set_crange(asgn, cr); + asgn->nd_value = NEW_CALL(gettable(vid, &lhs_loc), op, NEW_LIST(rhs, &rhs->nd_loc), loc); + nd_set_loc(asgn, loc); } } else { - asgn = NEW_BEGIN(0, cr); + asgn = NEW_BEGIN(0, loc); } return asgn; } static NODE * new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, - ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *cr) + ID atype, ID attr, ID op, NODE *rhs, const YYLTYPE *loc) { NODE *asgn; - asgn = NEW_OP_ASGN2(lhs, CALL_Q_P(atype), attr, op, rhs, cr); + asgn = NEW_OP_ASGN2(lhs, CALL_Q_P(atype), attr, op, rhs, loc); fixpos(asgn, lhs); return asgn; } static NODE * -new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *cr) +new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, const YYLTYPE *loc) { NODE *asgn; if (lhs) { - asgn = NEW_OP_CDECL(lhs, op, rhs, cr); + asgn = NEW_OP_CDECL(lhs, op, rhs, loc); } else { - asgn = NEW_BEGIN(0, cr); + asgn = NEW_BEGIN(0, loc); } fixpos(asgn, lhs); return asgn; } static NODE * -const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *cr) +const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, const YYLTYPE *loc) { - return NEW_COLON2(head, mid, cr); + return NEW_COLON2(head, mid, loc); } static NODE * -const_decl_gen(struct parser_params *parser, NODE *path, const YYLTYPE *cr) +const_decl_gen(struct parser_params *parser, NODE *path, const YYLTYPE *loc) { if (in_def) { - yyerror1(cr, "dynamic constant assignment"); + yyerror1(loc, "dynamic constant assignment"); } - return NEW_CDECL(0, 0, (path), cr); + return NEW_CDECL(0, 0, (path), loc); } #else static VALUE @@ -10923,7 +10923,7 @@ typedef struct { struct parser_params* parser; rb_encoding *enc; NODE *succ_block; - const YYLTYPE *crange; + const YYLTYPE *loc; } reg_named_capture_assign_t; static int @@ -10944,23 +10944,23 @@ reg_named_capture_assign_iter(const OnigUChar *name, const OnigUChar *name_end, return ST_CONTINUE; } var = intern_cstr(s, len, enc); - node = node_assign(assignable(var, 0, arg->crange), NEW_LIT(ID2SYM(var), arg->crange), arg->crange); + node = node_assign(assignable(var, 0, arg->loc), NEW_LIT(ID2SYM(var), arg->loc), arg->loc); succ = arg->succ_block; - if (!succ) succ = NEW_BEGIN(0, arg->crange); + if (!succ) succ = NEW_BEGIN(0, arg->loc); succ = block_append(succ, node); arg->succ_block = succ; return ST_CONTINUE; } static NODE * -reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, const YYLTYPE *cr) +reg_named_capture_assign_gen(struct parser_params* parser, VALUE regexp, const YYLTYPE *loc) { reg_named_capture_assign_t arg; arg.parser = parser; arg.enc = rb_enc_get(regexp); arg.succ_block = 0; - arg.crange = cr; + arg.loc = loc; onig_foreach_name(RREGEXP_PTR(regexp), reg_named_capture_assign_iter, &arg); if (!arg.succ_block) return 0; diff --git a/thread.c b/thread.c index 26f619f288..c7d48c01db 100644 --- a/thread.c +++ b/thread.c @@ -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; } diff --git a/vm_core.h b/vm_core.h index c2a4b1ab03..1be20c1356 100644 --- a/vm_core.h +++ b/vm_core.h @@ -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