* proc.c (proc_new): use the given class.

* vm.c (vm_make_proc): added an argument for the class.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18728 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-08-20 13:28:18 +00:00
Родитель 51e0bcb72a
Коммит 9286180079
5 изменённых файлов: 24 добавлений и 15 удалений

Просмотреть файл

@ -1,3 +1,9 @@
Wed Aug 20 22:28:15 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* proc.c (proc_new): use the given class.
* vm.c (vm_make_proc): added an argument for the class.
Wed Aug 20 22:24:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* enum.c (enum_take): get rid of extraneous iteration.

7
proc.c
Просмотреть файл

@ -379,11 +379,12 @@ proc_new(VALUE klass, int is_lambda)
}
}
if (block->proc) {
return block->proc;
procval = block->proc;
if (procval && RBASIC(procval)->klass == klass) {
return procval;
}
procval = vm_make_proc(th, cfp, block);
procval = vm_make_proc(th, cfp, block, klass);
if (is_lambda) {
rb_proc_t *proc;

20
vm.c
Просмотреть файл

@ -373,25 +373,27 @@ vm_stack_to_heap(rb_thread_t * const th)
static VALUE
vm_make_proc_from_block(rb_thread_t *th, rb_control_frame_t *cfp,
rb_block_t *block)
rb_block_t *block, VALUE klass)
{
VALUE procval;
rb_control_frame_t *bcfp;
VALUE *bdfp; /* to gc mark */
if (block->proc) {
return block->proc;
procval = block->proc;
if (procval && RBASIC(procval)->klass == klass) {
return procval;
}
bcfp = RUBY_VM_GET_CFP_FROM_BLOCK_PTR(block);
bdfp = bcfp->dfp;
block->proc = procval = vm_make_proc(th, bcfp, block);
procval = vm_make_proc(th, bcfp, block, klass);
if (!block->proc) block->proc = procval;
return procval;
}
VALUE
vm_make_proc(rb_thread_t *th,
rb_control_frame_t *cfp, const rb_block_t *block)
vm_make_proc(rb_thread_t *th, rb_control_frame_t *cfp,
const rb_block_t *block, VALUE klass)
{
VALUE procval, envval, blockprocval = 0;
rb_proc_t *proc;
@ -401,7 +403,7 @@ vm_make_proc(rb_thread_t *th,
rb_proc_t *p;
blockprocval = vm_make_proc_from_block(
th, cfp, (rb_block_t *)GC_GUARDED_PTR_REF(*cfp->lfp));
th, cfp, (rb_block_t *)GC_GUARDED_PTR_REF(*cfp->lfp), klass);
GetProcPtr(blockprocval, p);
*cfp->lfp = GC_GUARDED_PTR(&p->block);
@ -412,7 +414,7 @@ vm_make_proc(rb_thread_t *th,
if (PROCDEBUG) {
check_env_value(envval);
}
procval = rb_proc_alloc(rb_cProc);
procval = rb_proc_alloc(klass);
GetProcPtr(procval, proc);
proc->blockprocval = blockprocval;
proc->block.self = block->self;
@ -1743,7 +1745,7 @@ m_core_set_postexe(VALUE self, VALUE iseqval)
blockptr->iseq = blockiseq;
blockptr->proc = 0;
proc = vm_make_proc(th, cfp, blockptr);
proc = vm_make_proc(th, cfp, blockptr, rb_cProc);
rb_set_end_proc(rb_call_end_proc, proc);
});
return Qnil;

Просмотреть файл

@ -668,7 +668,7 @@ int rb_thread_method_id_and_class(rb_thread_t *th, ID *idp, VALUE *klassp);
VALUE vm_invoke_proc(rb_thread_t *th, rb_proc_t *proc, VALUE self,
int argc, const VALUE *argv, rb_block_t *blockptr);
VALUE vm_make_proc(rb_thread_t *th, rb_control_frame_t *cfp, const rb_block_t *block);
VALUE vm_make_proc(rb_thread_t *th, rb_control_frame_t *cfp, const rb_block_t *block, VALUE klass);
VALUE vm_make_env_object(rb_thread_t *th, rb_control_frame_t *cfp);
NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));

Просмотреть файл

@ -188,7 +188,7 @@ vm_callee_setup_arg_complex(rb_thread_t *th, const rb_iseq_t * iseq,
if (blockptr->proc == 0) {
rb_proc_t *proc;
blockval = vm_make_proc(th, th->cfp, blockptr);
blockval = vm_make_proc(th, th->cfp, blockptr, rb_cProc);
GetProcPtr(blockval, proc);
*block = &proc->block;
@ -662,7 +662,7 @@ vm_yield_with_cfunc(rb_thread_t *th, const rb_block_t *block,
}
if (blockptr) {
blockarg = vm_make_proc(th, th->cfp, blockptr);
blockarg = vm_make_proc(th, th->cfp, blockptr, rb_cProc);
}
else {
blockarg = Qnil;