ruby-changes:48545
From: mame <ko1@a...>
Date: Sun, 5 Nov 2017 12:52:27 +0900 (JST)
Subject: [ruby-changes:48545] mame:r60660 (trunk): Revert "Introduce rb_code_range_t and replace YYLTYPE with it"
mame 2017-11-05 12:52:22 +0900 (Sun, 05 Nov 2017) New Revision: 60660 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60660 Log: Revert "Introduce rb_code_range_t and replace YYLTYPE with it" r60655 changed the usage of bison by defining a customized YYLTYPE, which seemed to cause a random stall at rb_thread_terminate_all. Kazuki Tsujimoto investigated the issue and pointed out the commit that caused it. Thanks! Modified files: trunk/node.h trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 60659) +++ parse.y (revision 60660) @@ -49,18 +49,26 @@ https://github.com/ruby/ruby/blob/trunk/parse.y#L49 do \ if (N) \ { \ - (Current).first_loc = YYRHSLOC(Rhs, 1).first_loc; \ - (Current).last_loc = YYRHSLOC(Rhs, N).last_loc; \ + (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ + (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ + (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ + (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ } \ else \ { \ - (Current).first_loc.lineno = ruby_sourceline; \ - (Current).first_loc.column = (int)(parser->tokp - lex_pbeg); \ - (Current).last_loc.lineno = ruby_sourceline; \ - (Current).last_loc.column = (int)(lex_p - lex_pbeg); \ + (Current).first_line = (Current).last_line = \ + ruby_sourceline; \ + (Current).first_column = (Current).last_column = \ + (int)(parser->tokp - lex_pbeg); \ } \ while (0) +#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL +# define YY_LOCATION_PRINT(File, Loc) \ + rb_parser_printf(parser, "%d.%d-%d.%d", \ + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) +#endif #undef malloc #undef realloc #undef calloc @@ -380,18 +388,18 @@ set_line_body(NODE *body, int line) https://github.com/ruby/ruby/blob/trunk/parse.y#L388 #define yyparse ruby_yyparse -static NODE *cond_gen(struct parser_params*,NODE*,int,rb_code_location_t*); -#define cond(node,first_loc) cond_gen(parser, (node), FALSE, first_loc) -#define method_cond(node,first_loc) cond_gen(parser, (node), TRUE, first_loc) +static NODE *cond_gen(struct parser_params*,NODE*,int,YYLTYPE*); +#define cond(node,location) cond_gen(parser, (node), FALSE, location) +#define method_cond(node,location) cond_gen(parser, (node), TRUE, location) #define new_nil() NEW_NIL() -static NODE *new_if_gen(struct parser_params*,NODE*,NODE*,NODE*,rb_code_location_t*); -#define new_if(cc,left,right,first_loc) new_if_gen(parser, (cc), (left), (right), (first_loc)) -static NODE *new_unless_gen(struct parser_params*,NODE*,NODE*,NODE*,rb_code_location_t*); -#define new_unless(cc,left,right,first_loc) new_unless_gen(parser, (cc), (left), (right), (first_loc)) -static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*,rb_code_location_t*); -#define logop(id,node1,node2,first_loc) \ +static NODE *new_if_gen(struct parser_params*,NODE*,NODE*,NODE*,YYLTYPE*); +#define new_if(cc,left,right,location) new_if_gen(parser, (cc), (left), (right), (location)) +static NODE *new_unless_gen(struct parser_params*,NODE*,NODE*,NODE*,YYLTYPE*); +#define new_unless(cc,left,right,location) new_unless_gen(parser, (cc), (left), (right), (location)) +static NODE *logop_gen(struct parser_params*,enum node_type,NODE*,NODE*,YYLTYPE*); +#define logop(id,node1,node2,location) \ logop_gen(parser, ((id)==idAND||(id)==idANDOP)?NODE_AND:NODE_OR, \ - (node1), (node2), (first_loc)) + (node1), (node2), (location)) static NODE *newline_node(NODE*); static void fixpos(NODE*,NODE*); @@ -410,31 +418,31 @@ static void reduce_nodes_gen(struct pars https://github.com/ruby/ruby/blob/trunk/parse.y#L418 static void block_dup_check_gen(struct parser_params*,NODE*,NODE*); #define block_dup_check(n1,n2) block_dup_check_gen(parser,(n1),(n2)) -static NODE *block_append_gen(struct parser_params*,NODE*,NODE*,rb_code_location_t*); -#define block_append(h,t,first_loc) block_append_gen(parser,(h),(t),(first_loc)) -static NODE *list_append_gen(struct parser_params*,NODE*,NODE*,rb_code_location_t*); -#define list_append(l,i,first_loc) list_append_gen(parser,(l),(i),(first_loc)) +static NODE *block_append_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define block_append(h,t,location) block_append_gen(parser,(h),(t),(location)) +static NODE *list_append_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define list_append(l,i,location) list_append_gen(parser,(l),(i),(location)) static NODE *list_concat(NODE*,NODE*); -static NODE *arg_append_gen(struct parser_params*,NODE*,NODE*,rb_code_location_t*); -#define arg_append(h,t,first_loc) arg_append_gen(parser,(h),(t),(first_loc)) -static NODE *arg_concat_gen(struct parser_params*,NODE*,NODE*,rb_code_location_t*); -#define arg_concat(h,t,first_loc) arg_concat_gen(parser,(h),(t),(first_loc)) -static NODE *literal_concat_gen(struct parser_params*,NODE*,NODE*,rb_code_location_t*); -#define literal_concat(h,t,first_loc) literal_concat_gen(parser,(h),(t),(first_loc)) +static NODE *arg_append_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define arg_append(h,t,location) arg_append_gen(parser,(h),(t),(location)) +static NODE *arg_concat_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define arg_concat(h,t,location) arg_concat_gen(parser,(h),(t),(location)) +static NODE *literal_concat_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define literal_concat(h,t,location) literal_concat_gen(parser,(h),(t),(location)) static int literal_concat0(struct parser_params *, VALUE, VALUE); -static NODE *new_evstr_gen(struct parser_params*,NODE*,rb_code_location_t*); -#define new_evstr(n, first_loc) new_evstr_gen(parser,(n),(first_loc)) -static NODE *evstr2dstr_gen(struct parser_params*,NODE*,rb_code_location_t*); -#define evstr2dstr(n,first_loc) evstr2dstr_gen(parser,(n),(first_loc)) +static NODE *new_evstr_gen(struct parser_params*,NODE*,YYLTYPE*); +#define new_evstr(n, location) new_evstr_gen(parser,(n),(location)) +static NODE *evstr2dstr_gen(struct parser_params*,NODE*,YYLTYPE*); +#define evstr2dstr(n,location) evstr2dstr_gen(parser,(n),(location)) static NODE *splat_array(NODE*); -static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*,rb_code_location_t*); -#define call_bin_op(recv,id,arg1,first_loc) call_bin_op_gen(parser, (recv),(id),(arg1),(first_loc)) -static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID,rb_code_location_t*); -#define call_uni_op(recv,id,first_loc) call_uni_op_gen(parser, (recv),(id),(first_loc)) -static NODE *new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, rb_code_location_t *first_loc); -#define new_qcall(q,r,m,a,first_loc) new_qcall_gen(parser,q,r,m,a,first_loc) -#define new_command_qcall(q,r,m,a,first_loc) new_qcall_gen(parser,q,r,m,a,first_loc) +static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*,YYLTYPE*); +#define call_bin_op(recv,id,arg1,location) call_bin_op_gen(parser, (recv),(id),(arg1),(location)) +static NODE *call_uni_op_gen(struct parser_params*,NODE*,ID,YYLTYPE*); +#define call_uni_op(recv,id,location) call_uni_op_gen(parser, (recv),(id),(location)) +static NODE *new_qcall_gen(struct parser_params* parser, ID atype, NODE *recv, ID mid, NODE *args, YYLTYPE *location); +#define new_qcall(q,r,m,a,location) new_qcall_gen(parser,q,r,m,a,location) +#define new_command_qcall(q,r,m,a,location) new_qcall_gen(parser,q,r,m,a,location) 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) {b->nd_iter = m; return b;} @@ -442,136 +450,136 @@ static NODE *method_add_block_gen(struct https://github.com/ruby/ruby/blob/trunk/parse.y#L450 static NODE *new_args_gen(struct parser_params*,NODE*,NODE*,ID,NODE*,NODE*); #define new_args(f,o,r,p,t) new_args_gen(parser, (f),(o),(r),(p),(t)) -static NODE *new_args_tail_gen(struct parser_params*,NODE*,ID,ID,rb_code_location_t*); -#define new_args_tail(k,kr,b,first_loc) new_args_tail_gen(parser, (k),(kr),(b),(first_loc)) -static NODE *new_kw_arg_gen(struct parser_params *parser, NODE *k, rb_code_location_t *first_loc); -#define new_kw_arg(k,first_loc) new_kw_arg_gen(parser, k, first_loc) +static NODE *new_args_tail_gen(struct parser_params*,NODE*,ID,ID,YYLTYPE*); +#define new_args_tail(k,kr,b,location) new_args_tail_gen(parser, (k),(kr),(b),(location)) +static NODE *new_kw_arg_gen(struct parser_params *parser, NODE *k, YYLTYPE *location); +#define new_kw_arg(k,location) new_kw_arg_gen(parser, k, location) static VALUE negate_lit_gen(struct parser_params*, VALUE); #define negate_lit(lit) negate_lit_gen(parser, lit) 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*,rb_code_location_t*); -#define new_yield(node,first_loc) new_yield_gen(parser, (node), (first_loc)) -static NODE *dsym_node_gen(struct parser_params*,NODE*,rb_code_location_t*); -#define dsym_node(node,first_loc) dsym_node_gen(parser, (node), (first_loc)) - -static NODE *gettable_gen(struct parser_params*,ID,rb_code_location_t*); -#define gettable(id,first_loc) gettable_gen(parser,(id),(first_loc)) -static NODE *assignable_gen(struct parser_params*,ID,NODE*,rb_code_location_t*); -#define assignable(id,node,first_loc) assignable_gen(parser, (id), (node), (first_loc)) - -static NODE *aryset_gen(struct parser_params*,NODE*,NODE*,rb_code_location_t*); -#define aryset(node1,node2,first_loc) aryset_gen(parser, (node1), (node2), (first_loc)) -static NODE *attrset_gen(struct parser_params*,NODE*,ID,ID,rb_code_location_t*); -#define attrset(node,q,id,first_loc) attrset_gen(parser, (node), (q), (id), (first_loc)) +static NODE *new_yield_gen(struct parser_params*,NODE*,YYLTYPE*); +#define new_yield(node,location) new_yield_gen(parser, (node), (location)) +static NODE *dsym_node_gen(struct parser_params*,NODE*,YYLTYPE*); +#define dsym_node(node,location) dsym_node_gen(parser, (node), (location)) + +static NODE *gettable_gen(struct parser_params*,ID,YYLTYPE*); +#define gettable(id,location) gettable_gen(parser,(id),(location)) +static NODE *assignable_gen(struct parser_params*,ID,NODE*,YYLTYPE*); +#define assignable(id,node,location) assignable_gen(parser, (id), (node), (location)) + +static NODE *aryset_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define aryset(node1,node2,location) aryset_gen(parser, (node1), (node2), (location)) +static NODE *attrset_gen(struct parser_params*,NODE*,ID,ID,YYLTYPE*); +#define attrset(node,q,id,location) attrset_gen(parser, (node), (q), (id), (location)) 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*,rb_code_location_t*); -#define node_assign(node1, node2, first_loc) node_assign_gen(parser, (node1), (node2), (first_loc)) +static NODE *node_assign_gen(struct parser_params*,NODE*,NODE*,YYLTYPE*); +#define node_assign(node1, node2, location) node_assign_gen(parser, (node1), (node2), (location)) -static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, rb_code_location_t *first_loc); -#define new_op_assign(lhs, op, rhs, first_loc) new_op_assign_gen(parser, (lhs), (op), (rhs), (first_loc)) -static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, rb_code_location_t *first_loc); -#define new_attr_op_assign(lhs, type, attr, op, rhs, first_loc) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs), (first_loc)) -static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, rb_code_location_t *first_loc); -#define new_const_op_assign(lhs, op, rhs, first_loc) new_const_op_assign_gen(parser, (lhs), (op), (rhs), (first_loc)) +static NODE *new_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, YYLTYPE *location); +#define new_op_assign(lhs, op, rhs, location) new_op_assign_gen(parser, (lhs), (op), (rhs), (location)) +static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID atype, ID attr, ID op, NODE *rhs, YYLTYPE *location); +#define new_attr_op_assign(lhs, type, attr, op, rhs, location) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs), (location)) +static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs, YYLTYPE *location); +#define new_const_op_assign(lhs, op, rhs, location) new_const_op_assign_gen(parser, (lhs), (op), (rhs), (location)) -static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, rb_code_location_t *first_loc); -#define const_path_field(w, n, first_loc) const_path_field_gen(parser, w, n, first_loc) +static NODE *const_path_field_gen(struct parser_params *parser, NODE *head, ID mid, YYLTYPE *location); +#define const_path_field(w, n, location) const_path_field_gen(parser, w, n, location) #define top_const_field(n) NEW_COLON3(n) -static NODE *const_decl_gen(struct parser_params *parser, NODE* path, rb_code_location_t *first_loc); -#define const_decl(path, first_loc) const_decl_gen(parser, path, first_loc) +static NODE *const_decl_gen(struct parser_params *parser, NODE* path, YYLTYPE *location); +#define const_decl(path, location) const_decl_gen(parser, path, location) #define var_field(n) (n) -#define backref_assign_error(n, a, first_loc) (rb_backref_error(n), new_begin(0, first_loc)) +#define backref_assign_error(n, a, location) (rb_backref_error(n), new_begin(0, location)) static NODE *kwd_append(NODE*, NODE*); -static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, rb_code_location_t *first_loc); -#define new_hash(hash, first_loc) new_hash_gen(parser, (hash), first_loc) +static NODE *new_hash_gen(struct parser_params *parser, NODE *hash, YYLTYPE *location); +#define new_hash(hash, location) new_hash_gen(parser, (hash), location) -static NODE *new_defined_gen(struct parser_params *parser, NODE *expr, rb_code_location_t *first_loc); -#define new_defined(expr, first_loc) new_defined_gen(parser, expr, first_loc) +static NODE *new_defined_gen(struct parser_params *parser, NODE *expr, YYLTYPE *location); +#define new_defined(expr, location) new_defined_gen(parser, expr, location) -static NODE *new_regexp_gen(struct parser_params *, NODE *, int, rb_code_location_t *); -#define new_regexp(node, opt, first_loc) new_regexp_gen(parser, node, opt, first_loc) +static NODE *new_regexp_gen(struct parser_params *, NODE *, int, YYLTYPE *); +#define new_regexp(node, opt, location) new_regexp_gen(parser, node, opt, location) -static NODE *new_lit_gen(struct parser_params *parser, VALUE sym, rb_code_location_t *first_loc); -#define new_lit(sym, first_loc) new_lit_gen(parser, sym, first_loc) +static NODE *new_lit_gen(struct parser_params *parser, VALUE sym, YYLTYPE *location); +#define new_lit(sym, location) new_lit_gen(parser, sym, location) -static NODE *new_list_gen(struct parser_params *parser, NODE *item, rb_code_location_t *first_loc); -#define new_list(item, first_loc) new_list_gen(parser, item, first_loc) +static NODE *new_list_gen(struct parser_params *parser, NODE *item, YYLTYPE *location); +#define new_list(item, location) new_list_gen(parser, item, location) -static NODE *new_str_gen(struct parser_params *parser, VALUE str, rb_code_location_t *first_loc); -#define new_str(s,first_loc) new_str_gen(parser, s, first_loc) +static NODE *new_str_gen(struct parser_params *parser, VALUE str, YYLTYPE *location); +#define new_str(s,location) new_str_gen(parser, s, location) -static NODE *new_dvar_gen(struct parser_params *parser, ID id, rb_code_location_t *first_loc); -#define new_dvar(id, first_loc) new_dvar_gen(parser, id, first_loc) +static NODE *new_dvar_gen(struct parser_params *parser, ID id, YYLTYPE *location); +#define new_dvar(id, location) new_dvar_gen(parser, id, location) -static NODE *new_resbody_gen(struct parser_params *parser, NODE *exc_list, NODE *stmt, NODE *rescue, rb_code_location_t *first_loc); -#define new_resbody(e,s,r,first_loc) new_resbody_gen(parser, (e),(s),(r),(first_loc)) +static NODE *new_resbody_gen(struct parser_params *parser, NODE *exc_list, NODE *stmt, NODE *rescue, YYLTYPE *location); +#define new_resbody(e,s,r,location) new_resbody_gen(parser, (e),(s),(r),(location)) -static NODE *new_errinfo_gen(struct parser_params *parser, rb_code_location_t *first_loc); -#define new_errinfo(first_loc) new_errinfo_gen(parser, first_loc) +static NODE *new_errinfo_gen(struct parser_params *parser, YYLTYPE *location); +#define new_errinfo(location) new_errinfo_gen(parser, location) -static NODE *new_call_gen(struct parser_params *parser, NODE *recv, ID mid, NODE *args, rb_code_location_t *first_loc); -#define new_call(recv,mid,args,first_loc) new_call_gen(parser, recv,mid,args,first_loc) +static NODE *new_call_gen(struct parser_params *parser, NODE *recv, ID mid, NODE *args, YYLTYPE *location); +#define new_call(recv,mid,args,location) new_call_gen(parser, recv,mid,args,location) -static NODE *new_fcall_gen(struct parser_params *parser, ID mid, NODE *args, rb_code_location_t *first_loc); -#define new_fcall(mid,args,first_loc) new_fcall_gen(parser, mid, args, first_loc) +static NODE *new_fcall_gen(struct parser_params *parser, ID mid, NODE *args, YYLTYPE *location); +#define new_fcall(mid,args,location) new_fcall_gen(parser, mid, args, location) -static NODE *new_for_gen(struct parser_params *parser, NODE *var, NODE *iter, NODE *body, rb_code_location_t *first_loc); -#define new_for(var,iter,body,first_loc) new_for_gen(parser, var, iter, body, first_loc) +static NODE *new_for_gen(struct parser_params *parser, NODE *var, NODE *iter, NODE *body, YYLTYPE *location); +#define new_for(var,iter,body,location) new_for_gen(parser, var, iter, body, location) -static NODE *new_gvar_gen(struct parser_params *parser, ID id, rb_code_location_t *first_loc); -#define new_gvar(id, first_loc) new_gvar_gen(parser, id, first_loc) +static NODE *new_gvar_gen(struct parser_params *parser, ID id, YYLTYPE *location); +#define new_gvar(id, location) new_gvar_gen(parser, id, location) -static NODE *new_lvar_gen(struct parser_params *parser, ID id, rb_code_location_t *first_loc); -#define new_lvar(id, first_loc) new_lvar_gen(parser, id, first_loc) +static NODE *new_lvar_gen(struct parser_params *parser, ID id, YYLTYPE *location); +#define new_lvar(id, location) new_lvar_gen(parser, id, location) -static NODE *new_dstr_gen(struct parser_params *parser, VALUE str, rb_code_location_t *first_loc); -#define new_dstr(s, first_loc) new_dstr_gen(parser, s, first_loc) +static NODE *new_dstr_gen(struct parser_params *parser, VALUE str, YYLTYPE *location); +#define new_dstr(s, location) new_dstr_gen(parser, s, location) -static NODE *new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NODE *e, rb_code_location_t *first_loc); -#define new_rescue(b,res,e,first_loc) new_rescue_gen(parser,b,res,e,first_loc) +static NODE *new_rescue_gen(struct parser_params *parser, NODE *b, NODE *res, NODE *e, YYLTYPE *location); +#define new_rescue(b,res,e,location) new_rescue_gen(parser,b,res,e,location) -static NODE *new_undef_gen(struct parser_params *parser, NODE *i, rb_code_location_t *first_loc); -#define new_undef(i, first_loc) new_undef_gen(parser, i, first_loc) +static NODE *new_undef_gen(struct parser_params *parser, NODE *i, YYLTYPE *location); +#define new_undef(i, location) new_undef_gen(parser, i, location) -static NODE *new_zarray_gen(struct parser_params *parser, rb_code_location_t *first_loc); -#define new_zarray(first_loc) new_zarray_gen(parser, first_loc) +static NODE *new_zarray_gen(struct parser_params *parser, YYLTYPE *location); +#define new_zarray(location) new_zarray_gen(parser, location) -static NODE *new_ivar_gen(struct parser_params *parser, ID id, rb_code_location_t *first_loc); -#define new_ivar(id, first_loc) new_ivar_gen(parser,id,first_loc) +static NODE *new_ivar_gen(struct parser_params *parser, ID id, YYLTYPE *location); +#define new_ivar(id, location) new_ivar_gen (... truncated) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/