* eval.c (localjump_error): id should be ID.

* eval.c (rb_eval): nd_rval is set in copy_node_scope().

* eval.c (rb_yield_0): unused variable.

* eval.c (rb_yield_0): nothing to do for empty node.

* eval.c (call_end_proc, proc_invoke): adjust backtrace in END.
  [ruby-dev:21551]

* eval.c (rb_thread_start_0): set the value by break as the result.
  [ruby-dev:21552]

* eval.c (rb_thread_start_0, rb_thread_raise, rb_callcc): save
  variables across THREAD_SAVE_CONTEXT.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-10-08 21:43:36 +00:00
parent 99fb4ed24e
commit c0e5a7c63f
2 changed files with 50 additions and 22 deletions

View File

@ -1,3 +1,26 @@
Thu Oct 9 06:43:33 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (localjump_error): id should be ID.
* eval.c (rb_eval): nd_rval is set in copy_node_scope().
* eval.c (rb_yield_0): unused variable.
* eval.c (rb_yield_0): nothing to do for empty node.
Thu Oct 9 06:43:33 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (call_end_proc, proc_invoke): adjust backtrace in END.
[ruby-dev:21551]
Thu Oct 9 06:43:33 2003 Nobuyoshi Nakada <nobu@ruby-lang.org>
* eval.c (rb_thread_start_0): set the value by break as the result.
[ruby-dev:21552]
* eval.c (rb_thread_start_0, rb_thread_raise, rb_callcc): save
variables across THREAD_SAVE_CONTEXT.
Wed Oct 8 22:19:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org> Wed Oct 8 22:19:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
* lib/test/unit.rb: removed installation instructions. * lib/test/unit.rb: removed installation instructions.
@ -13,7 +36,7 @@ Wed Oct 8 22:19:00 2003 Nathaniel Talbott <ntalbott@ruby-lang.org>
* lib/test/unit/collector/objectspace.rb: extracted common test * lib/test/unit/collector/objectspace.rb: extracted common test
collection functionality in to a module. collection functionality in to a module.
* lib/test/unit/collector.rb: ditto; added. * lib/test/unit/collector.rb: ditto; added.
* test/testunit/collector/test_objectspace.rb: ditto. * test/testunit/collector/test_objectspace.rb: ditto.

47
eval.c
View File

@ -1493,7 +1493,7 @@ localjump_error(mesg, value, reason)
int reason; int reason;
{ {
VALUE exc = rb_exc_new2(rb_eLocalJumpError, mesg); VALUE exc = rb_exc_new2(rb_eLocalJumpError, mesg);
VALUE id; ID id;
rb_iv_set(exc, "@exit_value", value); rb_iv_set(exc, "@exit_value", value);
switch (reason) { switch (reason) {
@ -3494,7 +3494,6 @@ rb_eval(self, n)
} }
} }
defn = copy_node_scope(node->nd_defn, ruby_cref); defn = copy_node_scope(node->nd_defn, ruby_cref);
defn->nd_rval = (VALUE)ruby_cref;
rb_add_method(klass, node->nd_mid, defn, rb_add_method(klass, node->nd_mid, defn,
NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0)); NOEX_PUBLIC|(body?body->nd_noex&NOEX_UNDEF:0));
result = Qnil; result = Qnil;
@ -4077,7 +4076,6 @@ rb_yield_0(val, self, klass, flags, avalue)
struct FRAME frame; struct FRAME frame;
NODE *cnode = ruby_current_node; NODE *cnode = ruby_current_node;
int state; int state;
static unsigned serial = 1;
if (!rb_block_given_p()) { if (!rb_block_given_p()) {
localjump_error("no block given", Qnil, 0); localjump_error("no block given", Qnil, 0);
@ -4164,15 +4162,13 @@ rb_yield_0(val, self, klass, flags, avalue)
POP_TAG(); POP_TAG();
if (state) goto pop_state; if (state) goto pop_state;
} }
if (!node) goto pop_state;
PUSH_ITER(block->iter); PUSH_ITER(block->iter);
PUSH_TAG(PROT_NONE); PUSH_TAG(PROT_NONE);
if ((state = EXEC_TAG()) == 0) { if ((state = EXEC_TAG()) == 0) {
redo: redo:
if (!node) { if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
result = Qnil;
}
else if (nd_type(node) == NODE_CFUNC || nd_type(node) == NODE_IFUNC) {
if (node->nd_state == YIELD_FUNC_AVALUE) { if (node->nd_state == YIELD_FUNC_AVALUE) {
if (!avalue) { if (!avalue) {
val = svalue_to_avalue(val); val = svalue_to_avalue(val);
@ -6454,6 +6450,7 @@ call_end_proc(data)
PUSH_ITER(ITER_NOT); PUSH_ITER(ITER_NOT);
PUSH_FRAME(); PUSH_FRAME();
ruby_frame->self = ruby_frame->prev->self; ruby_frame->self = ruby_frame->prev->self;
ruby_frame->node = 0;
ruby_frame->last_func = 0; ruby_frame->last_func = 0;
ruby_frame->last_class = 0; ruby_frame->last_class = 0;
proc_invoke(data, rb_ary_new2(0), Qundef, 0); proc_invoke(data, rb_ary_new2(0), Qundef, 0);
@ -7045,6 +7042,7 @@ proc_invoke(proc, args, self, klass)
PUSH_ITER(ITER_CUR); PUSH_ITER(ITER_CUR);
ruby_frame->iter = ITER_CUR; ruby_frame->iter = ITER_CUR;
ruby_current_node = data->body;
PUSH_TAG((pcall || orphan) ? PROT_PCALL : PROT_CALL); PUSH_TAG((pcall || orphan) ? PROT_PCALL : PROT_CALL);
state = EXEC_TAG(); state = EXEC_TAG();
if (state == 0) { if (state == 0) {
@ -8199,7 +8197,7 @@ rb_thread_check(data)
return (rb_thread_t)RDATA(data)->data; return (rb_thread_t)RDATA(data)->data;
} }
static VALUE rb_thread_raise _((int, VALUE*, volatile rb_thread_t)); static VALUE rb_thread_raise _((int, VALUE*, rb_thread_t));
static int th_raise_argc; static int th_raise_argc;
static VALUE th_raise_argv[2]; static VALUE th_raise_argv[2];
@ -9401,14 +9399,13 @@ rb_thread_stop_timer()
#endif #endif
static VALUE static VALUE
rb_thread_start_0(fn, arg, th_arg) rb_thread_start_0(fn, arg, th)
VALUE (*fn)(); VALUE (*fn)();
void *arg; void *arg;
rb_thread_t th_arg; rb_thread_t th;
{ {
volatile rb_thread_t th = th_arg; volatile rb_thread_t th_save = th;
volatile VALUE thread = th->thread; struct BLOCK *volatile saved_block = 0, *block;
volatile struct BLOCK* saved_block = 0;
enum thread_status status; enum thread_status status;
int state; int state;
@ -9431,7 +9428,7 @@ rb_thread_start_0(fn, arg, th_arg)
#endif #endif
if (THREAD_SAVE_CONTEXT(curr_thread)) { if (THREAD_SAVE_CONTEXT(curr_thread)) {
return thread; return th_save->thread;
} }
if (ruby_block) { /* should nail down higher blocks */ if (ruby_block) { /* should nail down higher blocks */
@ -9460,18 +9457,22 @@ rb_thread_start_0(fn, arg, th_arg)
th->result = (*fn)(arg, th); th->result = (*fn)(arg, th);
} }
} }
else if (TAG_DST()) {
th->result = prot_tag->retval;
}
th = th_save;
POP_TAG(); POP_TAG();
status = th->status; status = th->status;
if (th == main_thread) ruby_stop(state); if (th == main_thread) ruby_stop(state);
rb_thread_remove(th); rb_thread_remove(th);
while (saved_block) { for (block = saved_block; block;) {
volatile struct BLOCK *tmp = saved_block; struct BLOCK *tmp = block;
if (tmp->frame.argc > 0) if (tmp->frame.argc > 0)
free(tmp->frame.argv); free(tmp->frame.argv);
saved_block = tmp->prev; block = tmp->prev;
free((void*)tmp); free((void*)tmp);
} }
@ -9764,8 +9765,10 @@ static VALUE
rb_thread_raise(argc, argv, th) rb_thread_raise(argc, argv, th)
int argc; int argc;
VALUE *argv; VALUE *argv;
volatile rb_thread_t th; rb_thread_t th;
{ {
volatile rb_thread_t th_save = th;
if (rb_thread_dead(th)) return Qnil; if (rb_thread_dead(th)) return Qnil;
if (curr_thread == th) { if (curr_thread == th) {
rb_f_raise(argc, argv); rb_f_raise(argc, argv);
@ -9773,7 +9776,7 @@ rb_thread_raise(argc, argv, th)
if (!rb_thread_dead(curr_thread)) { if (!rb_thread_dead(curr_thread)) {
if (THREAD_SAVE_CONTEXT(curr_thread)) { if (THREAD_SAVE_CONTEXT(curr_thread)) {
return th->thread; return th_save->thread;
} }
} }
@ -9936,7 +9939,8 @@ rb_callcc(self)
VALUE self; VALUE self;
{ {
volatile VALUE cont; volatile VALUE cont;
volatile rb_thread_t th; rb_thread_t th;
volatile rb_thread_t th_save;
struct tag *tag; struct tag *tag;
struct RVarmap *vars; struct RVarmap *vars;
@ -9954,8 +9958,9 @@ rb_callcc(self)
FL_SET(vars, DVAR_DONT_RECYCLE); FL_SET(vars, DVAR_DONT_RECYCLE);
} }
th_save = th;
if (THREAD_SAVE_CONTEXT(th)) { if (THREAD_SAVE_CONTEXT(th)) {
return th->result; return th_save->result;
} }
else { else {
return rb_yield(cont); return rb_yield(cont);