summaryrefslogtreecommitdiffstats
path: root/vm_insnhelper.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-28 04:20:35 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-28 04:20:35 +0000
commit44da447c16f637c5e662fb20437af0d4f6aca5e8 (patch)
treeb7f5373ce9a12b25c0074abc07ba566507663a18 /vm_insnhelper.c
parentab5c2640dee9a4cbb5d9feccd9b29d552f8b2c4a (diff)
downloadruby-44da447c16f637c5e662fb20437af0d4f6aca5e8.tar.gz
ruby-44da447c16f637c5e662fb20437af0d4f6aca5e8.tar.xz
ruby-44da447c16f637c5e662fb20437af0d4f6aca5e8.zip
* vm_insnhelper.c (vm_setup_method): should push call frame before
raising exception, to put the Ruby-defined method name in the error message. [ruby-core:26333] * vm_insnhelper.c (VM_CALLEE_SETUP_ARG): macro modified. * vm_insnhelper.c (vm_yield_setup_args): modified for new VM_CALLEE_SETUP_ARG macro. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_insnhelper.c')
-rw-r--r--vm_insnhelper.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 25b0d5b3b..5b965d215 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -98,22 +98,23 @@ vm_pop_frame(rb_thread_t *th)
/* method dispatch */
-#define VM_CALLEE_SETUP_ARG(ret, th, iseq, orig_argc, orig_argv, block) \
+#define VM_CALLEE_SETUP_ARG(ret, th, iseq, orig_argc, orig_argv, block, e) \
if (LIKELY(iseq->arg_simple & 0x01)) { \
/* simple check */ \
+ e = -1; \
+ ret = 0; \
if (orig_argc != iseq->argc) { \
- rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", orig_argc, iseq->argc); \
+ e = iseq->argc; \
} \
- ret = 0; \
} \
else { \
- ret = vm_callee_setup_arg_complex(th, iseq, orig_argc, orig_argv, block); \
+ ret = vm_callee_setup_arg_complex(th, iseq, orig_argc, orig_argv, block, &e); \
}
static inline int
vm_callee_setup_arg_complex(rb_thread_t *th, const rb_iseq_t * iseq,
int orig_argc, VALUE * orig_argv,
- const rb_block_t **block)
+ const rb_block_t **block, int *argerr)
{
const int m = iseq->argc;
int argc = orig_argc;
@@ -124,8 +125,11 @@ vm_callee_setup_arg_complex(rb_thread_t *th, const rb_iseq_t * iseq,
/* mandatory */
if (argc < (m + iseq->arg_post_len)) { /* check with post arg */
- rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)",
- argc, m + iseq->arg_post_len);
+ *argerr = m + iseq->arg_post_len;
+ return 0;
+ }
+ else {
+ *argerr = -1;
}
argv += m;
@@ -443,8 +447,9 @@ vm_setup_method(rb_thread_t *th, rb_control_frame_t *cfp,
int opt_pc, i;
VALUE *sp, *rsp = cfp->sp - argc;
rb_iseq_t *iseq = me->def->body.iseq;
+ int eargc = 0;
- VM_CALLEE_SETUP_ARG(opt_pc, th, iseq, argc, rsp, &blockptr);
+ VM_CALLEE_SETUP_ARG(opt_pc, th, iseq, argc, rsp, &blockptr, eargc);
/* stack overflow check */
CHECK_STACK_OVERFLOW(cfp, iseq->stack_max);
@@ -487,6 +492,9 @@ vm_setup_method(rb_thread_t *th, rb_control_frame_t *cfp,
VM_FRAME_MAGIC_METHOD, recv, (VALUE) blockptr,
iseq->iseq_encoded + opt_pc, sp, 0, 0);
}
+ if (eargc >= 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, eargc);
+ }
}
static inline VALUE
@@ -886,8 +894,11 @@ vm_yield_setup_args(rb_thread_t * const th, const rb_iseq_t *iseq,
if (lambda) {
/* call as method */
- int opt_pc;
- VM_CALLEE_SETUP_ARG(opt_pc, th, iseq, argc, argv, &blockptr);
+ int opt_pc, e;
+ VM_CALLEE_SETUP_ARG(opt_pc, th, iseq, argc, argv, &blockptr, e);
+ if (e >= 0) {
+ rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", argc, e);
+ }
return opt_pc;
}
else {