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

ruby-changes:48277

From: nobu <ko1@a...>
Date: Tue, 24 Oct 2017 16:17:41 +0900 (JST)
Subject: [ruby-changes:48277] nobu:r60392 (trunk): vm_eval.c: uncallable_object

nobu	2017-10-24 16:17:36 +0900 (Tue, 24 Oct 2017)

  New Revision: 60392

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

  Log:
    vm_eval.c: uncallable_object
    
    * vm_eval.c (uncallable_object): extract error case as a no-return
      function.  split successive ?-marks not to get confused with a
      trigraph.

  Modified files:
    trunk/vm_eval.c
Index: vm_eval.c
===================================================================
--- vm_eval.c	(revision 60391)
+++ vm_eval.c	(revision 60392)
@@ -475,45 +475,51 @@ rb_type_str(enum ruby_value_type type) https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L475
 #undef type_case
 }
 
+NORETURN(static void uncallable_object(VALUE recv, ID mid));
+static void
+uncallable_object(VALUE recv, ID mid)
+{
+    VALUE flags;
+    int type;
+    const char *typestr;
+    VALUE mname = rb_id2str(mid);
+
+    if (SPECIAL_CONST_P(recv)) {
+	rb_raise(rb_eNotImpError,
+		 "method `%"PRIsVALUE"' called on unexpected immediate object (%p)",
+		 mname, (void *)recv);
+    }
+    else if ((flags = RBASIC(recv)->flags) == 0) {
+	rb_raise(rb_eNotImpError,
+		 "method `%"PRIsVALUE"' called on terminated object (%p)",
+		 mname, (void *)recv);
+    }
+    else if (!(typestr = rb_type_str(type = BUILTIN_TYPE(recv)))) {
+	rb_raise(rb_eNotImpError,
+		 "method `%"PRIsVALUE"' called on broken T_?""?""?(0x%02x) object"
+		 " (%p flags=0x%"PRIxVALUE")",
+		 mname, type, (void *)recv, flags);
+    }
+    else if (T_OBJECT <= type && type < T_NIL) {
+	rb_raise(rb_eNotImpError,
+		 "method `%"PRIsVALUE"' called on hidden %s object"
+		 " (%p flags=0x%"PRIxVALUE")",
+		 mname, typestr, (void *)recv, flags);
+    }
+    else {
+	rb_raise(rb_eNotImpError,
+		 "method `%"PRIsVALUE"' called on unexpected %s object"
+		 " (%p flags=0x%"PRIxVALUE")",
+		 mname, typestr, (void *)recv, flags);
+    }
+}
+
 static inline const rb_callable_method_entry_t *
 rb_search_method_entry(VALUE recv, ID mid)
 {
     VALUE klass = CLASS_OF(recv);
 
-    if (!klass) {
-        VALUE flags;
-        if (SPECIAL_CONST_P(recv)) {
-            rb_raise(rb_eNotImpError,
-                     "method `%"PRIsVALUE"' called on unexpected immediate object (%p)",
-                     rb_id2str(mid), (void *)recv);
-        }
-        flags = RBASIC(recv)->flags;
-        if (flags == 0) {
-            rb_raise(rb_eNotImpError,
-                     "method `%"PRIsVALUE"' called on terminated object"
-                     " (%p flags=0x%"PRIxVALUE")",
-                     rb_id2str(mid), (void *)recv, flags);
-        }
-        else {
-            int type = BUILTIN_TYPE(recv);
-            const char *typestr = rb_type_str(type);
-            if (typestr && T_OBJECT <= type && type < T_NIL)
-                rb_raise(rb_eNotImpError,
-                         "method `%"PRIsVALUE"' called on hidden %s object"
-                         " (%p flags=0x%"PRIxVALUE")",
-                         rb_id2str(mid), typestr, (void *)recv, flags);
-            if (typestr)
-                rb_raise(rb_eNotImpError,
-                         "method `%"PRIsVALUE"' called on unexpected %s object"
-                         " (%p flags=0x%"PRIxVALUE")",
-                         rb_id2str(mid), typestr, (void *)recv, flags);
-            else
-                rb_raise(rb_eNotImpError,
-                         "method `%"PRIsVALUE"' called on broken T_???" "(0x%02x) object"
-                         " (%p flags=0x%"PRIxVALUE")",
-                         rb_id2str(mid), type, (void *)recv, flags);
-        }
-    }
+    if (!klass) uncallable_object(recv, mid);
     return rb_callable_method_entry(klass, mid);
 }
 

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

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