aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-23 08:24:54 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-23 08:24:54 +0000
commitd480f6889ac7d2a04bf65cbc066a8dc82c603e03 (patch)
treec20f7d0544a5754228eafb28f984c736fea49df4
parentd30a1b1e2bf9fb8844b7615b7d33e4036975d7c9 (diff)
downloadruby-d480f6889ac7d2a04bf65cbc066a8dc82c603e03.tar.gz
rb_catch_protect() accepts enum ruby_tag_type *.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--internal.h1
-rw-r--r--thread.c8
-rw-r--r--vm_core.h2
-rw-r--r--vm_eval.c37
4 files changed, 23 insertions, 25 deletions
diff --git a/internal.h b/internal.h
index 5518825f7e..a474830a2e 100644
--- a/internal.h
+++ b/internal.h
@@ -1740,7 +1740,6 @@ typedef void rb_check_funcall_hook(int, VALUE, ID, int, const VALUE *, VALUE);
VALUE rb_check_funcall_with_hook(VALUE recv, ID mid, int argc, const VALUE *argv,
rb_check_funcall_hook *hook, VALUE arg);
VALUE rb_check_funcall_default(VALUE, ID, int, const VALUE *, VALUE);
-VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr);
VALUE rb_yield_1(VALUE val);
VALUE rb_yield_force_blockarg(VALUE values);
diff --git a/thread.c b/thread.c
index 5e0cac5fa8..edae43e50c 100644
--- a/thread.c
+++ b/thread.c
@@ -4689,22 +4689,22 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
return (*func)(obj, arg, TRUE);
}
else {
+ enum ruby_tag_type state;
+
p.func = func;
if (outermost) {
- int state;
recursive_push(p.list, ID2SYM(recursive_key), 0);
recursive_push(p.list, p.objid, p.pairid);
result = rb_catch_protect(p.list, exec_recursive_i, (VALUE)&p, &state);
if (!recursive_pop(p.list, p.objid, p.pairid)) goto invalid;
if (!recursive_pop(p.list, ID2SYM(recursive_key), 0)) goto invalid;
- if (state) JUMP_TAG(state);
+ if (state != TAG_NONE) JUMP_TAG(state);
if (result == p.list) {
result = (*func)(obj, arg, TRUE);
}
}
else {
- enum ruby_tag_type state;
volatile VALUE ret = Qundef;
recursive_push(p.list, p.objid, p.pairid);
PUSH_TAG();
@@ -4718,7 +4718,7 @@ exec_recursive(VALUE (*func) (VALUE, VALUE, int), VALUE obj, VALUE pairid, VALUE
"for %+"PRIsVALUE" in %+"PRIsVALUE,
sym, rb_thread_current());
}
- if (state) JUMP_TAG(state);
+ if (state != TAG_NONE) JUMP_TAG(state);
result = ret;
}
}
diff --git a/vm_core.h b/vm_core.h
index 86b2fe9311..29cc836164 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -1537,6 +1537,8 @@ const rb_callable_method_entry_t *rb_vm_frame_method_entry(const rb_control_fram
#define CHECK_VM_STACK_OVERFLOW(cfp, margin) \
WHEN_VM_STACK_OVERFLOWED(cfp, (cfp)->sp, margin) vm_stackoverflow()
+VALUE rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr);
+
/* for thread */
#if RUBY_VM_THREAD_MODEL == 2
diff --git a/vm_eval.c b/vm_eval.c
index 02a9580959..5479f08dd5 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1958,28 +1958,9 @@ rb_catch(const char *tag, VALUE (*func)(), VALUE data)
return rb_catch_obj(vtag, func, data);
}
-static VALUE vm_catch_protect(VALUE, rb_block_call_func *, VALUE, int *, rb_thread_t *volatile);
-
-VALUE
-rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data)
-{
- int state;
- rb_thread_t *th = GET_THREAD();
- VALUE val = vm_catch_protect(t, (rb_block_call_func *)func, data, &state, th);
- if (state)
- TH_JUMP_TAG(th, state);
- return val;
-}
-
-VALUE
-rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, int *stateptr)
-{
- return vm_catch_protect(t, func, data, stateptr, GET_THREAD());
-}
-
static VALUE
vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
- int *stateptr, rb_thread_t *volatile th)
+ enum ruby_tag_type *stateptr, rb_thread_t *volatile th)
{
enum ruby_tag_type state;
VALUE val = Qnil; /* OK */
@@ -2006,6 +1987,22 @@ vm_catch_protect(VALUE tag, rb_block_call_func *func, VALUE data,
return val;
}
+VALUE
+rb_catch_protect(VALUE t, rb_block_call_func *func, VALUE data, enum ruby_tag_type *stateptr)
+{
+ return vm_catch_protect(t, func, data, stateptr, GET_THREAD());
+}
+
+VALUE
+rb_catch_obj(VALUE t, VALUE (*func)(), VALUE data)
+{
+ enum ruby_tag_type state;
+ rb_thread_t *th = GET_THREAD();
+ VALUE val = vm_catch_protect(t, (rb_block_call_func *)func, data, &state, th);
+ if (state) TH_JUMP_TAG(th, state);
+ return val;
+}
+
static void
local_var_list_init(struct local_var_list *vars)
{