diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-03 10:59:44 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-04-03 10:59:44 +0000 |
commit | ccf20a6d3fca0ae3a6817387622892c4db340032 (patch) | |
tree | 10b0bc74a9d7ed4ef27d6ac558c5b962126437e1 | |
parent | 9729ba32d0d07f7395205b65faacf0cffdbc0b5e (diff) | |
download | ruby-ccf20a6d3fca0ae3a6817387622892c4db340032.tar.gz |
* insns.def (defineclass): check if cbase is a class or a module.
[ruby-core:16118]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | insns.def | 4 | ||||
-rw-r--r-- | vm_insnhelper.c | 22 |
3 files changed, 23 insertions, 8 deletions
@@ -1,3 +1,8 @@ +Thu Apr 3 19:59:42 2008 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * insns.def (defineclass): check if cbase is a class or a module. + [ruby-core:16118] + Thu Apr 3 14:42:11 2008 NAKAMURA Usaku <usa@ruby-lang.org> * common.mk (INSNS): add insns_info.inc. @@ -943,6 +943,8 @@ defineclass cbase = vm_get_cbase(th); } + vm_check_if_namespace(cbase); + /* find klass */ if (rb_const_defined_at(cbase, id)) { /* already exist */ @@ -981,6 +983,8 @@ defineclass cbase = vm_get_cbase(th); } + vm_check_if_namespace(cbase); + /* find klass */ if (rb_const_defined_at(cbase, id)) { klass = rb_const_get_at(cbase, id); diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 6e0d8f30cb..dd72601668 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -976,6 +976,19 @@ vm_getspecial(rb_thread_t *th, VALUE *lfp, VALUE key, rb_num_t type) return val; } +static inline void +vm_check_if_namespace(VALUE klass) +{ + switch (TYPE(klass)) { + case T_CLASS: + case T_MODULE: + break; + default: + rb_raise(rb_eTypeError, "%s is not a class/module", + RSTRING_PTR(rb_obj_as_string(klass))); + } +} + static inline VALUE vm_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq, VALUE klass, ID id, int is_defined) @@ -1030,14 +1043,7 @@ vm_get_ev_const(rb_thread_t *th, rb_iseq_t *iseq, } } else { - switch (TYPE(klass)) { - case T_CLASS: - case T_MODULE: - break; - default: - rb_raise(rb_eTypeError, "%s is not a class/module", - RSTRING_PTR(rb_obj_as_string(klass))); - } + vm_check_if_namespace(klass); if (is_defined) { return rb_const_defined(klass, id); } |