* eval.c (rb_block_pass): removed.
* eval.c (rb_thread_start_1): use rb_proc_yield() instead of rb_block_pass(). fixed: [ruby-dev:28794] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ab63980325
commit
ac9910e727
@ -1,3 +1,10 @@
|
|||||||
|
Fri Jun 23 17:27:52 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* eval.c (rb_block_pass): removed.
|
||||||
|
|
||||||
|
* eval.c (rb_thread_start_1): use rb_proc_yield() instead of
|
||||||
|
rb_block_pass(). fixed: [ruby-dev:28794]
|
||||||
|
|
||||||
Thu Jun 22 11:52:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Thu Jun 22 11:52:02 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/http.rb (Net::HTTPResponse): duplicated error 501;
|
* lib/net/http.rb (Net::HTTPResponse): duplicated error 501;
|
||||||
@ -27,7 +34,7 @@ Wed Jun 21 17:29:57 2006 NAKAMURA Usaku <usa@ruby-lang.org>
|
|||||||
|
|
||||||
* ext/socket/getaddrinfo.c (freeaddrinfo, get_name): fixed typo.
|
* ext/socket/getaddrinfo.c (freeaddrinfo, get_name): fixed typo.
|
||||||
|
|
||||||
* ext/tk/tcltklib.c (tcl_eval, tcl_global_eva): ditto.
|
* ext/tk/tcltklib.c (tcl_eval, tcl_global_eval): ditto.
|
||||||
|
|
||||||
* ext/zlib/zlib.c (rscheck): constified.
|
* ext/zlib/zlib.c (rscheck): constified.
|
||||||
|
|
||||||
|
82
eval.c
82
eval.c
@ -8691,84 +8691,6 @@ proc_binding(VALUE proc)
|
|||||||
return bind;
|
return bind;
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
|
||||||
rb_block_pass(VALUE (*func) (VALUE), VALUE arg, VALUE proc)
|
|
||||||
{
|
|
||||||
VALUE b;
|
|
||||||
struct BLOCK _block;
|
|
||||||
struct BLOCK *data;
|
|
||||||
volatile VALUE result = Qnil;
|
|
||||||
int state;
|
|
||||||
volatile int orphan;
|
|
||||||
volatile int safe = ruby_safe_level;
|
|
||||||
|
|
||||||
if (NIL_P(proc)) {
|
|
||||||
result = (*func)(arg);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
if (!rb_obj_is_proc(proc)) {
|
|
||||||
b = rb_check_convert_type(proc, T_DATA, "Proc", "to_proc");
|
|
||||||
if (!rb_obj_is_proc(b)) {
|
|
||||||
rb_raise(rb_eTypeError, "wrong argument type %s (expected Proc)",
|
|
||||||
rb_obj_classname(proc));
|
|
||||||
}
|
|
||||||
proc = b;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ruby_safe_level >= 1 && OBJ_TAINTED(proc) &&
|
|
||||||
ruby_safe_level > proc_get_safe_level(proc)) {
|
|
||||||
rb_raise(rb_eSecurityError, "Insecure: tainted block value");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ruby_frame->block && ruby_frame->block->block_obj == proc) {
|
|
||||||
return (*func)(arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
Data_Get_Struct(proc, struct BLOCK, data);
|
|
||||||
orphan = block_orphan(data);
|
|
||||||
|
|
||||||
PUSH_FRAME(Qtrue);
|
|
||||||
PUSH_TAG(PROT_LOOP);
|
|
||||||
_block = *data;
|
|
||||||
if (orphan) {
|
|
||||||
_block.uniq = block_unique++;
|
|
||||||
prot_tag->blkid = _block.uniq;
|
|
||||||
}
|
|
||||||
ruby_frame->block = &_block;
|
|
||||||
state = EXEC_TAG();
|
|
||||||
if (state == 0) {
|
|
||||||
retry:
|
|
||||||
proc_set_safe_level(proc);
|
|
||||||
if (safe > ruby_safe_level)
|
|
||||||
ruby_safe_level = safe;
|
|
||||||
result = (*func)(arg);
|
|
||||||
}
|
|
||||||
else if (state == TAG_BREAK && TAG_DST()) {
|
|
||||||
result = prot_tag->retval;
|
|
||||||
state = 0;
|
|
||||||
}
|
|
||||||
else if (state == TAG_RETRY) {
|
|
||||||
state = 0;
|
|
||||||
goto retry;
|
|
||||||
}
|
|
||||||
POP_TAG();
|
|
||||||
POP_FRAME();
|
|
||||||
if (proc_safe_level_p(proc)) ruby_safe_level = safe;
|
|
||||||
|
|
||||||
switch (state) {/* escape from orphan block */
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
case TAG_RETURN:
|
|
||||||
if (orphan) {
|
|
||||||
proc_jump_error(state, prot_tag->retval);
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
JUMP_TAG(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct block_arg {
|
struct block_arg {
|
||||||
VALUE self;
|
VALUE self;
|
||||||
NODE *iter;
|
NODE *iter;
|
||||||
@ -11976,7 +11898,7 @@ rb_thread_start_1(void)
|
|||||||
rb_thread_t th = new_thread.thread;
|
rb_thread_t th = new_thread.thread;
|
||||||
volatile rb_thread_t th_save = th;
|
volatile rb_thread_t th_save = th;
|
||||||
VALUE proc = new_thread.proc;
|
VALUE proc = new_thread.proc;
|
||||||
VALUE arg = new_thread.arg;
|
volatile VALUE arg = new_thread.arg;
|
||||||
struct ruby_env *ip = th->anchor;
|
struct ruby_env *ip = th->anchor;
|
||||||
enum thread_status status;
|
enum thread_status status;
|
||||||
int state;
|
int state;
|
||||||
@ -11992,7 +11914,7 @@ rb_thread_start_1(void)
|
|||||||
if ((state = EXEC_TAG()) == 0) {
|
if ((state = EXEC_TAG()) == 0) {
|
||||||
if (THREAD_SAVE_CONTEXT(th) == 0) {
|
if (THREAD_SAVE_CONTEXT(th) == 0) {
|
||||||
new_thread.thread = 0;
|
new_thread.thread = 0;
|
||||||
th->result = rb_block_pass(rb_thread_yield_0, arg, proc);
|
th->result = rb_proc_yield(RARRAY(arg)->len, RARRAY(arg)->ptr, proc);
|
||||||
}
|
}
|
||||||
th = th_save;
|
th = th_save;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user