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

ruby-changes:38662

From: ko1 <ko1@a...>
Date: Wed, 3 Jun 2015 10:39:46 +0900 (JST)
Subject: [ruby-changes:38662] ko1:r50743 (trunk): * method.h: split rb_method_definition_t::flag to several flags.

ko1	2015-06-03 10:39:16 +0900 (Wed, 03 Jun 2015)

  New Revision: 50743

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

  Log:
    * method.h: split rb_method_definition_t::flag to several flags.
      `flag' contains several categories of attributes and it makes us
      confusion (at least, I had confused).
      * rb_method_visibility_t (flags::visi)
        * NOEX_UNDEF     -> METHOD_VISI_UNDEF     = 0
        * NOEX_PUBLIC    -> METHOD_VISI_PUBLIC    = 1
        * NOEX_PRIVATE   -> METHOD_VISI_PRIVATE   = 2
        * NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3
      * NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits)
      * NOEX_BASIC       -> basic (flags::basic, 1 bit)
      * NOEX_MODFUNC     -> rb_scope_visibility_t in CREF
      * NOEX_SUPER       -> MISSING_SUPER (enum missing_reason)
      * NOEX_VCALL       -> MISSING_VCALL (enum missing_reason)
      * NOEX_RESPONDS    -> BOUND_RESPONDS (macro)
      Now, NOEX_NOREDEF is not supported (I'm not sure it is needed).
      Background:
        I did not know what "NOEX" stands for.
        I asked Matz (who made this name) and his answer was "Nothing".
        "At first, it meant NO EXport (private), but the original
        meaning was gone."
        This is why I remove the mysterious word "NOEX" from MRI.
    * vm_core.h: introduce `enum missing_reason' to represent
      method_missing (NoMethodError) reason.
    * eval_intern.h: introduce rb_scope_visibility_t to represent
      scope visibility.
      It has 3 method visibilities (public/private/protected)
      and `module_function`.

  Modified files:
    trunk/ChangeLog
    trunk/class.c
    trunk/eval_error.c
    trunk/eval_intern.h
    trunk/insns.def
    trunk/internal.h
    trunk/load.c
    trunk/method.h
    trunk/parse.y
    trunk/proc.c
    trunk/struct.c
    trunk/vm.c
    trunk/vm_core.h
    trunk/vm_eval.c
    trunk/vm_insnhelper.c
    trunk/vm_insnhelper.h
    trunk/vm_method.c
Index: eval_intern.h
===================================================================
--- eval_intern.h	(revision 50742)
+++ eval_intern.h	(revision 50743)
@@ -228,16 +228,25 @@ CREF_NEXT_SET(rb_cref_t *cref, const rb_ https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L228
     RB_OBJ_WRITE(cref, &cref->next, next_cref);
 }
 
-static inline long
-CREF_VISI(const rb_cref_t *cref)
+typedef struct rb_scope_visi_struct {
+    rb_method_visibility_t method_visi : 3;
+    unsigned int module_func : 1;
+} rb_scope_visibility_t;
+
+static inline const rb_scope_visibility_t *
+CREF_SCOPE_VISI(const rb_cref_t *cref)
 {
-    return (long)cref->visi;
+    return (const rb_scope_visibility_t *)&cref->scope_visi;
 }
 
 static inline void
-CREF_VISI_SET(rb_cref_t *cref, long v)
+CREF_SCOPE_VISI_COPY(const rb_cref_t *dst_cref, rb_cref_t *src_cref)
 {
-    cref->visi = v;
+    rb_scope_visibility_t *src = (rb_scope_visibility_t *)&src_cref->scope_visi;
+    rb_scope_visibility_t *dst = (rb_scope_visibility_t *)&dst_cref->scope_visi;
+
+    dst->method_visi = src->method_visi;
+    dst->module_func = src->module_func;
 }
 
 static inline VALUE
@@ -282,7 +291,7 @@ CREF_OMOD_SHARED_UNSET(rb_cref_t *cref) https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L291
     cref->flags &= ~NODE_FL_CREF_OMOD_SHARED_;
 }
 
-void rb_frame_visibility_set(rb_method_flag_t);
+void rb_frame_visibility_set(rb_method_visibility_t);
 
 void rb_thread_cleanup(void);
 void rb_thread_wait_other_threads(void);
@@ -308,7 +317,7 @@ NORETURN(void rb_fiber_start(void)); https://github.com/ruby/ruby/blob/trunk/eval_intern.h#L317
 
 NORETURN(void rb_print_undef(VALUE, ID, int));
 NORETURN(void rb_print_undef_str(VALUE, VALUE));
-NORETURN(void rb_print_inaccessible(VALUE, ID, int));
+NORETURN(void rb_print_inaccessible(VALUE, ID, rb_method_visibility_t));
 NORETURN(void rb_vm_localjump_error(const char *,VALUE, int));
 NORETURN(void rb_vm_jump_tag_but_local_jump(int));
 NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv,
Index: method.h
===================================================================
--- method.h	(revision 50742)
+++ method.h	(revision 50743)
@@ -21,27 +21,6 @@ https://github.com/ruby/ruby/blob/trunk/method.h#L21
 # endif
 #endif
 
-typedef enum {
-    NOEX_PUBLIC    = 0x00,
-    NOEX_NOSUPER   = 0x01,
-    NOEX_PRIVATE   = 0x02,
-    NOEX_PROTECTED = 0x04,
-    NOEX_MASK      = 0x06,
-    NOEX_BASIC     = 0x08,
-    NOEX_UNDEF     = NOEX_NOSUPER,
-    NOEX_MODFUNC   = 0x12,
-    NOEX_SUPER     = 0x20,
-    NOEX_VCALL     = 0x40,
-    NOEX_RESPONDS  = 0x80,
-
-    NOEX_BIT_WIDTH = 8,
-    NOEX_SAFE_SHIFT_OFFSET = ((NOEX_BIT_WIDTH+3)/4)*4 /* round up to nibble */
-} rb_method_flag_t;
-
-#define NOEX_SAFE(n) ((int)((n) >> NOEX_SAFE_SHIFT_OFFSET) & 0x0F)
-#define NOEX_WITH(n, s) (((s) << NOEX_SAFE_SHIFT_OFFSET) | (n) | (ruby_running ? 0 : NOEX_BASIC))
-#define NOEX_WITH_SAFE(n) NOEX_WITH((n), rb_safe_level())
-
 /* method data type */
 
 typedef struct rb_method_entry_struct {
@@ -53,6 +32,13 @@ typedef struct rb_method_entry_struct { https://github.com/ruby/ruby/blob/trunk/method.h#L32
 } rb_method_entry_t;
 
 typedef enum {
+    METHOD_VISI_UNDEF     = 0x00,
+    METHOD_VISI_PUBLIC    = 0x01,
+    METHOD_VISI_PRIVATE   = 0x02,
+    METHOD_VISI_PROTECTED = 0x03
+} rb_method_visibility_t;
+
+typedef enum {
     VM_METHOD_TYPE_ISEQ,
     VM_METHOD_TYPE_CFUNC,
     VM_METHOD_TYPE_ATTRSET,
@@ -92,10 +78,12 @@ typedef struct rb_method_alias_struct { https://github.com/ruby/ruby/blob/trunk/method.h#L78
 } rb_method_alias_t;
 
 typedef struct rb_method_definition_struct {
-    rb_method_flag_t flag;
+    struct {
+	rb_method_visibility_t visi: 3;
+	unsigned int basic: 1;
+	unsigned int safe: 3;
+    } flags;
     rb_method_type_t type; /* method type */
-    int *alias_count_ptr;
-    ID original_id;
 
     union {
 	rb_method_iseq_t iseq;
@@ -111,6 +99,9 @@ typedef struct rb_method_definition_stru https://github.com/ruby/ruby/blob/trunk/method.h#L99
 	} optimize_type;
 	struct rb_method_entry_struct *orig_me;
     } body;
+
+    int *alias_count_ptr;
+    ID original_id;
 } rb_method_definition_t;
 
 #define UNDEFINED_METHOD_ENTRY_P(me) (!(me) || !(me)->def || (me)->def->type == VM_METHOD_TYPE_UNDEF)
@@ -118,9 +109,9 @@ typedef struct rb_method_definition_stru https://github.com/ruby/ruby/blob/trunk/method.h#L109
     ((def)->type == VM_METHOD_TYPE_REFINED && \
      UNDEFINED_METHOD_ENTRY_P((def)->body.orig_me))
 
-void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
-void rb_add_method_iseq(VALUE klass, ID mid, VALUE iseqval, rb_cref_t *cref, rb_method_flag_t noex);
-rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
+void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_visibility_t visi);
+void rb_add_method_iseq(VALUE klass, ID mid, VALUE iseqval, rb_cref_t *cref, rb_method_visibility_t visi);
+rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_visibility_t visi);
 rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
 rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
 void rb_add_refined_method_entry(VALUE refined_class, ID mid);
@@ -133,7 +124,7 @@ rb_method_entry_t *rb_method_entry_witho https://github.com/ruby/ruby/blob/trunk/method.h#L124
 						       VALUE *defined_class_ptr);
 
 rb_method_entry_t *rb_method_entry_get_without_cache(VALUE klass, ID id, VALUE *define_class_ptr);
-rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_flag_t noex);
+rb_method_entry_t *rb_method_entry_set(VALUE klass, ID mid, const rb_method_entry_t *, rb_method_visibility_t noex);
 
 int rb_method_entry_arity(const rb_method_entry_t *me);
 int rb_method_entry_eq(const rb_method_entry_t *m1, const rb_method_entry_t *m2);
Index: insns.def
===================================================================
--- insns.def	(revision 50742)
+++ insns.def	(revision 50743)
@@ -917,7 +917,7 @@ defineclass https://github.com/ruby/ruby/blob/trunk/insns.def#L917
     vm_push_frame(th, class_iseq, VM_FRAME_MAGIC_CLASS,
 		  klass, 0,
 		  VM_ENVVAL_BLOCK_PTR(GET_BLOCK_PTR()),
-		  (VALUE)vm_cref_push(th, klass, NOEX_PUBLIC, NULL),
+		  (VALUE)vm_cref_push(th, klass, NULL),
 		  class_iseq->iseq_encoded, GET_SP(),
 		  class_iseq->local_size, class_iseq->stack_max);
 
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 50742)
+++ ChangeLog	(revision 50743)
@@ -1,3 +1,39 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jun 03 10:35:45 2015  Koichi Sasada  <ko1@a...>
+
+	* method.h: split rb_method_definition_t::flag to several flags.
+
+	  `flag' contains several categories of attributes and it makes us
+	  confusion (at least, I had confused).
+
+	  * rb_method_visibility_t (flags::visi)
+	    * NOEX_UNDEF     -> METHOD_VISI_UNDEF     = 0
+	    * NOEX_PUBLIC    -> METHOD_VISI_PUBLIC    = 1
+	    * NOEX_PRIVATE   -> METHOD_VISI_PRIVATE   = 2
+	    * NOEX_PROTECTED -> METHOD_VISI_PROTECTED = 3
+	  * NOEX_SAFE(flag)) -> safe (flags::safe, 2 bits)
+	  * NOEX_BASIC       -> basic (flags::basic, 1 bit)
+	  * NOEX_MODFUNC     -> rb_scope_visibility_t in CREF
+	  * NOEX_SUPER       -> MISSING_SUPER (enum missing_reason)
+	  * NOEX_VCALL       -> MISSING_VCALL (enum missing_reason)
+	  * NOEX_RESPONDS    -> BOUND_RESPONDS (macro)
+
+	  Now, NOEX_NOREDEF is not supported (I'm not sure it is needed).
+
+	  Background:
+	    I did not know what "NOEX" stands for.
+	    I asked Matz (who made this name) and his answer was "Nothing".
+	    "At first, it meant NO EXport (private), but the original
+	    meaning was gone."
+	    This is why I remove the mysterious word "NOEX" from MRI.
+
+	* vm_core.h: introduce `enum missing_reason' to represent
+	  method_missing (NoMethodError) reason.
+
+	* eval_intern.h: introduce rb_scope_visibility_t to represent
+	  scope visibility.
+	  It has 3 method visibilities (public/private/protected)
+	  and `module_function`.
+
 Wed Jun  3 08:06:30 2015  NAKAMURA Usaku  <usa@r...>
 
 	* gem/bundled_gems: updated to test-unit 3.1.1 and minitest 5.7.0.
Index: vm_core.h
===================================================================
--- vm_core.h	(revision 50742)
+++ vm_core.h	(revision 50743)
@@ -167,7 +167,15 @@ typedef struct rb_call_info_struct { https://github.com/ruby/ruby/blob/trunk/vm_core.h#L167
     union {
 	int opt_pc; /* used by iseq */
 	int index; /* used by ivar */
-	int missing_reason; /* used by method_missing */
+	enum missing_reason {
+	    MISSING_NOENTRY   = 0x00,
+	    MISSING_PRIVATE   = 0x01,
+	    MISSING_PROTECTED = 0x02,
+	    MISSING_VCALL     = 0x04,
+	    MISSING_SUPER     = 0x08,
+	    MISSING_MISSING   = 0x10,
+	    MISSING_NONE      = 0x20
+	} missing_reason; /* used by method_missing */
 	int inc_sp; /* used by cfunc */
     } aux;
 
Index: eval_error.c
===================================================================
--- eval_error.c	(revision 50742)
+++ eval_error.c	(revision 50743)
@@ -209,23 +209,22 @@ ruby_error_print(void) https://github.com/ruby/ruby/blob/trunk/eval_error.c#L209
 }
 
 static const char *
-method_scope_name(int scope)
+method_visibility_name(rb_method_visibility_t visi)
 {
-    const char *v;
-
-    switch (scope) {
-      default:
-      case NOEX_PUBLIC: v = ""; break;
-      case NOEX_PRIVATE: v = " private"; break;
-      case NOEX_PROTECTED: v = " protected"; break;
+    switch (visi) {
+      case METHOD_VISI_UNDEF:
+      case METHOD_VISI_PUBLIC:    return "";
+      case METHOD_VISI_PRIVATE:   return " private";
+      case METHOD_VISI_PROTECTED: return " protected";
     }
-    return v;
+    rb_bug("method_visibility_name: unreachable (%d)", (int)visi);
 }
 
 void
-rb_print_undef(VALUE klass, ID id, int scope)
+rb_print_undef(VALUE klass, ID id, int visi)
 {
-    const char *v = method_scope_name(scope);
+    const char *v = method_visibility_name(visi);
+
     rb_name_error(id, "undefined%s method `%"PRIsVALUE"' for %s `% "PRIsVALUE"'", v,
 		  QUOTE_ID(id),
 		  (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
@@ -242,9 +241,9 @@ rb_print_undef_str(VALUE klass, VALUE na https://github.com/ruby/ruby/blob/trunk/eval_error.c#L241
 }
 
 void
-rb_print_inaccessible(VALUE klass, ID id, int scope)
+rb_print_inaccessible(VALUE klass, ID id, rb_method_visibility_t visi)
 {
-    const char *v = method_scope_name(scope);
+    const char *v = method_visibility_name(visi);
     rb_name_error(id, "method `%"PRIsVALUE"' for %s `% "PRIsVALUE"' is %s",
 		  QUOTE_ID(id),
 		  (RB_TYPE_P(klass, T_MODULE)) ? "module" : "class",
Index: load.c
===================================================================
--- load.c	(revision 50742)
+++ load.c	(revision 50743)
@@ -935,7 +935,7 @@ load_failed(VALUE fname) https://github.com/ruby/ruby/blob/trunk/load.c#L935
 static VALUE
 load_ext(VALUE path)
 {
-    rb_frame_visibility_set(NOEX_PUBLIC);
+    rb_frame_visibility_set(METHOD_VISI_PUBLIC);
     return (VALUE)dln_load(RSTRING_PTR(path));
 }
 
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 50742)
+++ vm_eval.c	(revision 50743)
@@ -15,7 +15,7 @@ struct local_var_list { https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L15
     VALUE tbl;
 };
 
-static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status);
+static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, enum missing_reason call_status);
 static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const rb_cref_t *cref);
 static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv);
 static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr);
@@ -208,7 +208,7 @@ vm_call0_body(rb_thread_t* th, rb_call_i https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L208
 	    ci->defined_class = RCLASS_SUPER(ci->defined_class);
 
 	    if (!ci->defined_class || !(ci->me = rb_method_entry(ci->defined_class, ci->mid, &ci->defined_class))) {
-		int ex = type == VM_METHOD_TYPE_ZSUPER ? NOEX_SUPER : 0;
+		enum missing_reason ex = (type == VM_METHOD_TYPE_ZSUPER) ? MISSING_SUPER : 0;
 		ret = method_missing(ci->recv, ci->mid, ci->argc, argv, ex);
 		goto success;
 	    }
@@ -285,7 +285,7 @@ vm_call_super(rb_thread_t *th, int argc, https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L285
     id = rb_vm_frame_method_entry(cfp)->def->original_id;
     me = rb_method_entry(klass, id, &klass);
     if (!me) {
-	return method_missing(recv, id, argc, argv, NOEX_SUPER);
+	return method_missing(recv, id, argc, argv, MISSING_SUPER);
     }
 
     return vm_call0(th, recv, id, argc, argv, me, klass);
@@ -321,8 +321,7 @@ stack_check(void) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L321
 
 static inline rb_method_entry_t *
     rb_search_method_entry(VALUE recv, ID mid, VALUE *defined_class_ptr);
-static inline int rb_method_call_status(rb_thread_t *th, const rb_method_entry_t *me, call_type scope, VALUE self);
-#define NOEX_OK NOEX_NOSUPER
+static inline enum missing_reason rb_method_call_status(rb_thread_t *th, const rb_method_entry_t *me, call_type scope, VALUE self);
 
 /*!
  * \internal
@@ -347,9 +346,9 @@ rb_call0(VALUE recv, ID mid, int argc, c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L346
     rb_method_entry_t *me =
 	rb_search_method_entry(recv, mid, &defined_class);
     rb_thread_t *th = GET_THREAD();
-    int call_status = rb_method_call_status(th, me, scope, self);
+    enum missing_reason call_status = rb_method_call_status(th, me, scope, self);
 
-    if (call_status != NOEX_OK) {
+    if (call_status != MISSING_NONE) {
 	return method_missing(recv, mid, argc, argv, call_status);
     }
     stack_check();
@@ -391,7 +390,7 @@ check_funcall_respond_to(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L390
     VALUE defined_class;
     const rb_method_entry_t *me = rb_method_entry(klass, idRespond_to, &defined_class);
 
-    if (me && !(me->def->flag & NOEX_BASIC)) {
+    if (me && !me->def->flags.basic) {
 	const rb_block_t *passed_block = th->passed_block;
 	VALUE args[2], result;
 	int arity = rb_method_entry_arity(me);
@@ -415,7 +414,7 @@ check_funcall_respond_to(rb_thread_t *th https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L414
 static int
 check_funcall_callable(rb_thread_t *th, const rb_method_entry_t *me)
 {
-    return rb_method_call_status(th, me, CALL_FCALL, th->cfp->self) == NOEX_OK;
+    return rb_method_call_status(th, me, CALL_FCALL, th->cfp->self) == MISSING_NONE;
 }
 
 static VALUE
@@ -450,7 +449,7 @@ rb_check_funcall(VALUE recv, ID mid, int https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L449
 	return Qundef;
 
     me = rb_search_method_entry(recv, mid, &defined_class);
-    if (check_funcall_callable(th, me) != NOEX_OK) {
+    if (!check_funcall_callable(th, me)) {
 	return check_funcall_missing(th, klass, recv, mid, argc, argv);
     }
     stack_check();
@@ -470,7 +469,7 @@ rb_check_funcall_with_hook(VALUE recv, I https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L469
 	return Qundef;
 
     me = rb_search_method_entry(recv, mid, &defined_class);
-    if (check_funcall_callable(th, me) != NOEX_OK) {
+    if (!check_funcall_callable(th, me)) {
 	(*hook)(FALSE, recv, mid, argc, argv, arg);
 	return check_funcall_missing(th, klass, recv, mid, argc, argv);
     }
@@ -557,16 +556,16 @@ rb_search_method_entry(VALUE recv, ID mi https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L556
     return rb_method_entry(klass, mid, defined_class_ptr);
 }
 
-static inline int
+static inline enum missing_reason
 rb_method_call_status(rb_thread_t *th, const rb_method_entry_t *me, call_type scope, VALUE self)
 {
     VALUE klass;
     ID oid;
-    int noex;
+    rb_method_visibility_t visi;
 
     if (UNDEFINED_METHOD_ENTRY_P(me)) {
       undefined:
-	return scope == CALL_VCALL ? NOEX_VCALL : 0;
+	return scope == CALL_VCALL ? MISSING_VCALL : MISSING_NOENTRY;
     }
     if (me->def->type == VM_METHOD_TYPE_REFINED) {
 	me = rb_resolve_refined_method(Qnil, me, NULL);
@@ -574,17 +573,17 @@ rb_method_call_status(rb_thread_t *th, c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L573
     }
     klass = me->klass;
     oid = me->def->original_id;
-    noex = me->def->flag;
+    visi = me->def->flags.visi;
 
     if (oid != idMethodMissing) {
 	/* receiver specified form for private method */
-	if (UNLIKELY(noex)) {
-	    if (((noex & NOEX_MASK) & NOEX_PRIVATE) && scope == CALL_PUBLIC) {
-		return NOEX_PRIVATE;
+	if (UNLIKELY(visi != METHOD_VISI_PUBLIC)) {
+	    if (visi == METHOD_VISI_PRIVATE && scope == CALL_PUBLIC) {
+		return MISSING_PRIVATE;
 	    }
 
 	    /* self must be kind of a specified form for protected method */
-	    if (((noex & NOEX_MASK) & NOEX_PROTECTED) && scope == CALL_PUBLIC) {
+	    if (visi == METHOD_VISI_PROTECTED && scope == CALL_PUBLIC) {
 		VALUE defined_class = klass;
 
 		if (RB_TYPE_P(defined_class, T_ICLASS)) {
@@ -592,17 +591,17 @@ rb_method_call_status(rb_thread_t *th, c https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L591
 		}
 
 		if (self == Qundef || !rb_obj_is_kind_of(self, defined_class)) {
-		    return NOEX_PROTECTED;
+		    return MISSING_PROTECTED;
 		}
 	    }
 
-	    if (NOEX_SAFE(noex) > th->safe_level) {
-		rb_raise(rb_eSecurityError, "calling insecure method: %"PRIsVALUE,
-			 rb_id2str(me->called_id));
+	    if (me->def->flags.safe > th->safe_level) {
+		rb_raise(rb_eSecurityError, "calling insecure method: %"PRIsVALUE, rb_id2str(me->called_id));
 	    }
 	}
     }
-    return NOEX_OK;
+
+    return MISSING_NONE;
 }
 
 
@@ -625,7 +624,7 @@ rb_call(VALUE recv, ID mid, int argc, co https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L624
 }
 
 NORETURN(static void raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv,
-					  VALUE obj, int call_status));
+					  VALUE obj, enum missing_reason call_status));
 
 /*
  *  call-seq:
@@ -668,8 +667,6 @@ rb_method_missing(int argc, const VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L667
     UNREACHABLE;
 }
 
-#define NOEX_MISSING   0x80
-
 static VALUE
 make_no_method_exception(VALUE exc, const char *format, VALUE obj, int argc, const VALUE *argv)
 {
@@ -696,7 +693,7 @@ make_no_method_exception(VALUE exc, cons https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L693
 
 static void
 raise_method_missing(rb_thread_t *th, int argc, const VALUE *argv, VALUE obj,
-		     int last_call_status)
+		     enum missing_reason last_call_status)
 {
     VALUE exc = rb_eNoMethodError;
     const char *format = 0;
@@ -707,23 +704,23 @@ raise_method_missing(rb_thread_t *th, in https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L704
 
     stack_check();
 
-    if (last_call_status & NOEX_PRIVATE) {
+    if (last_call_status & MISSING_PRIVATE) {
 	format = "private method `%s' called for %s";
     }
-    else if (last_call_status & NOEX_PROTECTED) {
+    else if (last_call_status & MISSING_PROTECTED) {
 	format = "protected method `%s' called for %s";
     }
-    else if (last_call_status & NOEX_VCALL) {
+    else if (last_call_status & MISSING_VCALL) {
 	format = "undefined local variable or method `%s' for %s";
 	exc = rb_eNameError;
     }
-    else if (last_call_status & NOEX_SUPER) {
+    else if (last_call_status & MISSING_SUPER) {
 	format = "super: no superclass method `%s' for %s";
     }
 
     {
 	exc = make_no_method_exception(exc, format, obj, argc, argv);
-	if (!(last_call_status & NOEX_MISSING)) {
+	if (!(last_call_status & MISSING_MISSING)) {
 	    rb_vm_pop_cfunc_frame();
 	}
 	rb_exc_raise(exc);
@@ -731,7 +728,7 @@ raise_method_missing(rb_thread_t *th, in https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L72 (... truncated)

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

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