зеркало из https://github.com/github/ruby.git
* array.c (rb_ary_resurrect), string.c (rb_str_resurrect): new
functions based on [ruby-dev:37983] * insns.def (putstring, duparray): use rb_{ary,str}_resurrect(). * iseq.c (iseq_data_to_ary): needs to result TS_VALUE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
829ab73879
Коммит
1128e61562
|
@ -1,3 +1,12 @@
|
|||
Wed Feb 18 14:33:35 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* array.c (rb_ary_resurrect), string.c (rb_str_resurrect): new
|
||||
functions based on [ruby-dev:37983]
|
||||
|
||||
* insns.def (putstring, duparray): use rb_{ary,str}_resurrect().
|
||||
|
||||
* iseq.c (iseq_data_to_ary): needs to result TS_VALUE.
|
||||
|
||||
Wed Feb 18 12:35:31 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* file.c (rb_file_s_extname): fix for spaces before extention.
|
||||
|
|
6
array.c
6
array.c
|
@ -1469,6 +1469,12 @@ rb_ary_dup(VALUE ary)
|
|||
return dup;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_ary_resurrect(VALUE ary)
|
||||
{
|
||||
return rb_ary_new4(RARRAY_LEN(ary), RARRAY_PTR(ary));
|
||||
}
|
||||
|
||||
extern VALUE rb_output_fs;
|
||||
|
||||
static VALUE
|
||||
|
|
|
@ -373,7 +373,7 @@ putstring
|
|||
()
|
||||
(VALUE val)
|
||||
{
|
||||
val = rb_str_replace(rb_str_new(0, 0), str);
|
||||
val = rb_str_resurrect(str);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -460,7 +460,7 @@ duparray
|
|||
()
|
||||
(VALUE val)
|
||||
{
|
||||
val = rb_ary_replace(rb_ary_new2(0), ary);
|
||||
val = rb_ary_resurrect(ary);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
29
iseq.c
29
iseq.c
|
@ -23,6 +23,22 @@ VALUE rb_cISeq;
|
|||
|
||||
#define hidden_obj_p(obj) (!SPECIAL_CONST_P(obj) && !RBASIC(obj)->klass)
|
||||
|
||||
static inline VALUE
|
||||
obj_resurrect(VALUE obj)
|
||||
{
|
||||
if (hidden_obj_p(obj)) {
|
||||
switch (BUILTIN_TYPE(obj)) {
|
||||
case T_STRING:
|
||||
obj = rb_str_resurrect(obj);
|
||||
break;
|
||||
case T_ARRAY:
|
||||
obj = rb_ary_resurrect(obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
static void
|
||||
compile_data_free(struct iseq_compile_data *compile_data)
|
||||
{
|
||||
|
@ -701,16 +717,7 @@ insn_operand_intern(rb_iseq_t *iseq,
|
|||
op = ID2SYM(op);
|
||||
|
||||
case TS_VALUE: /* VALUE */
|
||||
if (hidden_obj_p(op)) {
|
||||
switch (BUILTIN_TYPE(op)) {
|
||||
case T_STRING:
|
||||
op = rb_str_replace(rb_str_new(0, 0), op);
|
||||
break;
|
||||
case T_ARRAY:
|
||||
op = rb_ary_replace(rb_ary_new2(0), op);
|
||||
break;
|
||||
}
|
||||
}
|
||||
op = obj_resurrect(op);
|
||||
ret = rb_inspect(op);
|
||||
if (CLASS_OF(op) == rb_cISeq) {
|
||||
rb_ary_push(child, op);
|
||||
|
@ -1141,7 +1148,7 @@ iseq_data_to_ary(rb_iseq_t *iseq)
|
|||
rb_ary_push(ary, INT2FIX(*seq));
|
||||
break;
|
||||
case TS_VALUE:
|
||||
rb_ary_push(ary, *seq);
|
||||
rb_ary_push(ary, obj_resurrect(*seq));
|
||||
break;
|
||||
case TS_ISEQ:
|
||||
{
|
||||
|
|
5
string.c
5
string.c
|
@ -828,6 +828,11 @@ rb_str_dup(VALUE str)
|
|||
return str_duplicate(rb_obj_class(str), str);
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_str_resurrect(VALUE str)
|
||||
{
|
||||
return rb_str_replace(str_alloc(rb_cString), str);
|
||||
}
|
||||
|
||||
/*
|
||||
* call-seq:
|
||||
|
|
|
@ -599,6 +599,9 @@ NOINLINE(void rb_gc_save_machine_context(rb_thread_t *));
|
|||
|
||||
#define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
|
||||
|
||||
VALUE rb_str_resurrect(VALUE str);
|
||||
VALUE rb_ary_resurrect(VALUE ary);
|
||||
|
||||
/* for thread */
|
||||
|
||||
#if RUBY_VM_THREAD_MODEL == 2
|
||||
|
|
Загрузка…
Ссылка в новой задаче