aboutsummaryrefslogtreecommitdiffstats
path: root/eval_error.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-03 01:39:16 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-06-03 01:39:16 +0000
commit97119d8eb9ed654ba38cb3769c777bdb40492b1e (patch)
tree3d4e87205d6917410a460a99b6ad15a46beb0572 /eval_error.c
parent83c95981d9c9e4eabc5526f7d30d4c7137c585ec (diff)
downloadruby-97119d8eb9ed654ba38cb3769c777bdb40492b1e.tar.gz
* 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 'eval_error.c')
-rw-r--r--eval_error.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/eval_error.c b/eval_error.c
index c32eff13f2..0f2f165cc8 100644
--- a/eval_error.c
+++ b/eval_error.c
@@ -209,23 +209,22 @@ ruby_error_print(void)
}
static const char *
-method_scope_name(int scope)
+method_visibility_name(rb_method_visibility_t visi)
{
- const char *v;
-
- switch (scope) {
- default:
- case NOEX_PUBLIC: v = ""; break;
- case NOEX_PRIVATE: v = " private"; break;
- case NOEX_PROTECTED: v = " protected"; break;
+ switch (visi) {
+ case METHOD_VISI_UNDEF:
+ case METHOD_VISI_PUBLIC: return "";
+ case METHOD_VISI_PRIVATE: return " private";
+ case METHOD_VISI_PROTECTED: return " protected";
}
- return v;
+ rb_bug("method_visibility_name: unreachable (%d)", (int)visi);
}
void
-rb_print_undef(VALUE klass, ID id, int scope)
+rb_print_undef(VALUE klass, ID id, int visi)
{
- const char *v = method_scope_name(scope);
+ const char *v = method_visibility_name(visi);
+
rb_name_error(id, "undefined%s method `%"PRIsVALUE"' for %s `% "PRIsVALUE"'", v,
QUOTE_ID(id),
(RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
@@ -242,9 +241,9 @@ rb_print_undef_str(VALUE klass, VALUE name)
}
void
-rb_print_inaccessible(VALUE klass, ID id, int scope)
+rb_print_inaccessible(VALUE klass, ID id, rb_method_visibility_t visi)
{
- const char *v = method_scope_name(scope);
+ const char *v = method_visibility_name(visi);
rb_name_error(id, "method `%"PRIsVALUE"' for %s `% "PRIsVALUE"' is %s",
QUOTE_ID(id),
(RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",