summaryrefslogtreecommitdiff
path: root/insns.def
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-05 02:27:29 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-05 02:27:29 +0000
commita823fc5d8bb87d978b3027b5efe3c76e08e9e4ae (patch)
treeb0702f4e904be214d914e51ad4a763a5ba3bf13b /insns.def
parent3e8e963837c27554d393dcde695c7fc2a43d79e9 (diff)
* compile.c (compile_cpath): use Qundef to denote cbase lookup.
* insns.def (defineclass): Qudef is passed for cbase. * insns.def (setconstant): ditto. * vm_insnhelper.c (vm_check_if_namespace): use rb_inspect() instead of rb_obj_as_string() for better description. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16290 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'insns.def')
-rw-r--r--insns.def25
1 files changed, 9 insertions, 16 deletions
diff --git a/insns.def b/insns.def
index cb7802e704..69849ff41e 100644
--- a/insns.def
+++ b/insns.def
@@ -240,24 +240,14 @@ setconstant
(VALUE val, VALUE klass)
()
{
- if (klass == Qnil) {
+ if (klass == Qundef) {
klass = vm_get_cbase(th);
- }
- if (NIL_P(klass)) {
- rb_raise(rb_eTypeError, "no class/module to define constant");
- }
-
- switch (TYPE(klass)) {
- case T_CLASS:
- case T_MODULE:
- break;
- default: {
- volatile VALUE tmp = rb_obj_as_string(klass);
- rb_raise(rb_eTypeError, "%s is not a class/module",
- RSTRING_PTR(tmp));
- }
+ if (NIL_P(klass)) {
+ rb_raise(rb_eTypeError, "no class/module to define constant");
+ }
}
+ vm_check_if_namespace(klass);
rb_const_set(klass, id, val);
INC_VM_STATE_VERSION();
}
@@ -939,8 +929,11 @@ defineclass
super = rb_cObject;
}
- if (cbase == Qnil) {
+ if (cbase == Qundef) {
cbase = vm_get_cbase(th);
+ if (NIL_P(klass)) {
+ rb_raise(rb_eTypeError, "no class/module to define constant");
+ }
}
vm_check_if_namespace(cbase);