1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@25521 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2009-10-28 04:20:35 +00:00
parent db115a545f
commit 2e868a3442
2 changed files with 33 additions and 11 deletions

View file

@ -12,6 +12,17 @@ Wed Oct 28 13:02:10 2009 Shugo Maeda <shugo@ruby-lang.org>
* lib/net/ftp.rb (Net::FTP#login): calls send_type_command instead
of binary=.
Wed Oct 28 12:26:51 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* 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.
Tue Oct 27 22:46:44 2009 NARUSE, Yui <naruse@ruby-lang.org>
* lib/net/ftp.rb (Net::FTP#initialize): @sock = nil.

View file

@ -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 */ \
if (orig_argc != iseq->argc) { \
rb_raise(rb_eArgError, "wrong number of arguments (%d for %d)", orig_argc, iseq->argc); \
} \
e = -1; \
ret = 0; \
if (orig_argc != iseq->argc) { \
e = iseq->argc; \
} \
} \
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 {