aboutsummaryrefslogtreecommitdiffstats
path: root/vm_eval.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-23 07:25:52 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-06-23 07:25:52 +0000
commit919c7802999ce403bb91c9c47e5e707d1ee6342a (patch)
tree479ee29eaecd26251ee6c4a783ad9c52db7f541f /vm_eval.c
parentd3b8612d3ffc9606d9e4da84e4cf834a35cca4c5 (diff)
downloadruby-919c7802999ce403bb91c9c47e5e707d1ee6342a.tar.gz
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'vm_eval.c')
-rw-r--r--vm_eval.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/vm_eval.c b/vm_eval.c
index a1bae98364..02a9580959 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1105,7 +1105,7 @@ rb_iterate0(VALUE (* it_proc) (VALUE), VALUE data1,
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), VALUE data1,
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 src, VALUE scope, rb_cref_t *const cref_
}
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)
* @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, int *state)
* @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 *state)
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 *state)
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 level)
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
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_call_func *func, VALUE data,
_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);
}