ruby-changes:48110
From: nobu <ko1@a...>
Date: Sat, 21 Oct 2017 10:06:30 +0900 (JST)
Subject: [ruby-changes:48110] nobu:r60224 (trunk): moved node generation for dregex_once to parse.y
nobu 2017-10-21 10:06:25 +0900 (Sat, 21 Oct 2017) New Revision: 60224 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60224 Log: moved node generation for dregex_once to parse.y Modified files: trunk/compile.c trunk/parse.y Index: parse.y =================================================================== --- parse.y (revision 60223) +++ parse.y (revision 60224) @@ -9267,12 +9267,7 @@ new_regexp_gen(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L9267 node = NEW_NODE(NODE_DSTR, STR_NEW0(), 1, new_list(node, column)); nd_set_column(node, column); case NODE_DSTR: - if (options & RE_OPTION_ONCE) { - nd_set_type(node, NODE_DREGX_ONCE); - } - else { - nd_set_type(node, NODE_DREGX); - } + nd_set_type(node, NODE_DREGX); 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) { @@ -9303,6 +9298,9 @@ new_regexp_gen(struct parser_params *par https://github.com/ruby/ruby/blob/trunk/parse.y#L9298 nd_set_type(node, NODE_LIT); node->nd_lit = reg_compile(src, options); } + if (options & RE_OPTION_ONCE) { + node = NEW_NODE(NODE_SCOPE, 0, node, 0); + } break; } return node; Index: compile.c =================================================================== --- compile.c (revision 60223) +++ compile.c (revision 60224) @@ -6226,11 +6226,9 @@ iseq_compile_each0(rb_iseq_t *iseq, LINK https://github.com/ruby/ruby/blob/trunk/compile.c#L6226 } break; } - case NODE_DREGX_ONCE:{ + case NODE_SCOPE:{ int ic_index = iseq->body->is_size++; - NODE *dregx_node = NEW_NODE(NODE_DREGX, node->u1.value, node->u2.value, node->u3.value); - NODE *block_node = NEW_NODE(NODE_SCOPE, 0, dregx_node, 0); - const rb_iseq_t *block_iseq = NEW_CHILD_ISEQ(block_node, make_name_for_block(iseq), + const rb_iseq_t *block_iseq = NEW_CHILD_ISEQ(node, make_name_for_block(iseq), ISEQ_TYPE_ONCE_GUARD, line); ADD_INSN2(ret, line, once, block_iseq, INT2FIX(ic_index)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/