* class.c (rewrite_cref_stack): remove recursion.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42848 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-09-05 15:05:20 +00:00
Родитель 7eafeaa313
Коммит bbbc8b57eb
2 изменённых файлов: 20 добавлений и 13 удалений

Просмотреть файл

@ -1,3 +1,7 @@
Fri Sep 6 00:05:14 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* class.c (rewrite_cref_stack): remove recursion.
Thu Sep 5 18:05:00 2013 Charlie Somerville <charliesome@ruby-lang.org> Thu Sep 5 18:05:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
* string.c (fstring_cmp): take string encoding into account when * string.c (fstring_cmp): take string encoding into account when

29
class.c
Просмотреть файл

@ -231,22 +231,23 @@ rb_class_new(VALUE super)
return rb_class_boot(super); return rb_class_boot(super);
} }
static NODE* static void
rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass) rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr)
{ {
NODE *new_node; NODE *new_node;
if (!node) { while (node) {
return NULL; if (node->nd_clss == old_klass) {
} new_node = NEW_CREF(new_klass);
if (node->nd_clss == old_klass) { new_node->nd_next = node->nd_next;
new_node = NEW_CREF(new_klass); *new_cref_ptr = new_node;
new_node->nd_next = node->nd_next; return;
} }
else {
new_node = NEW_CREF(node->nd_clss); new_node = NEW_CREF(node->nd_clss);
new_node->nd_next = rewrite_cref_stack(node->nd_next, old_klass, new_klass); node = node->nd_next;
*new_cref_ptr = new_node;
new_cref_ptr = &new_node->nd_next;
} }
return new_node; *new_cref_ptr = NULL;
} }
static void static void
@ -255,9 +256,11 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me)
VALUE newiseqval; VALUE newiseqval;
if (me->def && me->def->type == VM_METHOD_TYPE_ISEQ) { if (me->def && me->def->type == VM_METHOD_TYPE_ISEQ) {
rb_iseq_t *iseq; rb_iseq_t *iseq;
NODE *new_cref;
newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass); newiseqval = rb_iseq_clone(me->def->body.iseq->self, klass);
GetISeqPtr(newiseqval, iseq); GetISeqPtr(newiseqval, iseq);
OBJ_WRITE(iseq->self, &iseq->cref_stack, rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass)); rewrite_cref_stack(me->def->body.iseq->cref_stack, me->klass, klass, &new_cref);
OBJ_WRITE(iseq->self, &iseq->cref_stack, new_cref);
rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag); rb_add_method(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, me->flag);
RB_GC_GUARD(newiseqval); RB_GC_GUARD(newiseqval);
} }