* eval.c (rb_add_method, rb_alias): need to clear cache by
ID when method defined in parent class is cached for grand child classes. [ruby-dev:20672] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4075 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9a3da66892
commit
0caa77e7bc
@ -1,3 +1,9 @@
|
|||||||
|
Tue Jul 15 19:50:49 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
|
* eval.c (rb_add_method, rb_alias): need to clear cache by
|
||||||
|
ID when method defined in parent class is cached for
|
||||||
|
grand child classes. [ruby-dev:20672]
|
||||||
|
|
||||||
Tue Jul 15 14:38:21 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Tue Jul 15 14:38:21 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* lib/matrix.rb: remove elements conversion to_f, to_i, to_r.
|
* lib/matrix.rb: remove elements conversion to_f, to_i, to_r.
|
||||||
|
21
eval.c
21
eval.c
@ -231,6 +231,22 @@ rb_clear_cache_for_undef(klass, id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
rb_clear_cache_by_id(id)
|
||||||
|
ID id;
|
||||||
|
{
|
||||||
|
struct cache_entry *ent, *end;
|
||||||
|
|
||||||
|
if (!ruby_running) return;
|
||||||
|
ent = cache; end = ent + CACHE_SIZE;
|
||||||
|
while (ent < end) {
|
||||||
|
if (ent->mid == id) {
|
||||||
|
ent->mid = 0;
|
||||||
|
}
|
||||||
|
ent++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_clear_cache_by_class(klass)
|
rb_clear_cache_by_class(klass)
|
||||||
VALUE klass;
|
VALUE klass;
|
||||||
@ -276,7 +292,7 @@ rb_add_method(klass, mid, node, noex)
|
|||||||
mid = ID_ALLOCATOR;
|
mid = ID_ALLOCATOR;
|
||||||
}
|
}
|
||||||
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
|
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
|
||||||
rb_clear_cache_for_undef(klass, mid);
|
rb_clear_cache_by_id(mid);
|
||||||
body = NEW_METHOD(node, noex);
|
body = NEW_METHOD(node, noex);
|
||||||
st_insert(RCLASS(klass)->m_tbl, mid, (st_data_t)body);
|
st_insert(RCLASS(klass)->m_tbl, mid, (st_data_t)body);
|
||||||
if (node && mid != ID_ALLOCATOR && ruby_running) {
|
if (node && mid != ID_ALLOCATOR && ruby_running) {
|
||||||
@ -1820,7 +1836,6 @@ rb_undef(klass, id)
|
|||||||
rb_name_error(id, "undefined method `%s' for%s `%s'",
|
rb_name_error(id, "undefined method `%s' for%s `%s'",
|
||||||
rb_id2name(id),s0,rb_class2name(c));
|
rb_id2name(id),s0,rb_class2name(c));
|
||||||
}
|
}
|
||||||
if (klass != origin) rb_clear_cache_for_undef(origin, id);
|
|
||||||
rb_add_method(klass, id, 0, NOEX_PUBLIC);
|
rb_add_method(klass, id, 0, NOEX_PUBLIC);
|
||||||
if (FL_TEST(klass, FL_SINGLETON)) {
|
if (FL_TEST(klass, FL_SINGLETON)) {
|
||||||
rb_funcall(rb_iv_get(klass, "__attached__"),
|
rb_funcall(rb_iv_get(klass, "__attached__"),
|
||||||
@ -1879,7 +1894,7 @@ rb_alias(klass, name, def)
|
|||||||
body = body->nd_head;
|
body = body->nd_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_clear_cache_for_undef(klass, name);
|
rb_clear_cache_by_id(name);
|
||||||
st_insert(RCLASS(klass)->m_tbl, name,
|
st_insert(RCLASS(klass)->m_tbl, name,
|
||||||
(st_data_t)NEW_METHOD(NEW_FBODY(body, def, origin), orig->nd_noex));
|
(st_data_t)NEW_METHOD(NEW_FBODY(body, def, origin), orig->nd_noex));
|
||||||
if (singleton) {
|
if (singleton) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user