summaryrefslogtreecommitdiff
path: root/vm_eval.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-29 04:55:10 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-29 04:55:10 +0000
commit0580ba06110f7998fdaead724907a4c8d6540107 (patch)
tree4ceed7d1642d46a147114fc1a303ce5257af49bb /vm_eval.c
parent2bb26c118d9e52a52940f73c9cb1fc26e07003d6 (diff)
* array.c (rb_ary_to_ary): do not use #respond_to? to detect
to_ary. Just call. [ruby-core:23738] * eval.c (rb_check_funcall): new function with method existence check. returns Qundef when the method does not exist. * enumerator.c (enumerator_rewind): just call method, using rb_check_funcall(). [ruby-core:23738] * error.c (exc_equal): ditto. * object.c (convert_type): ditto. * error.c (rb_name_err_mesg_new): export function. * eval.c (make_exception): ditto. * io.c (pop_last_hash): return early when the last argument is nil. * io.c (rb_io_puts): treat T_STRING specially for small optimization. * vm_eval.c (raise_method_missing): skip method call if possible using rb_method_basic_definition_p(). * vm_eval.c (method_missing): ditto. * test/ruby/test_rubyoptions.rb (TestRubyOptions#test_debug): test suites changed to ignore exceptions caused by just-call policy. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/vm_eval.c b/vm_eval.c
index 967e24c694..8fbe82d102 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -390,9 +390,16 @@ raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj,
{
int n = 0;
+ VALUE mesg;
VALUE args[3];
- args[n++] = rb_funcall(rb_const_get(exc, rb_intern("message")), '!',
- 3, rb_str_new2(format), obj, argv[0]);
+
+ mesg = rb_const_get(exc, rb_intern("message"));
+ if (rb_method_basic_definition_p(CLASS_OF(mesg), '!')) {
+ args[n++] = rb_name_err_mesg_new(mesg, rb_str_new2(format), obj, argv[0]);
+ }
+ else {
+ args[n++] = rb_funcall(mesg, '!', 3, rb_str_new2(format), obj, argv[0]);
+ }
args[n++] = argv[0];
if (exc == rb_eNoMethodError) {
args[n++] = rb_ary_new4(argc - 1, argv + 1);
@@ -433,6 +440,9 @@ method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status)
nargv[0] = ID2SYM(id);
MEMCPY(nargv + 1, argv, VALUE, argc);
+ if (rb_method_basic_definition_p(CLASS_OF(obj) , idMethodMissing)) {
+ raise_method_missing(th, argc+1, nargv, obj, call_status | NOEX_MISSING);
+ }
result = rb_funcall2(obj, idMethodMissing, argc + 1, nargv);
if (argv_ary) rb_ary_clear(argv_ary);
return result;