From 2832987bb29bfdfa6c0a00cff86c0942b59ba824 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksey=20Kliger=20=28=CE=BBgeek=29?= Date: Thu, 17 Jun 2021 09:05:14 -0400 Subject: [PATCH] [mono] Add accessors m_method_is_final and m_method_is_abstract (#54271) * [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 | 12 ++++++++++++ src/mono/mono/metadata/icall.c | 9 ++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/mono/mono/metadata/class-inlines.h b/src/mono/mono/metadata/class-inlines.h index 7c8a61a..a9aa3c9 100644 --- a/src/mono/mono/metadata/class-inlines.h +++ b/src/mono/mono/metadata/class-inlines.h @@ -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; diff --git a/src/mono/mono/metadata/icall.c b/src/mono/mono/metadata/icall.c index b340e0b..014b69b 100644 --- a/src/mono/mono/metadata/icall.c +++ b/src/mono/mono/metadata/icall.c @@ -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 */ -- 2.7.4