ruby-changes:55770
From: Nobuyoshi <ko1@a...>
Date: Wed, 22 May 2019 16:11:13 +0900 (JST)
Subject: [ruby-changes:55770] Nobuyoshi Nakada: 48f3dc3cce (trunk): Set namespace tree
https://git.ruby-lang.org/ruby.git/commit/?id=48f3dc3cce From 48f3dc3cce74f459a690f8434d191140a1c0d8a2 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Fri, 19 Apr 2019 06:37:01 +0900 Subject: Set namespace tree * variable.c (set_namespace_path): set path to the whole namespace tree. [Feature #15765] diff --git a/variable.c b/variable.c index f57dcef..ea618ce 100644 --- a/variable.c +++ b/variable.c @@ -2696,10 +2696,10 @@ check_before_mod_set(VALUE klass, ID id, VALUE val, const char *dest) https://github.com/ruby/ruby/blob/trunk/variable.c#L2696 rb_check_frozen(klass); } -static void finalize_classpath_for_children(VALUE named_namespace); +static void set_namespace_path(VALUE named_namespace, VALUE name); static enum rb_id_table_iterator_result -finalize_classpath_i(ID id, VALUE v, void *payload) +set_namespace_path_i(ID id, VALUE v, void *payload) { rb_const_entry_t *ce = (rb_const_entry_t *)v; VALUE value = ce->value; @@ -2715,12 +2715,11 @@ finalize_classpath_i(ID id, VALUE v, void *payload) https://github.com/ruby/ruby/blob/trunk/variable.c#L2715 if (has_permanent_classpath) { return ID_TABLE_CONTINUE; } - rb_ivar_set(value, classpath, build_const_path(parental_path, id)); + set_namespace_path(value, build_const_path(parental_path, id)); if (RCLASS_IV_TBL(value)) { st_data_t tmp = tmp_classpath; st_delete(RCLASS_IV_TBL(value), &tmp, 0); } - finalize_classpath_for_children(value); return ID_TABLE_CONTINUE; } @@ -2731,16 +2730,13 @@ finalize_classpath_i(ID id, VALUE v, void *payload) https://github.com/ruby/ruby/blob/trunk/variable.c#L2730 * classpath. */ static void -finalize_classpath_for_children(VALUE named_namespace) +set_namespace_path(VALUE named_namespace, VALUE namespace_path) { struct rb_id_table *const_table = RCLASS_CONST_TBL(named_namespace); + rb_ivar_set(named_namespace, classpath, namespace_path); if (const_table) { - int permanent; - VALUE parental_path = classname(named_namespace, &permanent); - VM_ASSERT(RB_TYPE_P(parental_path, T_STRING)); - VM_ASSERT(permanent); - rb_id_table_foreach(const_table, finalize_classpath_i, &parental_path); + rb_id_table_foreach(const_table, set_namespace_path_i, &namespace_path); } } @@ -2780,16 +2776,14 @@ rb_const_set(VALUE klass, ID id, VALUE val) https://github.com/ruby/ruby/blob/trunk/variable.c#L2776 VALUE val_path = classname(val, &val_path_permanent); if (NIL_P(val_path) || !val_path_permanent) { if (klass == rb_cObject) { - rb_ivar_set(val, classpath, rb_id2str(id)); - finalize_classpath_for_children(val); + set_namespace_path(val, rb_id2str(id)); } else { int parental_path_permanent; VALUE parental_path = classname(klass, &parental_path_permanent); if (!NIL_P(parental_path)) { if (parental_path_permanent && !val_path_permanent) { - rb_ivar_set(val, classpath, build_const_path(parental_path, id)); - finalize_classpath_for_children(val); + set_namespace_path(val, build_const_path(parental_path, id)); } else if (!parental_path_permanent && NIL_P(val_path)) { rb_ivar_set(val, tmp_classpath, build_const_path(parental_path, id)); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/