mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* class.c (clone_method): should copy cbase in cref as well.
[ruby-dev:35116] * iseq.c (iseq_mark): mark original iseq object. * iseq.c (iseq_free): do not free internal data if they have original iseq to belong. * iseq.c (rb_iseq_clone): a new function to clone iseq value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5898c07466
commit
e956f28724
4 changed files with 60 additions and 15 deletions
12
ChangeLog
12
ChangeLog
|
@ -3,6 +3,18 @@ Mon Aug 11 16:56:40 2008 TAKAO Kouji <kouji@takao7.net>
|
||||||
* test/readline/test_readline.rb: added test for Readline's class
|
* test/readline/test_readline.rb: added test for Readline's class
|
||||||
methods.
|
methods.
|
||||||
|
|
||||||
|
Mon Aug 11 16:39:23 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* class.c (clone_method): should copy cbase in cref as well.
|
||||||
|
[ruby-dev:35116]
|
||||||
|
|
||||||
|
* iseq.c (iseq_mark): mark original iseq object.
|
||||||
|
|
||||||
|
* iseq.c (iseq_free): do not free internal data if they have
|
||||||
|
original iseq to belong.
|
||||||
|
|
||||||
|
* iseq.c (rb_iseq_clone): a new function to clone iseq value.
|
||||||
|
|
||||||
Mon Aug 11 16:34:48 2008 Tanaka Akira <akr@fsij.org>
|
Mon Aug 11 16:34:48 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* enc/trans/iso2022.trans: renamed from iso2022.erb.c.
|
* enc/trans/iso2022.trans: renamed from iso2022.erb.c.
|
||||||
|
|
10
class.c
10
class.c
|
@ -13,6 +13,7 @@
|
||||||
#include "ruby/signal.h"
|
#include "ruby/signal.h"
|
||||||
#include "ruby/node.h"
|
#include "ruby/node.h"
|
||||||
#include "ruby/st.h"
|
#include "ruby/st.h"
|
||||||
|
#include "vm_core.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
extern st_table *rb_class_tbl;
|
extern st_table *rb_class_tbl;
|
||||||
|
@ -78,10 +79,17 @@ clone_method(ID mid, NODE *body, struct clone_method_data *data)
|
||||||
st_insert(data->tbl, mid, 0);
|
st_insert(data->tbl, mid, 0);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
NODE *fbody = body->nd_body->nd_body;
|
||||||
|
|
||||||
|
if (nd_type(fbody) == RUBY_VM_METHOD_NODE) {
|
||||||
|
fbody = NEW_NODE(RUBY_VM_METHOD_NODE, 0,
|
||||||
|
rb_iseq_clone((VALUE)fbody->nd_body, data->klass),
|
||||||
|
0);
|
||||||
|
}
|
||||||
st_insert(data->tbl, mid,
|
st_insert(data->tbl, mid,
|
||||||
(st_data_t)
|
(st_data_t)
|
||||||
NEW_FBODY(
|
NEW_FBODY(
|
||||||
NEW_METHOD(body->nd_body->nd_body,
|
NEW_METHOD(fbody,
|
||||||
data->klass, /* TODO */
|
data->klass, /* TODO */
|
||||||
body->nd_body->nd_noex),
|
body->nd_body->nd_noex),
|
||||||
0));
|
0));
|
||||||
|
|
24
iseq.c
24
iseq.c
|
@ -48,6 +48,7 @@ iseq_free(void *ptr)
|
||||||
|
|
||||||
if (ptr) {
|
if (ptr) {
|
||||||
iseq = ptr;
|
iseq = ptr;
|
||||||
|
if (!iseq->orig) {
|
||||||
/* It's possible that strings are freed
|
/* It's possible that strings are freed
|
||||||
* GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name),
|
* GC_INFO("%s @ %s\n", RSTRING_PTR(iseq->name),
|
||||||
* RSTRING_PTR(iseq->filename));
|
* RSTRING_PTR(iseq->filename));
|
||||||
|
@ -62,6 +63,7 @@ iseq_free(void *ptr)
|
||||||
RUBY_FREE_UNLESS_NULL(iseq->catch_table);
|
RUBY_FREE_UNLESS_NULL(iseq->catch_table);
|
||||||
RUBY_FREE_UNLESS_NULL(iseq->arg_opt_table);
|
RUBY_FREE_UNLESS_NULL(iseq->arg_opt_table);
|
||||||
compile_data_free(iseq->compile_data);
|
compile_data_free(iseq->compile_data);
|
||||||
|
}
|
||||||
ruby_xfree(ptr);
|
ruby_xfree(ptr);
|
||||||
}
|
}
|
||||||
RUBY_FREE_LEAVE("iseq");
|
RUBY_FREE_LEAVE("iseq");
|
||||||
|
@ -84,6 +86,7 @@ iseq_mark(void *ptr)
|
||||||
RUBY_MARK_UNLESS_NULL(iseq->coverage);
|
RUBY_MARK_UNLESS_NULL(iseq->coverage);
|
||||||
/* RUBY_MARK_UNLESS_NULL((VALUE)iseq->node); */
|
/* RUBY_MARK_UNLESS_NULL((VALUE)iseq->node); */
|
||||||
/* RUBY_MARK_UNLESS_NULL(iseq->cached_special_block); */
|
/* RUBY_MARK_UNLESS_NULL(iseq->cached_special_block); */
|
||||||
|
RUBY_MARK_UNLESS_NULL(iseq->orig);
|
||||||
|
|
||||||
if (iseq->compile_data != 0) {
|
if (iseq->compile_data != 0) {
|
||||||
RUBY_MARK_UNLESS_NULL(iseq->compile_data->mark_ary);
|
RUBY_MARK_UNLESS_NULL(iseq->compile_data->mark_ary);
|
||||||
|
@ -1227,6 +1230,27 @@ insn_make_insn_table(void)
|
||||||
return table;
|
return table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VALUE
|
||||||
|
rb_iseq_clone(VALUE iseqval, VALUE newcbase)
|
||||||
|
{
|
||||||
|
VALUE newiseq = iseq_alloc(rb_cISeq);
|
||||||
|
rb_iseq_t *iseq0, *iseq1;
|
||||||
|
|
||||||
|
GetISeqPtr(iseqval, iseq0);
|
||||||
|
GetISeqPtr(newiseq, iseq1);
|
||||||
|
|
||||||
|
*iseq1 = *iseq0;
|
||||||
|
iseq1->self = newiseq;
|
||||||
|
if (!iseq1->orig) {
|
||||||
|
iseq1->orig = iseqval;
|
||||||
|
}
|
||||||
|
if (newcbase) {
|
||||||
|
iseq1->cref_stack = NEW_BLOCK(newcbase);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newiseq;
|
||||||
|
}
|
||||||
|
|
||||||
/* ruby2cext */
|
/* ruby2cext */
|
||||||
|
|
||||||
VALUE
|
VALUE
|
||||||
|
|
|
@ -261,6 +261,7 @@ struct rb_iseq_struct {
|
||||||
/****************/
|
/****************/
|
||||||
|
|
||||||
VALUE self;
|
VALUE self;
|
||||||
|
VALUE orig; /* non-NULL if its data have origin */
|
||||||
|
|
||||||
/* block inlining */
|
/* block inlining */
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue