summaryrefslogtreecommitdiffstats
path: root/eval_method.ci
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-22 21:16:21 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-09-22 21:16:21 +0000
commite720c83a5f8535e915d37cfd18b6f91cab98701c (patch)
treeff67564f114b9d55b30f109fef65181015a195e8 /eval_method.ci
parent3914cdeba080516b59d471e3e46598ef251e42c3 (diff)
downloadruby-e720c83a5f8535e915d37cfd18b6f91cab98701c.tar.gz
ruby-e720c83a5f8535e915d37cfd18b6f91cab98701c.tar.xz
ruby-e720c83a5f8535e915d37cfd18b6f91cab98701c.zip
* eval_method.ci (remove_method): check for undefined method.
[ruby-dev:31816] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13491 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_method.ci')
-rw-r--r--eval_method.ci19
1 files changed, 12 insertions, 7 deletions
diff --git a/eval_method.ci b/eval_method.ci
index 08ba95337..762e05aff 100644
--- a/eval_method.ci
+++ b/eval_method.ci
@@ -140,9 +140,11 @@ rb_add_method(VALUE klass, ID mid, NODE * node, int noex)
{
/* check re-definition */
+ st_data_t data;
NODE *old_node;
- if (st_lookup(RCLASS(klass)->m_tbl, mid, (st_data_t *)&old_node)) {
+ if (st_lookup(RCLASS(klass)->m_tbl, mid, &data)) {
+ old_node = (NODE *)data;
if (old_node) {
if (nd_type(old_node->nd_body->nd_body) == NODE_CFUNC) {
rb_vm_check_redefinition_opt_method(old_node);
@@ -208,13 +210,13 @@ rb_get_alloc_func(VALUE klass)
static NODE *
search_method(VALUE klass, ID id, VALUE *klassp)
{
- NODE *body;
+ st_data_t body;
if (!klass) {
return 0;
}
- while (!st_lookup(RCLASS(klass)->m_tbl, id, (st_data_t *) & body)) {
+ while (!st_lookup(RCLASS(klass)->m_tbl, id, &body)) {
klass = RCLASS(klass)->super;
if (!klass)
return 0;
@@ -224,7 +226,7 @@ search_method(VALUE klass, ID id, VALUE *klassp)
*klassp = klass;
}
- return body;
+ return (NODE *)body;
}
/*
@@ -289,6 +291,7 @@ rb_method_node(VALUE klass, ID id)
static void
remove_method(VALUE klass, ID mid)
{
+ st_data_t data;
NODE *body;
if (klass == rb_cObject) {
@@ -302,8 +305,8 @@ remove_method(VALUE klass, ID mid)
if (mid == object_id || mid == __send || mid == __send_bang || mid == init) {
rb_warn("removing `%s' may cause serious problem", rb_id2name(mid));
}
- if (!st_delete(RCLASS(klass)->m_tbl, &mid, (st_data_t *) & body) ||
- !body->nd_body) {
+ if (!st_delete(RCLASS(klass)->m_tbl, &mid, &data) ||
+ !(body = (NODE *)data) || !body->nd_body) {
rb_name_error(mid, "method `%s' not defined in %s",
rb_id2name(mid), rb_class2name(klass));
}
@@ -556,6 +559,7 @@ rb_alias(VALUE klass, ID name, ID def)
{
NODE *orig_fbody, *node;
VALUE singleton = 0;
+ st_data_t data;
rb_frozen_class_p(klass);
if (name == def)
@@ -578,7 +582,8 @@ rb_alias(VALUE klass, ID name, ID def)
orig_fbody->nd_cnt++;
- if (st_lookup(RCLASS(klass)->m_tbl, name, (st_data_t *) & node)) {
+ if (st_lookup(RCLASS(klass)->m_tbl, name, &data)) {
+ node = (NODE *)data;
if (node) {
if (RTEST(ruby_verbose) && node->nd_cnt == 0 && node->nd_body) {
rb_warning("discarding old %s", rb_id2name(name));