[前][次][番号順一覧][スレッド一覧]

ruby-changes:47040

From: ko1 <ko1@a...>
Date: Fri, 23 Jun 2017 16:26:00 +0900 (JST)
Subject: [ruby-changes:47040] ko1:r59155 (trunk): use "enum ruby_tag_type" and TAG_NONE.

ko1	2017-06-23 16:25:52 +0900 (Fri, 23 Jun 2017)

  New Revision: 59155

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=59155

  Log:
    use "enum ruby_tag_type" and TAG_NONE.
    
    Return value of EXEC_TAG() is saved by "int state".
    Instead of "int", use "enum ruby_tag_type". First EXEC_TAG()
    value should be 0, so that define TAG_NONE (= 0) and use it.
    
    Some code used "status" instead of "state". To make them clear,
    rename them to state.
    
    We can change variable name from "state" to "tag_state", but this
    ticket doesn't contain it.

  Modified files:
    trunk/cont.c
    trunk/error.c
    trunk/eval.c
    trunk/eval_error.c
    trunk/eval_intern.h
    trunk/eval_jump.c
    trunk/gc.c
    trunk/load.c
    trunk/proc.c
    trunk/signal.c
    trunk/thread.c
    trunk/vm.c
    trunk/vm_backtrace.c
    trunk/vm_core.h
    trunk/vm_eval.c
    trunk/vm_trace.c
Index: eval_intern.h
===================================================================
--- eval_intern.h	(revision 59154)
+++ eval_intern.h	(revision 59155)
@@ -160,14 +160,14 @@ LONG WINAPI rb_w32_stack_overflow_handle https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L160
 static inline int
 rb_threadptr_tag_state(rb_thread_t *th)
 {
-    int state = th->state;
+    enum ruby_tag_type state = th->state;
     th->state = 0;
     return state;
 }
 
-NORETURN(static inline void rb_threadptr_tag_jump(rb_thread_t *, int));
+NORETURN(static inline void rb_threadptr_tag_jump(rb_thread_t *, enum ruby_tag_type st));
 static inline void
-rb_threadptr_tag_jump(rb_thread_t *th, int st)
+rb_threadptr_tag_jump(rb_thread_t *th, enum ruby_tag_type st)
 {
     th->state = st;
     ruby_longjmp(th->tag->buf, 1);
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 59154)
+++ vm_core.h	(revision 59155)
@@ -149,6 +149,7 @@ https://github.com/ruby/ruby/blob/trunk/vm_core.h#L149
 typedef unsigned long rb_num_t;
 
 enum ruby_tag_type {
+    RUBY_TAG_NONE       = 0x0,
     RUBY_TAG_RETURN	= 0x1,
     RUBY_TAG_BREAK	= 0x2,
     RUBY_TAG_NEXT	= 0x3,
@@ -159,6 +160,8 @@ enum ruby_tag_type { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L160
     RUBY_TAG_FATAL	= 0x8,
     RUBY_TAG_MASK	= 0xf
 };
+
+#define TAG_NONE        RUBY_TAG_NONE
 #define TAG_RETURN	RUBY_TAG_RETURN
 #define TAG_BREAK	RUBY_TAG_BREAK
 #define TAG_NEXT	RUBY_TAG_NEXT
@@ -741,7 +744,7 @@ typedef struct rb_thread_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L744
     VALUE last_status; /* $? */
 
     /* passing state */
-    int state;
+    enum ruby_tag_type state;
 
     /* for rb_iterate */
     VALUE passed_block_handler;
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 59154)
+++ eval_error.c	(revision 59155)
@@ -175,7 +175,7 @@ rb_threadptr_error_print(rb_thread_t *vo https://github.com/ruby/ruby/blob/trunk/eval_error.c#L175
     rb_thread_raised_clear(th);
 
     TH_PUSH_TAG(th);
-    if (TH_EXEC_TAG() == 0) {
+    if (TH_EXEC_TAG() == TAG_NONE) {
 	errat = rb_get_backtrace(errinfo);
     }
     else if (errat == Qundef) {
Index: load.c
===================================================================
--- load.c	(revision 59154)
+++ load.c	(revision 59155)
@@ -579,7 +579,7 @@ const rb_iseq_t *rb_iseq_load_iseq(VALUE https://github.com/ruby/ruby/blob/trunk/load.c#L579
 static int
 rb_load_internal0(rb_thread_t *th, VALUE fname, int wrap)
 {
-    int state;
+    enum ruby_tag_type state;
     volatile VALUE wrapper = th->top_wrapper;
     volatile VALUE self = th->top_self;
 #if !defined __GNUC__
@@ -600,7 +600,7 @@ rb_load_internal0(rb_thread_t *th, VALUE https://github.com/ruby/ruby/blob/trunk/load.c#L600
 
     TH_PUSH_TAG(th);
     state = EXEC_TAG();
-    if (state == 0) {
+    if (state == TAG_NONE) {
 	NODE *node;
 	const rb_iseq_t *iseq;
 
@@ -665,19 +665,19 @@ rb_load(VALUE fname, int wrap) https://github.com/ruby/ruby/blob/trunk/load.c#L665
 }
 
 void
-rb_load_protect(VALUE fname, int wrap, int *state)
+rb_load_protect(VALUE fname, int wrap, int *pstate)
 {
-    int status;
+    enum ruby_tag_type state;
     volatile VALUE path = 0;
 
     PUSH_TAG();
-    if ((status = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	path = file_to_load(fname);
     }
     POP_TAG();
-    if (!status) status = rb_load_internal0(GET_THREAD(), path, wrap);
-    if (state)
-	*state = status;
+
+    if (state != TAG_NONE) state = rb_load_internal0(GET_THREAD(), path, wrap);
+    if (state != TAG_NONE) *pstate = state;
 }
 
 /*
@@ -961,7 +961,7 @@ rb_require_internal(VALUE fname, int saf https://github.com/ruby/ruby/blob/trunk/load.c#L961
     volatile int result = -1;
     rb_thread_t *th = GET_THREAD();
     volatile VALUE errinfo = th->errinfo;
-    int state;
+    enum ruby_tag_type state;
     struct {
 	int safe;
     } volatile saved;
@@ -974,7 +974,7 @@ rb_require_internal(VALUE fname, int saf https://github.com/ruby/ruby/blob/trunk/load.c#L974
 
     TH_PUSH_TAG(th);
     saved.safe = rb_safe_level();
-    if ((state = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	long handle;
 	int found;
 
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 59154)
+++ vm_eval.c	(revision 59155)
@@ -1105,7 +1105,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), V https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1105
 	    const struct vm_ifunc *const ifunc,
 	    rb_thread_t *const th)
 {
-    int state;
+    enum ruby_tag_type state;
     volatile VALUE retval = Qnil;
     rb_control_frame_t *const cfp = th->ec.cfp;
 
@@ -1136,7 +1136,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), V https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1136
 	    rb_vm_rewind_cfp(th, cfp);
 
 	    state = 0;
-	    th->state = 0;
+	    th->state = TAG_NONE;
 	    th->errinfo = Qnil;
 
 	    if (state == TAG_RETRY) goto iter_retry;
@@ -1328,7 +1328,7 @@ eval_string_with_cref(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1328
     }
 
     TH_PUSH_TAG(th);
-    if ((state = TH_EXEC_TAG()) == 0) {
+    if ((state = TH_EXEC_TAG()) == TAG_NONE) {
 	result = vm_exec(th);
     }
     TH_POP_TAG();
@@ -1445,9 +1445,9 @@ rb_eval_string(const char *str) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1445
  * @return The evaluated result if succeeded, an undefined value if otherwise.
  */
 VALUE
-rb_eval_string_protect(const char *str, int *state)
+rb_eval_string_protect(const char *str, int *pstate)
 {
-    return rb_protect((VALUE (*)(VALUE))rb_eval_string, (VALUE)str, state);
+    return rb_protect((VALUE (*)(VALUE))rb_eval_string, (VALUE)str, pstate);
 }
 
 /**
@@ -1462,9 +1462,9 @@ rb_eval_string_protect(const char *str, https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1462
  * @return The evaluated result if succeeded, an undefined value if otherwise.
  */
 VALUE
-rb_eval_string_wrap(const char *str, int *state)
+rb_eval_string_wrap(const char *str, int *pstate)
 {
-    int status;
+    int state;
     rb_thread_t *th = GET_THREAD();
     VALUE self = th->top_self;
     VALUE wrapper = th->top_wrapper;
@@ -1474,16 +1474,16 @@ rb_eval_string_wrap(const char *str, int https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1474
     th->top_self = rb_obj_clone(rb_vm_top_self());
     rb_extend_object(th->top_self, th->top_wrapper);
 
-    val = rb_eval_string_protect(str, &status);
+    val = rb_eval_string_protect(str, &state);
 
     th->top_self = self;
     th->top_wrapper = wrapper;
 
-    if (state) {
-	*state = status;
+    if (pstate) {
+	*pstate = state;
     }
-    else if (status) {
-	TH_JUMP_TAG(th, status);
+    else if (state != TAG_NONE) {
+	TH_JUMP_TAG(th, state);
     }
     return val;
 }
@@ -1491,7 +1491,7 @@ rb_eval_string_wrap(const char *str, int https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1491
 VALUE
 rb_eval_cmd(VALUE cmd, VALUE arg, int level)
 {
-    int state;
+    enum ruby_tag_type state;
     volatile VALUE val = Qnil;		/* OK */
     const int VAR_NOCLOBBERED(safe) = rb_safe_level();
     rb_thread_t *const VAR_NOCLOBBERED(th) = GET_THREAD();
@@ -1502,7 +1502,7 @@ rb_eval_cmd(VALUE cmd, VALUE arg, int le https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1502
 
     TH_PUSH_TAG(th);
     rb_set_safe_level_force(level);
-    if ((state = TH_EXEC_TAG()) == 0) {
+    if ((state = TH_EXEC_TAG()) == TAG_NONE) {
 	if (!RB_TYPE_P(cmd, T_STRING)) {
 	    val = rb_funcallv(cmd, idCall, RARRAY_LENINT(arg),
 			      RARRAY_CONST_PTR(arg));
@@ -1981,7 +1981,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1981
 vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
 		 int *stateptr, rb_thread_t *volatile th)
 {
-    int state;
+    enum ruby_tag_type state;
     VALUE val = Qnil;		/* OK */
     rb_control_frame_t *volatile saved_cfp = th->ec.cfp;
 
@@ -1989,7 +1989,7 @@ vm_catch_protect(VALUE tag, rb_block_cal https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L1989
 
     _tag.tag = tag;
 
-    if ((state = TH_EXEC_TAG()) == 0) {
+    if ((state = TH_EXEC_TAG()) == TAG_NONE) {
 	/* call with argc=1, argv = [tag], block = Qnil to insure compatibility */
 	val = (*func)(tag, data, 1, (const VALUE *)&tag, Qnil);
     }
Index: proc.c
===================================================================
--- proc.c	(revision 59154)
+++ proc.c	(revision 59155)
@@ -2049,10 +2049,10 @@ call_method_data_safe(rb_thread_t *th, c https://github.com/ruby/ruby/blob/trunk/proc.c#L2049
 		      int safe)
 {
     VALUE result = Qnil;	/* OK */
-    int state;
+    enum ruby_tag_type state;
 
     TH_PUSH_TAG(th);
-    if ((state = TH_EXEC_TAG()) == 0) {
+    if ((state = TH_EXEC_TAG()) == TAG_NONE) {
 	/* result is used only if state == 0, no exceptions is caught. */
 	/* otherwise it doesn't matter even if clobbered. */
 	NO_CLOBBERED(result) = call_method_data(th, data, argc, argv, passed_procval);
Index: thread.c
===================================================================
--- thread.c	(revision 59154)
+++ thread.c	(revision 59155)
@@ -490,7 +490,7 @@ rb_thread_terminate_all(void) https://github.com/ruby/ruby/blob/trunk/thread.c#L490
     rb_threadptr_unlock_all_locking_mutexes(th);
 
     TH_PUSH_TAG(th);
-    if (TH_EXEC_TAG() == 0) {
+    if (TH_EXEC_TAG() == TAG_NONE) {
       retry:
 	thread_debug("rb_thread_terminate_all (main thread: %p)\n", (void *)th);
 	terminate_all(vm, th);
@@ -597,7 +597,7 @@ thread_do_start(rb_thread_t *th, VALUE a https://github.com/ruby/ruby/blob/trunk/thread.c#L597
 static int
 thread_start_func_2(rb_thread_t *th, VALUE *stack_start, VALUE *register_stack_start)
 {
-    int state;
+    enum ruby_tag_type state;
     VALUE args = th->first_args;
     rb_thread_list_t *join_list;
     rb_thread_t *main_th;
@@ -625,7 +625,7 @@ thread_start_func_2(rb_thread_t *th, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L625
 	rb_thread_set_current(th);
 
 	TH_PUSH_TAG(th);
-	if ((state = EXEC_TAG()) == 0) {
+	if ((state = EXEC_TAG()) == TAG_NONE) {
 	    SAVE_ROOT_JMPBUF(th, thread_do_start(th, args));
 	}
 	else {
@@ -1444,7 +1444,7 @@ rb_thread_io_blocking_region(rb_blocking https://github.com/ruby/ruby/blob/trunk/thread.c#L1444
     rb_vm_t *vm = GET_VM();
     rb_thread_t *th = GET_THREAD();
     volatile int saved_errno = 0;
-    int state;
+    enum ruby_tag_type state;
     struct waiting_fd wfd;
 
     wfd.fd = fd;
@@ -1452,7 +1452,7 @@ rb_thread_io_blocking_region(rb_blocking https://github.com/ruby/ruby/blob/trunk/thread.c#L1452
     list_add(&vm->waiting_fds, &wfd.wfd_node);
 
     TH_PUSH_TAG(th);
-    if ((state = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	BLOCKING_REGION({
 	    val = func(data1);
 	    saved_errno = errno;
@@ -1865,7 +1865,7 @@ rb_thread_s_handle_interrupt(VALUE self, https://github.com/ruby/ruby/blob/trunk/thread.c#L1865
     VALUE mask;
     rb_thread_t *th = GET_THREAD();
     volatile VALUE r = Qnil;
-    int state;
+    enum ruby_tag_type state;
 
     if (!rb_block_given_p()) {
 	rb_raise(rb_eArgError, "block is needed.");
@@ -1885,7 +1885,7 @@ rb_thread_s_handle_interrupt(VALUE self, https://github.com/ruby/ruby/blob/trunk/thread.c#L1885
     }
 
     TH_PUSH_TAG(th);
-    if ((state = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	r = rb_yield(Qnil);
     }
     TH_POP_TAG();
@@ -4689,7 +4689,7 @@ exec_recursive(VALUE (*func) (VALUE, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L4689
 	return (*func)(obj, arg, TRUE);
     }
     else {
-	int state;
+	enum ruby_tag_type state;
 
 	p.func = func;
 
@@ -4708,7 +4708,7 @@ exec_recursive(VALUE (*func) (VALUE, VAL https://github.com/ruby/ruby/blob/trunk/thread.c#L4708
 	    volatile VALUE ret = Qundef;
 	    recursive_push(p.list, p.objid, p.pairid);
 	    PUSH_TAG();
-	    if ((state = EXEC_TAG()) == 0) {
+	    if ((state = EXEC_TAG()) == TAG_NONE) {
 		ret = (*func)(obj, arg, FALSE);
 	    }
 	    POP_TAG();
Index: vm_backtrace.c
===================================================================
--- vm_backtrace.c	(revision 59154)
+++ vm_backtrace.c	(revision 59155)
@@ -1174,7 +1174,7 @@ rb_debug_inspector_open(rb_debug_inspect https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L1174
 {
     rb_debug_inspector_t dbg_context;
     rb_thread_t *th = GET_THREAD();
-    int state;
+    enum ruby_tag_type state;
     volatile VALUE MAYBE_UNUSED(result);
 
     dbg_context.th = th;
@@ -1184,7 +1184,7 @@ rb_debug_inspector_open(rb_debug_inspect https://github.com/ruby/ruby/blob/trunk/vm_backtrace.c#L1184
     dbg_context.contexts = collect_caller_bindings(th);
 
     TH_PUSH_TAG(th);
-    if ((state = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	result = (*func)(&dbg_context, data);
     }
     TH_POP_TAG();
Index: eval_jump.c
===================================================================
--- eval_jump.c	(revision 59154)
+++ eval_jump.c	(revision 59155)
@@ -113,13 +113,13 @@ exec_end_procs_chain(struct end_proc_dat https://github.com/ruby/ruby/blob/trunk/eval_jump.c#L113
 void
 rb_exec_end_proc(void)
 {
-    int status;
+    enum ruby_tag_type state;
     volatile int safe = rb_safe_level();
     rb_thread_t *th = GET_THREAD();
     volatile VALUE errinfo = th->errinfo;
 
     TH_PUSH_TAG(th);
-    if ((status = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
       again:
 	exec_end_procs_chain(&ephemeral_end_procs, &th->errinfo);
 	exec_end_procs_chain(&end_procs, &th->errinfo);
@@ -127,7 +127,7 @@ rb_exec_end_proc(void) https://github.com/ruby/ruby/blob/trunk/eval_jump.c#L127
     else {
 	VAR_INITIALIZED(th);
 	TH_TMPPOP_TAG();
-	error_handle(status);
+	error_handle(state);
 	if (!NIL_P(th->errinfo)) errinfo = th->errinfo;
 	TH_REPUSH_TAG();
 	goto again;
Index: eval.c
===================================================================
--- eval.c	(revision 59154)
+++ eval.c	(revision 59155)
@@ -45,7 +45,7 @@ static ID id_cause; https://github.com/ruby/ruby/blob/trunk/eval.c#L45
 int
 ruby_setup(void)
 {
-    int state;
+    enum ruby_tag_type state;
 
     if (GET_VM())
 	return 0;
@@ -56,7 +56,7 @@ ruby_setup(void) https://github.com/ruby/ruby/blob/trunk/eval.c#L56
     Init_vm_objects();
 
     PUSH_TAG();
-    if ((state = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	rb_call_inits();
 	ruby_prog_init();
 	GET_VM()->running = 1;
@@ -94,12 +94,12 @@ ruby_init(void) https://github.com/ruby/ruby/blob/trunk/eval.c#L94
 void *
 ruby_options(int argc, char **argv)
 {
-    int state;
+    enum ruby_tag_type state;
     void *volatile iseq = 0;
 
     ruby_init_stack((void *)&iseq);
     PUSH_TAG();
-    if ((state = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	SAVE_ROOT_JMPBUF(GET_THREAD(), iseq = ruby_process_options(argc, argv));
     }
     else {
@@ -115,7 +115,7 @@ static void https://github.com/ruby/ruby/blob/trunk/eval.c#L115
 ruby_finalize_0(void)
 {
     PUSH_TAG();
-    if (EXEC_TAG() == 0) {
+    if (EXEC_TAG() == TAG_NONE) {
 	rb_trap_exit();
     }
     POP_TAG();
@@ -168,7 +168,7 @@ ruby_cleanup(volatile int ex) https://github.com/ruby/ruby/blob/trunk/eval.c#L168
     rb_threadptr_interrupt(th);
     rb_threadptr_check_signal(th);
     TH_PUSH_TAG(th);
-    if ((state = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	SAVE_ROOT_JMPBUF(th, { RUBY_VM_CHECK_INTS(th); });
 
       step_0: step++;
@@ -240,7 +240,7 @@ ruby_exec_internal(void *n) https://github.com/ruby/ruby/blob/trunk/eval.c#L240
     if (!n) return 0;
 
     TH_PUSH_TAG(th);
-    if ((state = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	SAVE_ROOT_JMPBUF(th, {
 	    rb_iseq_eval_main(iseq);
 	});
@@ -492,10 +492,10 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L492
 
     file = rb_source_loc(&line);
     if ((file && !NIL_P(mesg)) || (cause != Qundef))  {
-	int status;
+	enum ruby_tag_type state;
 
 	TH_PUSH_TAG(th);
-	if (EXEC_TAG() == 0 && !(status = rb_threadptr_set_raised(th))) {
+	if (EXEC_TAG() == TAG_NONE && !(state = rb_threadptr_set_raised(th))) {
 	    VALUE bt = rb_get_backtrace(mesg);
 	    if (!NIL_P(bt) || cause == Qundef) {
 		if (OBJ_FROZEN(mesg)) {
@@ -513,7 +513,7 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L513
 	    rb_threadptr_reset_raised(th);
 	}
 	TH_POP_TAG();
-	if (status) goto fatal;
+	if (state) goto fatal;
     }
 
     if (!NIL_P(mesg)) {
@@ -522,11 +522,11 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L522
 
     if (RTEST(ruby_debug) && !NIL_P(e = th->errinfo) &&
 	!rb_obj_is_kind_of(e, rb_eSystemExit)) {
-	int status;
+	enum ruby_tag_type state;
 
 	mesg = e;
 	TH_PUSH_TAG(th);
-	if ((status = EXEC_TAG()) == 0) {
+	if ((state = EXEC_TAG()) == TAG_NONE) {
 	    th->errinfo = Qnil;
 	    e = rb_obj_as_string(mesg);
 	    th->errinfo = mesg;
@@ -545,12 +545,12 @@ setup_exception(rb_thread_t *th, int tag https://github.com/ruby/ruby/blob/trunk/eval.c#L545
 	    warn_print_str(e);
 	}
 	TH_POP_TAG();
-	if (status == TAG_FATAL && th->errinfo == exception_error) {
+	if (state == TAG_FATAL && th->errinfo == exception_error) {
 	    th->errinfo = mesg;
 	}
-	else if (status) {
+	else if (state) {
 	    rb_threadptr_reset_raised(th);
-	    TH_JUMP_TAG(th, status);
+	    TH_JUMP_TAG(th, state);
 	}
     }
 
@@ -793,7 +793,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/eval.c#L793
 rb_rescue2(VALUE (* b_proc) (ANYARGS), VALUE data1,
 	   VALUE (* r_proc) (ANYARGS), VALUE data2, ...)
 {
-    int state;
+    enum ruby_tag_type state;
     rb_thread_t *th = GET_THREAD();
     rb_control_frame_t *volatile cfp = th->ec.cfp;
     volatile VALUE result = Qfalse;
@@ -801,7 +801,7 @@ rb_rescue2(VALUE (* b_proc) (ANYARGS), V https://github.com/ruby/ruby/blob/trunk/eval.c#L801
     va_list args;
 
     TH_PUSH_TAG(th);
-    if ((state = TH_EXEC_TAG()) == 0) {
+    if ((state = TH_EXEC_TAG()) == TAG_NONE) {
       retry_entry:
 	result = (*b_proc) (data1);
     }
@@ -856,10 +856,10 @@ rb_rescue(VALUE (* b_proc)(ANYARGS), VAL https://github.com/ruby/ruby/blob/trunk/eval.c#L856
 }
 
 VALUE
-rb_protect(VALUE (* proc) (VALUE), VALUE data, int * state)
+rb_protect(VALUE (* proc) (VALUE), VALUE data, int *pstate)
 {
     volatile VALUE result = Qnil;
-    volatile int status;
+    volatile enum ruby_tag_type state;
     rb_thread_t *th = GET_THREAD();
     rb_control_frame_t *volatile cfp = th->ec.cfp;
     struct rb_vm_protect_tag protect_tag;
@@ -870,7 +870,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE https://github.com/ruby/ruby/blob/trunk/eval.c#L870
     TH_PUSH_TAG(th);
     th->protect_tag = &protect_tag;
     MEMCPY(&org_jmpbuf, &(th)->root_jmpbuf, rb_jmpbuf_t, 1);
-    if ((status = TH_EXEC_TAG()) == 0) {
+    if ((state = TH_EXEC_TAG()) == TAG_NONE) {
 	SAVE_ROOT_JMPBUF(th, result = (*proc) (data));
     }
     else {
@@ -880,10 +880,7 @@ rb_protect(VALUE (* proc) (VALUE), VALUE https://github.com/ruby/ruby/blob/trunk/eval.c#L880
     th->protect_tag = protect_tag.prev;
     TH_POP_TAG();
 
-    if (state) {
-	*state = status;
-    }
-
+    if (pstate != NULL) *pstate = state;
     return result;
 }
 
@@ -901,7 +898,7 @@ rb_ensure(VALUE (*b_proc)(ANYARGS), VALU https://github.com/ruby/ruby/blob/trunk/eval.c#L898
     ensure_list.next = th->ensure_list;
     th->ensure_list = &ensure_list;
     TH_PUSH_TAG(th);
-    if ((state = EXEC_TAG()) == 0) {
+    if ((state = EXEC_TAG()) == TAG_NONE) {
 	result = (*b_proc) (data1);
     }
     TH_POP_TAG();
Index: gc.c
===================================================================
--- gc.c	(revision 59154)
+++ gc.c	(revision 59155)
@@ -2777,7 +2777,7 @@ static void https://github.com/ruby/ruby/blob/trunk/gc.c#L2777
 run_finalizer(rb_objspace_t *obj (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]