[mono] Add accessors m_method_is_final and m_method_is_abstract (#54271)
authorAleksey Kliger (λgeek) <alklig@microsoft.com>
Thu, 17 Jun 2021 13:05:14 +0000 (09:05 -0400)
committerGitHub <noreply@github.com>
Thu, 17 Jun 2021 13:05:14 +0000 (09:05 -0400)
* [metadata] Cleanup redundant logic

Follow-up to 4e03f3665ad197b005b361b3b7cdf7fcac298ef2

* Add m_method_is_abstract and m_method_is_final accessors

src/mono/mono/metadata/class-inlines.h
src/mono/mono/metadata/icall.c

index 7c8a61a..a9aa3c9 100644 (file)
@@ -218,6 +218,18 @@ m_method_is_virtual (MonoMethod *method)
 }
 
 static inline gboolean
+m_method_is_abstract (MonoMethod *method)
+{
+        return (method->flags & METHOD_ATTRIBUTE_ABSTRACT) != 0;
+}
+
+static inline gboolean
+m_method_is_final (MonoMethod *method)
+{
+        return (method->flags & METHOD_ATTRIBUTE_FINAL) != 0;
+}
+
+static inline gboolean
 m_method_is_icall (MonoMethod *method)
 {
        return (method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) != 0;
index b340e0b..014b69b 100644 (file)
@@ -2532,7 +2532,7 @@ method_is_reabstracted (MonoMethod *method)
        /* only on interfaces */
        /* method is marked "final abstract" */
        /* FIXME: we need some other way to detect reabstracted methods.  "final" is an incidental detail of the spec. */
-       return method->flags & METHOD_ATTRIBUTE_FINAL && method->flags & METHOD_ATTRIBUTE_ABSTRACT;
+       return m_method_is_final (method) && m_method_is_abstract (method);
 }
 
 static gboolean
@@ -2540,7 +2540,7 @@ method_is_dim (MonoMethod *method)
 {
        /* only valid on interface methods*/
        /* method is marked "virtual" but not "virtual abstract" */
-       return method->flags & method->flags & METHOD_ATTRIBUTE_VIRTUAL && !(method->flags & METHOD_ATTRIBUTE_ABSTRACT);
+       return m_method_is_virtual (method) && !m_method_is_abstract (method);
 }
 
 static gboolean
@@ -2582,9 +2582,8 @@ set_interface_map_data_method_object (MonoMethod *method, MonoClass *iclass, int
         * the method), then say the target method is null.
         */
        if (method_is_reabstracted (method) &&
-           ((foundMethod->flags & METHOD_ATTRIBUTE_ABSTRACT) ||
-            (mono_class_is_interface (foundMethod->klass) && method_is_dim (foundMethod))
-                   ))
+           (m_method_is_abstract (foundMethod) ||
+            (mono_class_is_interface (foundMethod->klass) && method_is_dim (foundMethod))))
                MONO_HANDLE_ARRAY_SETREF (targets, i, NULL_HANDLE);
        else if (mono_class_is_interface (foundMethod->klass) && method_is_reabstracted (foundMethod) && !m_class_is_abstract (klass)) {
                /* if the method we found is a reabstracted DIM method, but the class isn't abstract, return NULL */