summaryrefslogtreecommitdiff
path: root/vm.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-03 01:39:16 (GMT)
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-03 01:39:16 (GMT)
commit18bbd05709a4d52704ac217f30c0d9f35830b7f0 (patch)
tree3d4e87205d6917410a460a99b6ad15a46beb0572 /vm.c
parent938eb46e807ef8230357b3a56b5cd5797e0188ae (diff)
* method.h: split rb_method_definition_t::flag to several flags.
`flag' contains several categories of attributes and it makes us confusion (at least, I had confused). * rb_method_visibility_t (flags::visi) * NOEX_UNDEF -> METHOD_VISI_UNDEF = 0 * NOEX_PUBLIC -> METHOD_VISI_PUBLIC = 1 * NOEX_PRIVATE -> METHOD_VISI_PRIVATE = 2 * NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3 * NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits) * NOEX_BASIC -> basic (flags::basic, 1 bit) * NOEX_MODFUNC -> rb_scope_visibility_t in CREF * NOEX_SUPER -> MISSING_SUPER (enum missing_reason) * NOEX_VCALL -> MISSING_VCALL (enum missing_reason) * NOEX_RESPONDS -> BOUND_RESPONDS (macro) Now, NOEX_NOREDEF is not supported (I'm not sure it is needed). Background: I did not know what "NOEX" stands for. I asked Matz (who made this name) and his answer was "Nothing". "At first, it meant NO EXport (private), but the original meaning was gone." This is why I remove the mysterious word "NOEX" from MRI. * vm_core.h: introduce `enum missing_reason' to represent method_missing (NoMethodError) reason. * eval_intern.h: introduce rb_scope_visibility_t to represent scope visibility. It has 3 method visibilities (public/private/protected) and `module_function`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/vm.c b/vm.c
index 461097d..6b3f4fe 100644
--- a/vm.c
+++ b/vm.c
@@ -89,10 +89,10 @@ vm_cref_new(VALUE klass, long visi, const rb_cref_t *prev_cref)
static rb_cref_t *
vm_cref_new_toplevel(rb_thread_t *th)
{
- rb_cref_t *cref = vm_cref_new(rb_cObject, NOEX_PRIVATE /* toplevel visibility is private */, NULL);
+ rb_cref_t *cref = vm_cref_new(rb_cObject, METHOD_VISI_PRIVATE /* toplevel visibility is private */, NULL);
if (th->top_wrapper) {
- cref = vm_cref_new(th->top_wrapper, NOEX_PRIVATE, cref);
+ cref = vm_cref_new(th->top_wrapper, METHOD_VISI_PRIVATE, cref);
}
return cref;
@@ -2285,7 +2285,8 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
rb_num_t is_singleton, rb_cref_t *cref)
{
VALUE klass = CREF_CLASS(cref);
- rb_method_flag_t noex = (rb_method_flag_t)CREF_VISI(cref);
+ const rb_scope_visibility_t *scope_visi = CREF_SCOPE_VISI(cref);
+ rb_method_visibility_t visi = scope_visi->method_visi;
rb_iseq_t *miseq;
GetISeqPtr(iseqval, miseq);
@@ -2300,17 +2301,17 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
if (is_singleton) {
klass = rb_singleton_class(obj); /* class and frozen checked in this API */
- noex = NOEX_PUBLIC;
+ visi = METHOD_VISI_PUBLIC;
}
/* dup */
RB_OBJ_WRITE(miseq->self, &miseq->klass, klass);
miseq->defined_method_id = id;
- rb_add_method_iseq(klass, id, iseqval, cref, noex);
+ rb_add_method_iseq(klass, id, iseqval, cref, visi);
- if (!is_singleton && noex == NOEX_MODFUNC) {
+ if (!is_singleton && scope_visi->module_func) {
klass = rb_singleton_class(klass);
- rb_add_method_iseq(klass, id, iseqval, cref, NOEX_PUBLIC);
+ rb_add_method_iseq(klass, id, iseqval, cref, METHOD_VISI_PUBLIC);
}
}
@@ -2797,7 +2798,7 @@ Init_VM(void)
th->cfp->self = th->top_self;
th->cfp->klass = Qnil;
- th->cfp->ep[-1] = (VALUE)vm_cref_new(rb_cObject, NOEX_PRIVATE, NULL);
+ th->cfp->ep[-1] = (VALUE)vm_cref_new(rb_cObject, METHOD_VISI_PRIVATE, NULL);
/*
* The Binding of the top level scope