1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

eval_error.c: rb_print_inaccessible

* eval_error.c (rb_print_inaccessible): exract from mnew_from_me()
  in proc.c

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-07-26 16:13:21 +00:00
parent 61fd977798
commit c56b3d1418
3 changed files with 22 additions and 12 deletions

View file

@ -208,8 +208,8 @@ ruby_error_print(void)
error_print();
}
void
rb_print_undef(VALUE klass, ID id, int scope)
static const char *
method_scope_name(int scope)
{
const char *v;
@ -219,6 +219,13 @@ rb_print_undef(VALUE klass, ID id, int scope)
case NOEX_PRIVATE: v = " private"; break;
case NOEX_PROTECTED: v = " protected"; break;
}
return v;
}
void
rb_print_undef(VALUE klass, ID id, int scope)
{
const char *v = method_scope_name(scope);
rb_name_error(id, "undefined%s method `%"PRIsVALUE"' for %s `%"PRIsVALUE"'", v,
QUOTE_ID(id),
(RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
@ -234,6 +241,17 @@ rb_print_undef_str(VALUE klass, VALUE name)
rb_class_name(klass));
}
void
rb_print_inaccessible(VALUE klass, ID id, int scope)
{
const char *v = method_scope_name(scope);
rb_name_error(id, "method `%s' for %s `% "PRIsVALUE"' is %s",
rb_id2name(id),
(RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
rb_class_name(klass),
v);
}
static int
sysexit_status(VALUE err)
{

View file

@ -238,6 +238,7 @@ NORETURN(void rb_fiber_start(void));
NORETURN(void rb_print_undef(VALUE, ID, int));
NORETURN(void rb_print_undef_str(VALUE, VALUE));
NORETURN(void rb_print_inaccessible(VALUE, ID, int));
NORETURN(void rb_vm_localjump_error(const char *,VALUE, int));
NORETURN(void rb_vm_jump_tag_but_local_jump(int));
NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv,

11
proc.c
View file

@ -1219,16 +1219,7 @@ mnew_from_me(rb_method_entry_t *me, VALUE defined_class, VALUE klass,
if (flag == NOEX_UNDEF) {
flag = me->flag;
if (scope && (flag & NOEX_MASK) != NOEX_PUBLIC) {
const char *v = "";
switch (flag & NOEX_MASK) {
case NOEX_PRIVATE: v = "private"; break;
case NOEX_PROTECTED: v = "protected"; break;
}
rb_name_error(id, "method `%s' for %s `% "PRIsVALUE"' is %s",
rb_id2name(id),
(RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
rb_class_name(klass),
v);
rb_print_inaccessible(klass, id, flag & NOEX_MASK);
}
}
if (def && def->type == VM_METHOD_TYPE_ZSUPER) {