* eval.c (rb_f_send): do not call private methods if the receiver

is specified.  [ruby-talk:153672]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@9043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2005-08-30 04:27:41 +00:00
Родитель 0b7f8eef40
Коммит 10ebbcadd9
5 изменённых файлов: 21 добавлений и 4 удалений

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

@ -1,3 +1,8 @@
Tue Aug 30 12:45:15 2005 Yukihiro Matsumoto <matz@ruby-lang.org>
* eval.c (rb_f_send): do not call private methods if the receiver
is specified. [ruby-talk:153672]
Mon Aug 29 19:47:18 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* lib/rdoc/usage.rb: improper exceptions. [ruby-dev:26870]
@ -34,7 +39,6 @@ Sat Aug 27 20:13:31 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/curses/view.rb: String =~ String is deprecated.
>>>>>>> 1.4509
Thu Aug 25 15:48:58 2005 Hirokazu Yamamoto <ocean@m2.ccsnet.ne.jp>
* ext/win32ole/win32ole.c: supress warnings. (win32)

1
env.h
Просмотреть файл

@ -30,6 +30,7 @@ RUBY_EXTERN struct FRAME {
void rb_gc_mark_frame _((struct FRAME *));
#define FRAME_DMETH 1
#define FRAME_FUNC 2
RUBY_EXTERN struct SCOPE {
struct RBasic super;

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

@ -5844,6 +5844,7 @@ rb_call0(klass, recv, id, oid, argc, argv, body, flags)
ruby_frame->this_class = (flags & NOEX_NOSUPER)?0:klass;
ruby_frame->self = recv;
ruby_frame->argc = argc;
ruby_frame->flags = (flags & NOEX_RECV) ? FRAME_FUNC : 0;
switch (nd_type(body)) {
case NODE_CFUNC:
@ -6040,7 +6041,9 @@ rb_call(klass, recv, mid, argc, argv, scope)
return method_missing(recv, mid, argc, argv, CSTAT_PROT);
}
}
if (scope > 0) { /* pass receiver info */
noex |= NOEX_RECV;
}
return rb_call0(klass, recv, mid, id, argc, argv, body, noex);
}
@ -6084,12 +6087,13 @@ rb_f_send(argc, argv, recv)
VALUE recv;
{
VALUE vid;
int scope = (ruby_frame->flags & FRAME_FUNC) ? 1 : 0;
if (argc == 0) rb_raise(rb_eArgError, "no method name given");
vid = *argv++; argc--;
PUSH_ITER(rb_block_given_p()?ITER_PRE:ITER_NOT);
vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, 1);
vid = rb_call(CLASS_OF(recv), recv, rb_to_id(vid), argc, argv, scope);
POP_ITER();
return vid;

1
node.h
Просмотреть файл

@ -350,6 +350,7 @@ typedef struct RNode {
#define NOEX_MASK 6
#define NOEX_UNDEF NOEX_NOSUPER
#define NOEX_RECV 8
VALUE rb_parser_new _((void));
VALUE rb_parser_end_seen_p _((VALUE));

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

@ -4186,7 +4186,14 @@ f_block_arg : blkarg_mark tIDENTIFIER
yyerror("block argument must be local variable");
else if (!dyna_in_block() && local_id($2))
yyerror("duplicated block argument name");
$$ = dyna_in_block() ? assignable($2, 0) : NEW_BLOCK_ARG($2);
if (dyna_in_block()) {
shadowing_lvar($2);
dyna_var($2);
$$ = assignable($2, 0);
}
else {
$$ = NEW_BLOCK_ARG($2);
}
/*%
$$ = $2;
%*/