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

* vm_eval.c (vm_call0, vm_call_super, rb_f_send, rb_f_public_send):

fixed call_type.  [ruby-dev:39581]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2009-10-30 07:57:21 +00:00
parent 35b88be02b
commit 166a53c560
3 changed files with 37 additions and 8 deletions

View file

@ -1,4 +1,7 @@
Fri Oct 30 16:42:03 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Fri Oct 30 16:57:19 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_eval.c (vm_call0, vm_call_super, rb_f_send, rb_f_public_send):
fixed call_type. [ruby-dev:39581]
* vm_eval.c (rb_search_method_emtry, rb_method_call_status): spli * vm_eval.c (rb_search_method_emtry, rb_method_call_status): spli
from rb_call0(). from rb_call0().

View file

@ -377,6 +377,31 @@ class TestObject < Test::Unit::TestCase
assert_raise(ArgumentError) { 1.send } assert_raise(ArgumentError) { 1.send }
end end
def test_no_superclass_method
bug2312 = '[ruby-dev:39581]'
o = Object.new
e = assert_raise(NoMethodError) {
o.method(:__send__).call(:never_defined_test_no_superclass_method)
}
m1 = e.message
assert_no_match(/no superclass method/, m1, bug2312)
e = assert_raise(NoMethodError) {
o.method(:__send__).call(:never_defined_test_no_superclass_method)
}
assert_equal(m1, e.message, bug2312)
e = assert_raise(NoMethodError) {
o.never_defined_test_no_superclass_method
}
assert_equal(m1, e.message, bug2312)
end
def test_superclass_method
bug2312 = '[ruby-dev:39581]'
assert_in_out_err(["-e", "module Enumerable;undef min;end; (1..2).min{}"],
[], [], /no superclass method/, bug2312)
end
def test_specific_eval_with_wrong_arguments def test_specific_eval_with_wrong_arguments
assert_raise(ArgumentError) do assert_raise(ArgumentError) do
1.instance_eval("foo") { foo } 1.instance_eval("foo") { foo }

View file

@ -21,7 +21,6 @@ static NODE *vm_cref_push(rb_thread_t *th, VALUE klass, int noex);
static VALUE vm_exec(rb_thread_t *th); static VALUE vm_exec(rb_thread_t *th);
static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref); static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref);
static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary); static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary);
static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, int scope);
typedef enum call_type { typedef enum call_type {
CALL_PUBLIC, CALL_PUBLIC,
@ -29,6 +28,8 @@ typedef enum call_type {
CALL_VCALL, CALL_VCALL,
} call_type; } call_type;
static VALUE send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope);
static inline VALUE static inline VALUE
vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv, vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
const rb_method_entry_t *me) const rb_method_entry_t *me)
@ -104,7 +105,7 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
case VM_METHOD_TYPE_ZSUPER: { case VM_METHOD_TYPE_ZSUPER: {
klass = RCLASS_SUPER(klass); klass = RCLASS_SUPER(klass);
if (!klass || !(me = rb_method_entry(klass, id))) { if (!klass || !(me = rb_method_entry(klass, id))) {
return method_missing(recv, id, argc, argv, 0); return method_missing(recv, id, argc, argv, NOEX_SUPER);
} }
RUBY_VM_CHECK_INTS(); RUBY_VM_CHECK_INTS();
if (!(def = me->def)) return Qnil; if (!(def = me->def)) return Qnil;
@ -121,7 +122,7 @@ vm_call0(rb_thread_t* th, VALUE recv, VALUE id, int argc, const VALUE *argv,
case VM_METHOD_TYPE_OPTIMIZED: { case VM_METHOD_TYPE_OPTIMIZED: {
switch (def->body.optimize_type) { switch (def->body.optimize_type) {
case OPTIMIZED_METHOD_TYPE_SEND: case OPTIMIZED_METHOD_TYPE_SEND:
val = send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE); val = send_internal(argc, argv, recv, CALL_FCALL);
break; break;
case OPTIMIZED_METHOD_TYPE_CALL: { case OPTIMIZED_METHOD_TYPE_CALL: {
rb_proc_t *proc; rb_proc_t *proc;
@ -175,7 +176,7 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv)
me = rb_method_entry(klass, id); me = rb_method_entry(klass, id);
if (!me) { if (!me) {
return method_missing(recv, id, argc, argv, 0); return method_missing(recv, id, argc, argv, NOEX_SUPER);
} }
return vm_call0(th, recv, id, argc, argv, me); return vm_call0(th, recv, id, argc, argv, me);
@ -573,7 +574,7 @@ rb_funcall3(VALUE recv, ID mid, int argc, const VALUE *argv)
} }
static VALUE static VALUE
send_internal(int argc, const VALUE *argv, VALUE recv, int scope) send_internal(int argc, const VALUE *argv, VALUE recv, call_type scope)
{ {
VALUE vid; VALUE vid;
VALUE self = RUBY_VM_PREVIOUS_CONTROL_FRAME(GET_THREAD()->cfp)->self; VALUE self = RUBY_VM_PREVIOUS_CONTROL_FRAME(GET_THREAD()->cfp)->self;
@ -610,7 +611,7 @@ send_internal(int argc, const VALUE *argv, VALUE recv, int scope)
VALUE VALUE
rb_f_send(int argc, VALUE *argv, VALUE recv) rb_f_send(int argc, VALUE *argv, VALUE recv)
{ {
return send_internal(argc, argv, recv, NOEX_NOSUPER | NOEX_PRIVATE); return send_internal(argc, argv, recv, CALL_FCALL);
} }
/* /*
@ -627,7 +628,7 @@ rb_f_send(int argc, VALUE *argv, VALUE recv)
VALUE VALUE
rb_f_public_send(int argc, VALUE *argv, VALUE recv) rb_f_public_send(int argc, VALUE *argv, VALUE recv)
{ {
return send_internal(argc, argv, recv, NOEX_PUBLIC); return send_internal(argc, argv, recv, CALL_PUBLIC);
} }
/* yield */ /* yield */