summaryrefslogtreecommitdiff
path: root/class.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-26 17:27:21 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-10-26 17:27:21 +0000
commit2285a8d813814e936484d302dacf1ff39e40e33c (patch)
tree903b908f019dce423c6d691003f200176046895a /class.c
parent6ca3ad34a044f48fa25d250076f5e8c9c8810b38 (diff)
* class.c, gc.c, object.c, variable.c, vm_insnhelper.c,
include/ruby/ruby.h: separate RCLASS_CONST_TBL from RCLASS_IV_TBL. RCLASS_IV_TBL has contained not only instance variable table but also constant table. Now the two table are separated to RCLASS_CONST_TBL and RCLASS_IV_TBL. This is a preparation for private constant (see [ruby-dev:39685][ruby-core:32698]). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29600 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'class.c')
-rw-r--r--class.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/class.c b/class.c
index 31b407038e..a6634679d5 100644
--- a/class.c
+++ b/class.c
@@ -52,6 +52,7 @@ class_alloc(VALUE flags, VALUE klass)
OBJSETUP(obj, klass, flags);
obj->ptr = ext;
RCLASS_IV_TBL(obj) = 0;
+ RCLASS_CONST_TBL(obj) = 0;
RCLASS_M_TBL(obj) = 0;
RCLASS_SUPER(obj) = 0;
RCLASS_IV_INDEX_TBL(obj) = 0;
@@ -161,6 +162,12 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
CONST_ID(id, "__classid__");
st_delete(RCLASS_IV_TBL(clone), &id, 0);
}
+ if (RCLASS_CONST_TBL(orig)) {
+ if (RCLASS_CONST_TBL(clone)) {
+ st_free_table(RCLASS_CONST_TBL(clone));
+ }
+ RCLASS_CONST_TBL(clone) = st_copy(RCLASS_CONST_TBL(orig));
+ }
if (RCLASS_M_TBL(orig)) {
struct clone_method_data data;
@@ -216,6 +223,9 @@ rb_singleton_class_clone(VALUE obj)
if (RCLASS_IV_TBL(klass)) {
RCLASS_IV_TBL(clone) = st_copy(RCLASS_IV_TBL(klass));
}
+ if (RCLASS_CONST_TBL(klass)) {
+ RCLASS_CONST_TBL(clone) = st_copy(RCLASS_CONST_TBL(klass));
+ }
RCLASS_M_TBL(clone) = st_init_numtable();
data.tbl = RCLASS_M_TBL(clone);
data.klass = (VALUE)clone;
@@ -607,7 +617,11 @@ include_class_new(VALUE module, VALUE super)
if (!RCLASS_IV_TBL(module)) {
RCLASS_IV_TBL(module) = st_init_numtable();
}
+ if (!RCLASS_CONST_TBL(module)) {
+ RCLASS_CONST_TBL(module) = st_init_numtable();
+ }
RCLASS_IV_TBL(klass) = RCLASS_IV_TBL(module);
+ RCLASS_CONST_TBL(klass) = RCLASS_CONST_TBL(module);
RCLASS_M_TBL(klass) = RCLASS_M_TBL(module);
RCLASS_SUPER(klass) = super;
if (TYPE(module) == T_ICLASS) {