summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-27 07:48:50 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-06-27 07:48:50 +0000
commit8ddbbb33242f413845079b0274c28331cb4aa0f5 (patch)
tree522b12dada77b09073a58130c99c77d62c895b87 /vm_method.c
parent8634544fa74be0995582bc8056763fcfd38a0702 (diff)
Module#prepend
* class.c (rb_prepend_module): prepend module into another module. * eval.c (rb_mod_prepend): new method Module#prepend. [Feature #1102] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/vm_method.c b/vm_method.c
index c9f0130512..5a7722cd67 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -169,6 +169,9 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
rb_method_definition_t *def, rb_method_flag_t noex)
{
rb_method_entry_t *me;
+#if NOEX_NOREDEF
+ VALUE rklass;
+#endif
st_table *mtbl;
st_data_t data;
@@ -194,6 +197,10 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
}
rb_check_frozen(klass);
+#if NOEX_NOREDEF
+ rklass = klass;
+#endif
+ klass = RCLASS_ORIGIN(klass);
mtbl = RCLASS_M_TBL(klass);
/* check re-definition */
@@ -205,7 +212,7 @@ rb_method_entry_make(VALUE klass, ID mid, rb_method_type_t type,
#if NOEX_NOREDEF
if (old_me->flag & NOEX_NOREDEF) {
rb_raise(rb_eTypeError, "cannot redefine %"PRIsVALUE"#%"PRIsVALUE,
- rb_class_name(klass), rb_id2str(mid));
+ rb_class_name(rklass), rb_id2str(mid));
}
#endif
rb_vm_check_redefinition_opt_method(old_me, klass);
@@ -384,7 +391,7 @@ search_method(VALUE klass, ID id)
return 0;
}
- while (!st_lookup(RCLASS_M_TBL(klass), id, &body)) {
+ while (!RCLASS_M_TBL(klass) || !st_lookup(RCLASS_M_TBL(klass), id, &body)) {
klass = RCLASS_SUPER(klass);
if (!klass) {
return 0;