mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c (iseq_compile_each): should consider block on stack,
if block argument is passed. [ruby-core:30534] * parse.c (arg_concat_gen): should append to nd_head, not to nd_iter for NODE_BLOCK_PASS. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4c897fdde1
commit
276fb7e77b
4 changed files with 56 additions and 11 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
Wed Jun 2 11:40:02 2010 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* compile.c (iseq_compile_each): should consider block on stack,
|
||||||
|
if block argument is passed. [ruby-core:30534]
|
||||||
|
|
||||||
|
* parse.c (arg_concat_gen): should append to nd_head, not to
|
||||||
|
nd_iter for NODE_BLOCK_PASS.
|
||||||
|
|
||||||
Tue Jun 1 23:12:06 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
Tue Jun 1 23:12:06 2010 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* re.c (unescape_nonascii): \P{FOO} is also Unicode property in
|
* re.c (unescape_nonascii): \P{FOO} is also Unicode property in
|
||||||
|
|
46
compile.c
46
compile.c
|
@ -3743,6 +3743,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
VALUE argc;
|
VALUE argc;
|
||||||
unsigned long flag = 0;
|
unsigned long flag = 0;
|
||||||
ID id = node->nd_mid;
|
ID id = node->nd_mid;
|
||||||
|
int boff = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* a[x] (op)= y
|
* a[x] (op)= y
|
||||||
|
@ -3771,15 +3772,18 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
ADD_INSN(ret, nd_line(node), putnil);
|
ADD_INSN(ret, nd_line(node), putnil);
|
||||||
}
|
}
|
||||||
COMPILE(ret, "NODE_OP_ASGN1 recv", node->nd_recv);
|
COMPILE(ret, "NODE_OP_ASGN1 recv", node->nd_recv);
|
||||||
if (nd_type(node->nd_args->nd_head) != NODE_ZARRAY) {
|
switch (nd_type(node->nd_args->nd_head)) {
|
||||||
|
case NODE_ZARRAY:
|
||||||
|
argc = INT2FIX(0);
|
||||||
|
break;
|
||||||
|
case NODE_BLOCK_PASS:
|
||||||
|
boff = 1;
|
||||||
|
default:
|
||||||
INIT_ANCHOR(args);
|
INIT_ANCHOR(args);
|
||||||
argc = setup_args(iseq, args, node->nd_args->nd_head, &flag);
|
argc = setup_args(iseq, args, node->nd_args->nd_head, &flag);
|
||||||
ADD_SEQ(ret, args);
|
ADD_SEQ(ret, args);
|
||||||
}
|
}
|
||||||
else {
|
ADD_INSN1(ret, nd_line(node), dupn, FIXNUM_INC(argc, 1 + boff));
|
||||||
argc = INT2FIX(0);
|
|
||||||
}
|
|
||||||
ADD_INSN1(ret, nd_line(node), dupn, FIXNUM_INC(argc, 1));
|
|
||||||
ADD_SEND_R(ret, nd_line(node), ID2SYM(idAREF), argc, Qfalse, LONG2FIX(flag));
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idAREF), argc, Qfalse, LONG2FIX(flag));
|
||||||
|
|
||||||
if (id == 0 || id == 1) {
|
if (id == 0 || id == 1) {
|
||||||
|
@ -3808,15 +3812,27 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
|
|
||||||
COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
|
COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
|
||||||
if (!poped) {
|
if (!poped) {
|
||||||
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2+boff));
|
||||||
}
|
}
|
||||||
if (flag & VM_CALL_ARGS_SPLAT_BIT) {
|
if (flag & VM_CALL_ARGS_SPLAT_BIT) {
|
||||||
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
|
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
|
||||||
|
if (boff > 0) {
|
||||||
|
ADD_INSN1(ret, nd_line(node), dupn, INT2FIX(3));
|
||||||
|
ADD_INSN(ret, nd_line(node), swap);
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
}
|
||||||
ADD_INSN(ret, nd_line(node), concatarray);
|
ADD_INSN(ret, nd_line(node), concatarray);
|
||||||
|
if (boff > 0) {
|
||||||
|
ADD_INSN1(ret, nd_line(node), setn, INT2FIX(3));
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
}
|
||||||
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
||||||
argc, Qfalse, LONG2FIX(flag));
|
argc, Qfalse, LONG2FIX(flag));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (boff > 0)
|
||||||
|
ADD_INSN(ret, nd_line(node), swap);
|
||||||
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
||||||
FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
|
FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
|
||||||
}
|
}
|
||||||
|
@ -3824,24 +3840,36 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
ADD_INSNL(ret, nd_line(node), jump, lfin);
|
ADD_INSNL(ret, nd_line(node), jump, lfin);
|
||||||
ADD_LABEL(ret, label);
|
ADD_LABEL(ret, label);
|
||||||
if (!poped) {
|
if (!poped) {
|
||||||
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2+boff));
|
||||||
}
|
}
|
||||||
ADD_INSN1(ret, nd_line(node), adjuststack, FIXNUM_INC(argc, 2));
|
ADD_INSN1(ret, nd_line(node), adjuststack, FIXNUM_INC(argc, 2+boff));
|
||||||
ADD_LABEL(ret, lfin);
|
ADD_LABEL(ret, lfin);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
|
COMPILE(ret, "NODE_OP_ASGN1 args->body: ", node->nd_args->nd_body);
|
||||||
ADD_SEND(ret, nd_line(node), ID2SYM(id), INT2FIX(1));
|
ADD_SEND(ret, nd_line(node), ID2SYM(id), INT2FIX(1));
|
||||||
if (!poped) {
|
if (!poped) {
|
||||||
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2));
|
ADD_INSN1(ret, nd_line(node), setn, FIXNUM_INC(argc, 2+boff));
|
||||||
}
|
}
|
||||||
if (flag & VM_CALL_ARGS_SPLAT_BIT) {
|
if (flag & VM_CALL_ARGS_SPLAT_BIT) {
|
||||||
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
|
ADD_INSN1(ret, nd_line(node), newarray, INT2FIX(1));
|
||||||
|
if (boff > 0) {
|
||||||
|
ADD_INSN1(ret, nd_line(node), dupn, INT2FIX(3));
|
||||||
|
ADD_INSN(ret, nd_line(node), swap);
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
}
|
||||||
ADD_INSN(ret, nd_line(node), concatarray);
|
ADD_INSN(ret, nd_line(node), concatarray);
|
||||||
|
if (boff > 0) {
|
||||||
|
ADD_INSN1(ret, nd_line(node), setn, INT2FIX(3));
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
ADD_INSN(ret, nd_line(node), pop);
|
||||||
|
}
|
||||||
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
||||||
argc, Qfalse, LONG2FIX(flag));
|
argc, Qfalse, LONG2FIX(flag));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if (boff > 0)
|
||||||
|
ADD_INSN(ret, nd_line(node), swap);
|
||||||
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
ADD_SEND_R(ret, nd_line(node), ID2SYM(idASET),
|
||||||
FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
|
FIXNUM_INC(argc, 1), Qfalse, LONG2FIX(flag));
|
||||||
}
|
}
|
||||||
|
|
|
@ -498,6 +498,7 @@ concatarray
|
||||||
(VALUE ary1, VALUE ary2st)
|
(VALUE ary1, VALUE ary2st)
|
||||||
(VALUE ary)
|
(VALUE ary)
|
||||||
{
|
{
|
||||||
|
const VALUE *sp = GET_SP();
|
||||||
const VALUE ary2 = ary2st;
|
const VALUE ary2 = ary2st;
|
||||||
VALUE tmp1 = rb_check_convert_type(ary1, T_ARRAY, "Array", "to_a");
|
VALUE tmp1 = rb_check_convert_type(ary1, T_ARRAY, "Array", "to_a");
|
||||||
VALUE tmp2 = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_a");
|
VALUE tmp2 = rb_check_convert_type(ary2, T_ARRAY, "Array", "to_a");
|
||||||
|
|
12
parse.y
12
parse.y
|
@ -1953,7 +1953,12 @@ arg : lhs '=' arg
|
||||||
|
|
||||||
value_expr($6);
|
value_expr($6);
|
||||||
if (!$3) $3 = NEW_ZARRAY();
|
if (!$3) $3 = NEW_ZARRAY();
|
||||||
args = arg_concat($3, $6);
|
if (nd_type($3) == NODE_BLOCK_PASS) {
|
||||||
|
args = NEW_ARGSCAT($3, $6);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
args = arg_concat($3, $6);
|
||||||
|
}
|
||||||
if ($5 == tOROP) {
|
if ($5 == tOROP) {
|
||||||
$5 = 0;
|
$5 = 0;
|
||||||
}
|
}
|
||||||
|
@ -8309,7 +8314,10 @@ arg_concat_gen(struct parser_params *parser, NODE *node1, NODE *node2)
|
||||||
if (!node2) return node1;
|
if (!node2) return node1;
|
||||||
switch (nd_type(node1)) {
|
switch (nd_type(node1)) {
|
||||||
case NODE_BLOCK_PASS:
|
case NODE_BLOCK_PASS:
|
||||||
node1->nd_iter = arg_concat(node1->nd_iter, node2);
|
if (node1->nd_head)
|
||||||
|
node1->nd_head = arg_concat(node1->nd_head, node2);
|
||||||
|
else
|
||||||
|
node1->nd_head = NEW_LIST(node2);
|
||||||
return node1;
|
return node1;
|
||||||
case NODE_ARGSPUSH:
|
case NODE_ARGSPUSH:
|
||||||
if (nd_type(node2) != NODE_ARRAY) break;
|
if (nd_type(node2) != NODE_ARRAY) break;
|
||||||
|
|
Loading…
Add table
Reference in a new issue