mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* compile.c (setup_args), vm.c (invoke_block_from_c),
vm_insnhelper.c (caller_setup_args): reverted r30241 and r30243 except for the test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30283 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
da4d3e8464
commit
f4db8aedc8
6 changed files with 16 additions and 24 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Tue Dec 21 06:10:18 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* compile.c (setup_args), vm.c (invoke_block_from_c),
|
||||||
|
vm_insnhelper.c (caller_setup_args): reverted r30241 and r30243
|
||||||
|
except for the test.
|
||||||
|
|
||||||
Tue Dec 21 01:41:42 2010 Masaya Tarui <tarui@ruby-lnag.org>
|
Tue Dec 21 01:41:42 2010 Masaya Tarui <tarui@ruby-lnag.org>
|
||||||
|
|
||||||
* io.c : add an extra byte to buffer for the specification of read
|
* io.c : add an extra byte to buffer for the specification of read
|
||||||
|
|
19
compile.c
19
compile.c
|
@ -2886,7 +2886,7 @@ add_ensure_iseq(LINK_ANCHOR *ret, rb_iseq_t *iseq, int is_return)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, VALUE *flag, VALUE *block)
|
setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, VALUE *flag)
|
||||||
{
|
{
|
||||||
VALUE argc = INT2FIX(0);
|
VALUE argc = INT2FIX(0);
|
||||||
int nsplat = 0;
|
int nsplat = 0;
|
||||||
|
@ -2896,15 +2896,8 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR *args, NODE *argn, VALUE *flag, VALUE *b
|
||||||
INIT_ANCHOR(arg_block);
|
INIT_ANCHOR(arg_block);
|
||||||
INIT_ANCHOR(args_splat);
|
INIT_ANCHOR(args_splat);
|
||||||
if (argn && nd_type(argn) == NODE_BLOCK_PASS) {
|
if (argn && nd_type(argn) == NODE_BLOCK_PASS) {
|
||||||
if (block && nd_type(argn->nd_body) == NODE_LAMBDA) {
|
|
||||||
NODE *lambda = argn->nd_body;
|
|
||||||
*block = NEW_CHILD_ISEQVAL(lambda->nd_body, make_name_for_block(iseq), ISEQ_TYPE_BLOCK, nd_line(lambda));
|
|
||||||
*flag |= VM_CALL_BLOCK_LAMBDA_BIT;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
COMPILE(arg_block, "block", argn->nd_body);
|
COMPILE(arg_block, "block", argn->nd_body);
|
||||||
*flag |= VM_CALL_ARGS_BLOCKARG_BIT;
|
*flag |= VM_CALL_ARGS_BLOCKARG_BIT;
|
||||||
}
|
|
||||||
argn = argn->nd_head;
|
argn = argn->nd_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3816,7 +3809,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
boff = 1;
|
boff = 1;
|
||||||
default:
|
default:
|
||||||
INIT_ANCHOR(args);
|
INIT_ANCHOR(args);
|
||||||
argc = setup_args(iseq, args, node->nd_args->nd_head, &flag, NULL);
|
argc = setup_args(iseq, args, node->nd_args->nd_head, &flag);
|
||||||
ADD_SEQ(ret, args);
|
ADD_SEQ(ret, args);
|
||||||
}
|
}
|
||||||
ADD_INSN1(ret, nd_line(node), dupn, FIXNUM_INC(argc, 1 + boff));
|
ADD_INSN1(ret, nd_line(node), dupn, FIXNUM_INC(argc, 1 + boff));
|
||||||
|
@ -4132,7 +4125,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
|
|
||||||
/* args */
|
/* args */
|
||||||
if (nd_type(node) != NODE_VCALL) {
|
if (nd_type(node) != NODE_VCALL) {
|
||||||
argc = setup_args(iseq, args, node->nd_args, &flag, &parent_block);
|
argc = setup_args(iseq, args, node->nd_args, &flag);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
argc = INT2FIX(0);
|
argc = INT2FIX(0);
|
||||||
|
@ -4170,7 +4163,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
INIT_ANCHOR(args);
|
INIT_ANCHOR(args);
|
||||||
iseq->compile_data->current_block = Qfalse;
|
iseq->compile_data->current_block = Qfalse;
|
||||||
if (nd_type(node) == NODE_SUPER) {
|
if (nd_type(node) == NODE_SUPER) {
|
||||||
argc = setup_args(iseq, args, node->nd_args, &flag, &parent_block);
|
argc = setup_args(iseq, args, node->nd_args, &flag);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* NODE_ZSUPER */
|
/* NODE_ZSUPER */
|
||||||
|
@ -4343,7 +4336,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->nd_head) {
|
if (node->nd_head) {
|
||||||
argc = setup_args(iseq, args, node->nd_head, &flag, NULL);
|
argc = setup_args(iseq, args, node->nd_head, &flag);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
argc = INT2FIX(0);
|
argc = INT2FIX(0);
|
||||||
|
@ -4955,7 +4948,7 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
|
|
||||||
INIT_ANCHOR(recv);
|
INIT_ANCHOR(recv);
|
||||||
INIT_ANCHOR(args);
|
INIT_ANCHOR(args);
|
||||||
argc = setup_args(iseq, args, node->nd_args, &flag, NULL);
|
argc = setup_args(iseq, args, node->nd_args, &flag);
|
||||||
|
|
||||||
if (node->nd_recv == (NODE *) 1) {
|
if (node->nd_recv == (NODE *) 1) {
|
||||||
flag |= VM_CALL_FCALL_BIT;
|
flag |= VM_CALL_FCALL_BIT;
|
||||||
|
|
|
@ -22,9 +22,6 @@ class TestLambdaParameters < Test::Unit::TestCase
|
||||||
assert_raise(ArgumentError) { ->(a,b){ }.call(1,2,3) }
|
assert_raise(ArgumentError) { ->(a,b){ }.call(1,2,3) }
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
__END__
|
|
||||||
def test_lambda_as_iterator
|
def test_lambda_as_iterator
|
||||||
a = 0
|
a = 0
|
||||||
2.times(&->(_){ a += 1 })
|
2.times(&->(_){ a += 1 })
|
||||||
|
|
5
vm.c
5
vm.c
|
@ -531,10 +531,7 @@ invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
|
||||||
const rb_control_frame_t *cfp;
|
const rb_control_frame_t *cfp;
|
||||||
rb_control_frame_t *ncfp;
|
rb_control_frame_t *ncfp;
|
||||||
int i, opt_pc, arg_size = iseq->arg_size;
|
int i, opt_pc, arg_size = iseq->arg_size;
|
||||||
int type =
|
int type = block_proc_is_lambda(block->proc) ?
|
||||||
block->proc == Qtrue ? VM_FRAME_MAGIC_LAMBDA :
|
|
||||||
block->proc == Qfalse ? VM_FRAME_MAGIC_BLOCK :
|
|
||||||
block_proc_is_lambda(block->proc) ?
|
|
||||||
VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK;
|
VM_FRAME_MAGIC_LAMBDA : VM_FRAME_MAGIC_BLOCK;
|
||||||
|
|
||||||
rb_vm_set_finish_env(th);
|
rb_vm_set_finish_env(th);
|
||||||
|
|
|
@ -550,7 +550,6 @@ typedef struct {
|
||||||
#define VM_CALL_TAILRECURSION_BIT (0x01 << 6)
|
#define VM_CALL_TAILRECURSION_BIT (0x01 << 6)
|
||||||
#define VM_CALL_SUPER_BIT (0x01 << 7)
|
#define VM_CALL_SUPER_BIT (0x01 << 7)
|
||||||
#define VM_CALL_OPT_SEND_BIT (0x01 << 8)
|
#define VM_CALL_OPT_SEND_BIT (0x01 << 8)
|
||||||
#define VM_CALL_BLOCK_LAMBDA_BIT (0x01 << 9)
|
|
||||||
|
|
||||||
enum vm_special_object_type {
|
enum vm_special_object_type {
|
||||||
VM_SPECIAL_OBJECT_VMCORE = 1,
|
VM_SPECIAL_OBJECT_VMCORE = 1,
|
||||||
|
|
|
@ -265,7 +265,7 @@ caller_setup_args(const rb_thread_t *th, rb_control_frame_t *cfp, VALUE flag,
|
||||||
else if (blockiseq) {
|
else if (blockiseq) {
|
||||||
blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp);
|
blockptr = RUBY_VM_GET_BLOCK_PTR_IN_CFP(cfp);
|
||||||
blockptr->iseq = blockiseq;
|
blockptr->iseq = blockiseq;
|
||||||
blockptr->proc = (flag & VM_CALL_BLOCK_LAMBDA_BIT) ? Qtrue : Qfalse;
|
blockptr->proc = 0;
|
||||||
*block = blockptr;
|
*block = blockptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue