aboutsummaryrefslogtreecommitdiffstats
path: root/error.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-28 04:41:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-02-28 04:41:38 +0000
commitd578f5ca81051cf8b6a724470a37ab02b4bc7aca (patch)
tree3075620060c592076e2df80b21949e7e1e0ed8cd /error.c
parentdc9d642ee5fd320319d06f89bbc7f16b24cd51ea (diff)
downloadruby-d578f5ca81051cf8b6a724470a37ab02b4bc7aca.tar.gz
NoMethodError#private_call?
* error.c (nometh_err_initialize): add private_call? parameter. * error.c (nometh_err_private_call_p): add private_call? method, to tell if the exception raised in private form FCALL or VCALL. [Feature #12043] * vm_eval.c (make_no_method_exception): append private_call? argument. * vm_insnhelper.c (ci_missing_reason): copy FCALL flag. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53961 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'error.c')
-rw-r--r--error.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/error.c b/error.c
index 204a9a6302..93cb6f03d6 100644
--- a/error.c
+++ b/error.c
@@ -697,6 +697,7 @@ static VALUE rb_eNOERROR;
static ID id_new, id_cause, id_message, id_backtrace;
static ID id_name, id_args, id_Errno, id_errno, id_i_path;
static ID id_receiver, id_iseq, id_local_variables;
+static ID id_private_call_p;
extern ID ruby_static_id_status;
#define id_bt idBt
#define id_bt_locations idBt_locations
@@ -1203,9 +1204,11 @@ name_err_local_variables(VALUE self)
static VALUE
nometh_err_initialize(int argc, VALUE *argv, VALUE self)
{
+ VALUE priv = (argc > 3) && (--argc, RTEST(argv[argc])) ? Qtrue : Qfalse;
VALUE args = (argc > 2) ? argv[--argc] : Qnil;
name_err_initialize(argc, argv, self);
rb_ivar_set(self, id_args, args);
+ rb_ivar_set(self, id_private_call_p, RTEST(priv) ? Qtrue : Qfalse);
return self;
}
@@ -1392,6 +1395,12 @@ nometh_err_args(VALUE self)
return rb_attr_get(self, id_args);
}
+static VALUE
+nometh_err_private_call_p(VALUE self)
+{
+ return rb_attr_get(self, id_private_call_p);
+}
+
void
rb_invalid_str(const char *str, const char *type)
{
@@ -2019,6 +2028,7 @@ Init_Exception(void)
rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError);
rb_define_method(rb_eNoMethodError, "initialize", nometh_err_initialize, -1);
rb_define_method(rb_eNoMethodError, "args", nometh_err_args, 0);
+ rb_define_method(rb_eNoMethodError, "private_call?", nometh_err_private_call_p, 0);
rb_eRuntimeError = rb_define_class("RuntimeError", rb_eStandardError);
rb_eSecurityError = rb_define_class("SecurityError", rb_eException);
@@ -2043,6 +2053,7 @@ Init_Exception(void)
id_name = rb_intern_const("name");
id_args = rb_intern_const("args");
id_receiver = rb_intern_const("receiver");
+ id_private_call_p = rb_intern_const("private_call?");
id_local_variables = rb_intern_const("local_variables");
id_Errno = rb_intern_const("Errno");
id_errno = rb_intern_const("errno");