Project

General

Profile

Feature #5007 ยป proc_call_under.patch

mame (Yusuke Endoh), 04/17/2012 10:52 PM

View differences:

proc.c
return vret;
}
VALUE rb_proc_call_under(VALUE procval, VALUE under, VALUE self, VALUE values);
static VALUE
proc_call_under(int argc, VALUE *argv, VALUE procval)
{
VALUE self, klass, values;
rb_scan_args(argc, argv, "1*", &self, &values);
if (SPECIAL_CONST_P(self)) {
klass = Qnil;
}
else {
klass = rb_singleton_class(self);
}
return rb_proc_call_under(procval, klass, self, values);
}
#if SIZEOF_LONG > SIZEOF_INT
static inline int
check_argc(long argc)
......
rb_define_method(rb_cProc, "[]", proc_call, -1);
rb_define_method(rb_cProc, "===", proc_call, -1);
rb_define_method(rb_cProc, "yield", proc_call, -1);
rb_define_method(rb_cProc, "call_under", proc_call_under, -1);
#endif
rb_define_method(rb_cProc, "to_proc", proc_to_proc, 0);
rb_define_method(rb_cProc, "arity", proc_arity, 0);
vm_eval.c
}
}
static inline VALUE
invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
VALUE self, int argc, const VALUE *argv,
const rb_block_t *blockptr, const NODE *cref);
VALUE
rb_proc_call_under(VALUE procval, VALUE under, VALUE self, VALUE values)
{
rb_thread_t *th = GET_THREAD();
rb_block_t block;
NODE *cref;
rb_proc_t *proc;
GetProcPtr(procval, proc);
block = proc->block;
block.self = self;
cref = vm_cref_push(th, under, NOEX_PUBLIC, &proc->block);
cref->flags |= NODE_FL_CREF_PUSHED_BY_EVAL;
return invoke_block_from_c(th, &block, self,
RARRAY_LENINT(values), RARRAY_PTR(values),
GC_GUARDED_PTR_REF(th->cfp->lfp[0]), cref);
}
/* string eval under the class/module context */
static VALUE
eval_under(VALUE under, VALUE self, VALUE src, const char *file, int line)
    (1-1/1)