From 41031667c9f1cbef8e88dbdb5f2988e95837f508 Mon Sep 17 00:00:00 2001 From: yugui Date: Sun, 22 Feb 2009 14:05:31 +0000 Subject: merges r22494 and r22495 from trunk into ruby_1_9_1. * vm_eval.c (method_missing): should not pop cfp if missing method is method_missing. [ruby-core:22298] * vm_eval.c (rb_raise_method_missing): new function to directly raise NoMethodError. * vm_insnhelper.c (vm_call_method): fixed the case method_missing is missing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_insnhelper.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'vm_insnhelper.c') diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 0e54dddc59..ffb36e9a00 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -403,20 +403,25 @@ vm_call_bmethod(rb_thread_t *th, ID id, VALUE procval, VALUE recv, return val; } -static inline VALUE -vm_method_missing(rb_thread_t *th, ID id, VALUE recv, +static inline void +vm_method_missing_args(rb_thread_t *th, VALUE *argv, int num, rb_block_t *blockptr, int opt) { - VALUE val; rb_control_frame_t * const reg_cfp = th->cfp; - VALUE *argv = ALLOCA_N(VALUE, num + 1); MEMCPY(argv, STACK_ADDR_FROM_TOP(num + 1), VALUE, num + 1); - argv[0] = ID2SYM(id); th->method_missing_reason = opt; th->passed_block = blockptr; POPN(num + 1); - val = rb_funcall2(recv, idMethodMissing, num + 1, argv); - return val; +} + +static inline VALUE +vm_method_missing(rb_thread_t *th, ID id, VALUE recv, + int num, rb_block_t *blockptr, int opt) +{ + VALUE *argv = ALLOCA_N(VALUE, num + 1); + vm_method_missing_args(th, argv, num, blockptr, opt); + argv[0] = ID2SYM(id); + return rb_funcall2(recv, idMethodMissing, num + 1, argv); } static inline void @@ -581,17 +586,19 @@ vm_call_method(rb_thread_t * const th, rb_control_frame_t * const cfp, } else { /* method missing */ + int stat = 0; + if (flag & VM_CALL_VCALL_BIT) { + stat |= NOEX_VCALL; + } + if (flag & VM_CALL_SUPER_BIT) { + stat |= NOEX_SUPER; + } if (id == idMethodMissing) { - rb_bug("method missing"); + VALUE *argv = ALLOCA_N(VALUE, num); + vm_method_missing_args(th, argv, num - 1, 0, stat); + rb_raise_method_missing(th, num, argv, recv, stat); } else { - int stat = 0; - if (flag & VM_CALL_VCALL_BIT) { - stat |= NOEX_VCALL; - } - if (flag & VM_CALL_SUPER_BIT) { - stat |= NOEX_SUPER; - } val = vm_method_missing(th, id, recv, num, blockptr, stat); } } -- cgit v1.2.3