ruby-changes:50606
From: nobu <ko1@a...>
Date: Thu, 15 Mar 2018 16:15:31 +0900 (JST)
Subject: [ruby-changes:50606] nobu:r62756 (trunk): variable.c: hoisted out overtaken cvar warnings
nobu 2018-03-15 16:15:26 +0900 (Thu, 15 Mar 2018) New Revision: 62756 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=62756 Log: variable.c: hoisted out overtaken cvar warnings Modified files: trunk/variable.c Index: variable.c =================================================================== --- variable.c (revision 62755) +++ variable.c (revision 62756) @@ -2856,6 +2856,23 @@ cvar_front_klass(VALUE klass) https://github.com/ruby/ruby/blob/trunk/variable.c#L2856 return RCLASS_SUPER(klass); } +static void +cvar_overtaken(VALUE front, VALUE target, ID id) +{ + if (front && target != front) { + st_data_t did = (st_data_t)id; + + if (RTEST(ruby_verbose)) { + rb_warning("class variable % "PRIsVALUE" of %"PRIsVALUE" is overtaken by %"PRIsVALUE"", + ID2SYM(id), rb_class_name(original_module(front)), + rb_class_name(original_module(target))); + } + if (BUILTIN_TYPE(front) == T_CLASS) { + st_delete(RCLASS_IV_TBL(front), &did, 0); + } + } +} + #define CVAR_FOREACH_ANCESTORS(klass, v, r) \ for (klass = cvar_front_klass(klass); klass; klass = RCLASS_SUPER(klass)) { \ if (cvar_lookup_at(klass, id, (v))) { \ @@ -2876,18 +2893,7 @@ rb_cvar_set(VALUE klass, ID id, VALUE va https://github.com/ruby/ruby/blob/trunk/variable.c#L2893 tmp = klass; CVAR_LOOKUP(0, {if (!front) front = klass; target = klass;}); if (target) { - if (front && target != front) { - st_data_t did = id; - - if (RTEST(ruby_verbose)) { - rb_warning("class variable %"PRIsVALUE" of %"PRIsVALUE" is overtaken by %"PRIsVALUE"", - QUOTE_ID(id), rb_class_name(original_module(front)), - rb_class_name(original_module(target))); - } - if (BUILTIN_TYPE(front) == T_CLASS) { - st_delete(RCLASS_IV_TBL(front),&did,0); - } - } + cvar_overtaken(front, target, id); } else { target = tmp; @@ -2913,18 +2919,7 @@ rb_cvar_get(VALUE klass, ID id) https://github.com/ruby/ruby/blob/trunk/variable.c#L2919 rb_name_err_raise("uninitialized class variable %1$s in %2$s", tmp, ID2SYM(id)); } - if (front && target != front) { - st_data_t did = id; - - if (RTEST(ruby_verbose)) { - rb_warning("class variable %"PRIsVALUE" of %"PRIsVALUE" is overtaken by %"PRIsVALUE"", - QUOTE_ID(id), rb_class_name(original_module(front)), - rb_class_name(original_module(target))); - } - if (BUILTIN_TYPE(front) == T_CLASS) { - st_delete(RCLASS_IV_TBL(front),&did,0); - } - } + cvar_overtaken(front, target, id); return (VALUE)value; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/