* include/ruby/node.h: add new constants for rb_call()'s scope.

* eval.c (iterate_method): use CALL_* scope constant to specify
  proper scope value.

* eval.c (rb_each, rb_apply, rb_funcall, rb_funcall2, rb_funcall3):
  ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-04-01 21:30:36 +00:00
parent ddf9b405ad
commit a4d6f2265a
4 changed files with 22 additions and 11 deletions

View File

@ -1,3 +1,13 @@
Wed Apr 2 06:24:06 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* include/ruby/node.h: add new constants for rb_call()'s scope.
* eval.c (iterate_method): use CALL_* scope constant to specify
proper scope value.
* eval.c (rb_each, rb_apply, rb_funcall, rb_funcall2, rb_funcall3):
ditto.
Tue Apr 1 21:19:41 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* rational.c: need to include <float.h> just once.

15
eval.c
View File

@ -1069,7 +1069,7 @@ iterate_method(VALUE obj)
arg = (struct iter_method_arg *)obj;
return rb_call(CLASS_OF(arg->obj), arg->obj, arg->mid,
arg->argc, arg->argv, NOEX_PRIVATE);
arg->argc, arg->argv, CALL_FCALL);
}
VALUE
@ -1088,8 +1088,7 @@ rb_block_call(VALUE obj, ID mid, int argc, VALUE *argv,
VALUE
rb_each(VALUE obj)
{
return rb_call(CLASS_OF(obj), obj, rb_intern("each"), 0, 0,
NOEX_PRIVATE);
return rb_call(CLASS_OF(obj), obj, rb_intern("each"), 0, 0, CALL_FCALL);
}
VALUE
@ -1458,7 +1457,7 @@ rb_apply(VALUE recv, ID mid, VALUE args)
argc = RARRAY_LEN(args); /* Assigns LONG, but argc is INT */
argv = ALLOCA_N(VALUE, argc);
MEMCPY(argv, RARRAY_PTR(args), VALUE, argc);
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, NOEX_NOSUPER);
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, CALL_FCALL);
}
static VALUE
@ -1538,21 +1537,19 @@ rb_funcall(VALUE recv, ID mid, int n, ...)
else {
argv = 0;
}
return rb_call(CLASS_OF(recv), recv, mid, n, argv,
NOEX_NOSUPER | NOEX_PRIVATE);
return rb_call(CLASS_OF(recv), recv, mid, n, argv, CALL_FCALL);
}
VALUE
rb_funcall2(VALUE recv, ID mid, int argc, const VALUE *argv)
{
return rb_call(CLASS_OF(recv), recv, mid, argc, argv,
NOEX_NOSUPER | NOEX_PRIVATE);
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, CALL_FCALL);
}
VALUE
rb_funcall3(VALUE recv, ID mid, int argc, const VALUE *argv)
{
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, NOEX_PUBLIC);
return rb_call(CLASS_OF(recv), recv, mid, argc, argv, CALL_PUBLIC);
}
static VALUE

View File

@ -475,6 +475,11 @@ typedef struct RNode {
#define NOEX_WITH(n, s) ((s << 8) | n)
#define NOEX_WITH_SAFE(n) NOEX_WITH(n, rb_safe_level())
#define CALL_PUBLIC 0
#define CALL_FCALL 1
#define CALL_VCALL 2
#define CALL_SUPER 3
VALUE rb_parser_new(void);
VALUE rb_parser_end_seen_p(VALUE);
VALUE rb_parser_encoding(VALUE);

3
vm.c
View File

@ -501,7 +501,6 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv)
VALUE klass;
ID id;
NODE *body;
int nosuper = 0;
rb_control_frame_t *cfp = th->cfp;
if (!cfp->iseq) {
@ -530,7 +529,7 @@ vm_call_super(rb_thread_t *th, int argc, const VALUE *argv)
rb_bug("vm_call_super: not found");
}
return vm_call0(th, klass, recv, id, id, argc, argv, body, nosuper);
return vm_call0(th, klass, recv, id, id, argc, argv, body, CALL_SUPER);
}
VALUE