From 2285a8d813814e936484d302dacf1ff39e40e33c Mon Sep 17 00:00:00 2001 From: mame Date: Tue, 26 Oct 2010 17:27:21 +0000 Subject: * 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 --- class.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'class.c') 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) { -- cgit v1.2.3