* eval.c (send_internal): use self in the previous frame to check for

protected methods.  [ruby-core:13254]

* insnhelper.ci (vm_call_method): send! method has gone.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-11-09 01:43:57 +00:00
Родитель 9a0e440b81
Коммит 4155206ebd
3 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Fri Nov 9 10:43:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (send_internal): use self in the previous frame to check for
protected methods. [ruby-core:13254]
* insnhelper.ci (vm_call_method): send! method has gone.
Fri Nov 9 10:38:13 2007 Koichi Sasada <ko1@atdot.net>
* marshal.c (w_object): should be SPECIAL_CONST_P() instead of

14
eval.c
Просмотреть файл

@ -1355,7 +1355,7 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status)
}
static VALUE
rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope)
rb_call0(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope, VALUE self)
{
NODE *body, *method;
int noex;
@ -1409,8 +1409,7 @@ rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope)
defined_class = RBASIC(defined_class)->klass;
}
if (!rb_obj_is_kind_of(rb_frame_self(),
rb_class_real(defined_class))) {
if (!rb_obj_is_kind_of(self, rb_class_real(defined_class))) {
return method_missing(recv, mid, argc, argv, NOEX_PROTECTED);
}
}
@ -1442,6 +1441,12 @@ rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope)
}
}
static VALUE
rb_call(VALUE klass, VALUE recv, ID mid, int argc, const VALUE *argv, int scope)
{
return rb_call0(klass, recv, mid, argc, argv, scope, rb_frame_self());
}
VALUE
rb_apply(VALUE recv, ID mid, VALUE args)
{
@ -1458,6 +1463,7 @@ static VALUE
send_internal(int argc, VALUE *argv, VALUE recv, int scope)
{
VALUE vid;
VALUE self = RUBY_VM_PREVIOUS_CONTROL_FRAME(GET_THREAD()->cfp)->self;
if (argc == 0) {
rb_raise(rb_eArgError, "no method name given");
@ -1465,7 +1471,7 @@ send_internal(int argc, VALUE *argv, VALUE recv, int scope)
vid = *argv++; argc--;
PASS_PASSED_BLOCK();
return rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, scope);
return rb_call0(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, scope, self);
}
/*

Просмотреть файл

@ -547,7 +547,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp,
val = vm_method_missing(th, id, recv, num, blockptr, stat);
}
else if (((mn->nd_noex & NOEX_MASK) & NOEX_PROTECTED) &&
!(flag & VM_CALL_SEND_BANG_BIT)) {
!(flag & VM_CALL_SEND_BIT)) {
VALUE defined_class = mn->nd_clss;
if (TYPE(defined_class) == T_ICLASS) {