From 53e527ad433db13c31e52a9bf5f598aa92c9ab98 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 6 Feb 2020 10:51:45 +0100 Subject: [PATCH] Remove ZEND_ACC_IMPLEMENT_INTERFACES flag This is equivalent to checking ce->num_interfaces. The only subtle moment is during inheritance, where num_interface may change when parent interfaces are inherited. The check in zend_do_link_class thus uses "interfaces", not "ce->num_interfaces". --- Zend/zend_compile.c | 5 ++--- Zend/zend_compile.h | 5 +---- Zend/zend_inheritance.c | 4 ++-- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ecf7ce1686..b915b7f8d6 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -6523,7 +6523,6 @@ void zend_compile_implements(zend_ast *ast) /* {{{ */ interface_names[i].lc_name = zend_string_tolower(interface_names[i].name); } - ce->ce_flags |= ZEND_ACC_IMPLEMENT_INTERFACES; ce->num_interfaces = list->children; ce->interface_names = interface_names; } @@ -6664,7 +6663,7 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ if (toplevel /* We currently don't early-bind classes that implement interfaces or use traits */ - && !(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES) && !ce->num_traits + && !ce->num_interfaces && !ce->num_traits && !(CG(compiler_options) & ZEND_COMPILE_PRELOAD)) { if (extends_ast) { zend_class_entry *parent_ce = zend_lookup_class_ex( @@ -6725,7 +6724,7 @@ zend_op *zend_compile_class_decl(zend_ast *ast, zend_bool toplevel) /* {{{ */ if (extends_ast && toplevel && (CG(compiler_options) & ZEND_COMPILE_DELAYED_BINDING) /* We currently don't early-bind classes that implement interfaces or use traits */ - && !(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES) && !ce->num_traits + && !ce->num_interfaces && !ce->num_traits ) { CG(active_op_array)->fn_flags |= ZEND_ACC_EARLY_BINDING; opline->opcode = ZEND_DECLARE_CLASS_DELAYED; diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index 97488a5e93..6c438b6902 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -229,7 +229,7 @@ typedef struct _zend_oparray_context { /* op_array or class is preloaded | | | */ #define ZEND_ACC_PRELOADED (1 << 10) /* X | X | | */ /* | | | */ -/* Class Flags (unused: 13, 15, 24...) | | | */ +/* Class Flags (unused: 13, 14, 15, 24...) | | | */ /* =========== | | | */ /* | | | */ /* Special class types | | | */ @@ -251,9 +251,6 @@ typedef struct _zend_oparray_context { /* Class constants updated | | | */ #define ZEND_ACC_CONSTANTS_UPDATED (1 << 12) /* X | | | */ /* | | | */ -/* Class implements interface(s) | | | */ -#define ZEND_ACC_IMPLEMENT_INTERFACES (1 << 14) /* X | | | */ -/* | | | */ /* User class has methods with static variables | | | */ #define ZEND_HAS_STATIC_IN_METHODS (1 << 16) /* X | | | */ /* | | | */ diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index a381fced2d..5abe1c55d4 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -1161,7 +1161,7 @@ ZEND_API void zend_do_inheritance_ex(zend_class_entry *ce, zend_class_entry *par /* Inherit interfaces */ if (parent_ce->num_interfaces) { - if (!(ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES)) { + if (!ce->num_interfaces) { zend_do_inherit_interfaces(ce, parent_ce); } else { uint32_t i; @@ -2463,7 +2463,7 @@ ZEND_API int zend_do_link_class(zend_class_entry *ce, zend_string *lc_parent_nam if (ce->num_traits) { zend_do_bind_traits(ce); } - if (ce->ce_flags & ZEND_ACC_IMPLEMENT_INTERFACES) { + if (interfaces) { zend_do_implement_interfaces(ce, interfaces); } if ((ce->ce_flags & (ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_INTERFACE|ZEND_ACC_TRAIT|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) == ZEND_ACC_IMPLICIT_ABSTRACT_CLASS) { -- 2.50.1