there is no such thing like 0 in enum defined_type

introduce new enum for it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61946 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
shyouhei 2018-01-19 05:18:18 +00:00
parent 12c0cc0172
commit 00d0bef714
3 changed files with 4 additions and 3 deletions

View File

@ -4113,7 +4113,7 @@ static int
defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret, defined_expr0(rb_iseq_t *iseq, LINK_ANCHOR *const ret,
const NODE *const node, LABEL **lfinish, VALUE needstr) const NODE *const node, LABEL **lfinish, VALUE needstr)
{ {
enum defined_type expr_type = 0; enum defined_type expr_type = DEFINED_NOT_DEFINED;
enum node_type type; enum node_type type;
switch (type = nd_type(node)) { switch (type = nd_type(node)) {

1
iseq.h
View File

@ -276,6 +276,7 @@ struct iseq_compile_data_storage {
/* defined? */ /* defined? */
enum defined_type { enum defined_type {
DEFINED_NOT_DEFINED,
DEFINED_NIL = 1, DEFINED_NIL = 1,
DEFINED_IVAR, DEFINED_IVAR,
DEFINED_LVAR, DEFINED_LVAR,

View File

@ -2809,7 +2809,7 @@ check_respond_to_missing(VALUE obj, VALUE v)
return DEFINED_METHOD; return DEFINED_METHOD;
} }
else { else {
return 0; return DEFINED_NOT_DEFINED;
} }
} }
@ -2817,7 +2817,7 @@ static VALUE
vm_defined(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, rb_num_t op_type, VALUE obj, VALUE needstr, VALUE v) vm_defined(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, rb_num_t op_type, VALUE obj, VALUE needstr, VALUE v)
{ {
VALUE klass; VALUE klass;
enum defined_type expr_type = 0; enum defined_type expr_type = DEFINED_NOT_DEFINED;
enum defined_type type = (enum defined_type)op_type; enum defined_type type = (enum defined_type)op_type;
switch (type) { switch (type) {