summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-12 03:44:40 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-03-12 03:44:40 +0000
commita2229db3e8a88002697ee2fcb45128bcf4914bbd (patch)
tree3a4540a7f5b889307fb1215b3d3bbab179c194a5 /vm_method.c
parentb19f3a8a1592bf32bd83e02c433715cd67923d1d (diff)
* vm_method.c (Init_eval_method): copy basic methods to Exception.
[ruby-core:40287][Bug #5473] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/vm_method.c b/vm_method.c
index d9f4a0315a..aa636d02ea 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -6,6 +6,8 @@
#define CACHE_MASK 0x7ff
#define EXPR1(c,m) ((((c)>>3)^(m))&CACHE_MASK)
+#define NOEX_NOREDEF NOEX_RESPONDS
+
static void rb_vm_check_redefinition_opt_method(const rb_method_entry_t *me, VALUE klass);
static ID object_id, respond_to_missing;
@@ -195,6 +197,11 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
rb_method_definition_t *old_def = old_me->def;
if (rb_method_definition_eq(old_def, def)) return old_me;
+#if 0
+ if (old_me->flag & NOEX_NOREDEF) {
+ rb_raise(rb_eTypeError, "cannot redefine %s#%s", rb_class2name(klass), rb_id2name(mid));
+ }
+#endif
rb_vm_check_redefinition_opt_method(old_me, klass);
if (RTEST(ruby_verbose) &&
@@ -1385,5 +1392,14 @@ Init_eval_method(void)
singleton_undefined = rb_intern("singleton_method_undefined");
attached = rb_intern("__attached__");
respond_to_missing = rb_intern("respond_to_missing?");
+
+ {
+#define REPLICATE_METHOD(klass, id) \
+ rb_method_entry_set((klass), (id), rb_method_entry((klass), (id)), \
+ (rb_method_flag_t)(NOEX_PRIVATE | NOEX_BASIC | NOEX_NOREDEF))
+ REPLICATE_METHOD(rb_eException, idMethodMissing);
+ REPLICATE_METHOD(rb_eException, idRespond_to);
+ REPLICATE_METHOD(rb_eException, respond_to_missing);
+ }
}