summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-01 04:35:58 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-05-01 04:35:58 +0000
commit75d28f887089c8582b63a64cf5df1d0270f15cc1 (patch)
tree1a274ad80a96f2546c0aba4701fd0c0e78857b5b /vm.c
parentea2cb282aeba0457aa775d5dbfa1da6810fafa45 (diff)
* yarvcore.h, compile.c (set_arguments): support post arguments.
* test/ruby/test_method.rb: add tests for above. * test/ruby/test_proc.rb: ditto. * proc.c: fix an arity bug ([ruby-core:11029]). * vm.c, vm.h, insns.def, vm_dump.h: fix bmethod process. * vm.c: support block argument on block parameter. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12231 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/vm.c b/vm.c
index c1793ae760..fb70e29b12 100644
--- a/vm.c
+++ b/vm.c
@@ -105,8 +105,6 @@ push_frame(rb_thread_t *th, rb_iseq_t *iseq, VALUE magic,
cfp->lfp = lfp;
cfp->dfp = dfp;
cfp->proc = 0;
- cfp->method_id = 0;
- cfp->method_klass = 0;
#define COLLECT_PROFILE 0
#if COLLECT_PROFILE
@@ -436,8 +434,8 @@ th_make_proc_from_block(rb_thread_t *th, rb_control_frame_t *cfp,
struct RObject *rb;
VALUE
-th_make_proc(rb_thread_t *th, rb_control_frame_t *cfp,
- rb_block_t *block)
+th_make_proc(rb_thread_t *th,
+ rb_control_frame_t *cfp, rb_block_t *block)
{
VALUE procval, envval, blockprocval = 0;
rb_proc_t *proc;
@@ -448,8 +446,7 @@ th_make_proc(rb_thread_t *th, rb_control_frame_t *cfp,
blockprocval =
th_make_proc_from_block(th, cfp,
- (rb_block_t *)GC_GUARDED_PTR_REF(*cfp->
- lfp));
+ (rb_block_t *)GC_GUARDED_PTR_REF(*cfp->lfp));
GetProcPtr(blockprocval, p);
*cfp->lfp = GC_GUARDED_PTR(&p->block);
}
@@ -489,12 +486,11 @@ th_invoke_bmethod(rb_thread_t *th, ID id, VALUE procval, VALUE recv,
rb_control_frame_t *cfp = th->cfp;
rb_proc_t *proc;
VALUE val;
- VALUE values[2] = {
- id, RCLASS(klass)->super,
- };
- /* dirty hack */
- (cfp-1)->block_iseq = (void *)values;
+ /* control block frame */
+ (cfp-2)->method_id = id;
+ (cfp-2)->method_klass = klass;
+
GetProcPtr(procval, proc);
val = th_invoke_proc(th, proc, recv, argc, argv);
return val;
@@ -741,6 +737,17 @@ th_yield_setup_args(rb_iseq_t *iseq, int argc, VALUE *argv)
argc = iseq->arg_rest + 1;
}
+ if (iseq->arg_block != -1) {
+ VALUE proc = Qnil;
+
+ if (rb_block_given_p()) {
+ proc = rb_block_proc();
+ }
+
+ argv[iseq->arg_block] = proc;
+ argc = iseq->arg_block + 1;
+ }
+
return argc;
}
@@ -982,7 +989,7 @@ th_backtrace_each(rb_thread_t *th,
rb_ary_push(ary, str);
}
}
- else if (cfp->method_id) {
+ else if (RUBYVM_CFUNC_FRAME_P(cfp)) {
str = rb_sprintf("%s:%d:in `%s'",
file, line_no,
rb_id2name(cfp->method_id));