diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-09-20 17:01:19 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-11-08 15:15:48 +0100 |
commit | ac4e0f0852ce780e143013ceff45067a172e8a83 (patch) | |
tree | f39eebeb379b6f75e95a333ccec37c4af264d8ee /Zend/zend_inheritance.c | |
parent | a555cc0b3d4f745e6d0bb8c595de400a0c728827 (diff) | |
download | php-git-ac4e0f0852ce780e143013ceff45067a172e8a83.tar.gz |
Make zend_type a 2-field struct
We now store the pointer payload and the type mask separately. This
is in preparation for union types, where we will be using both at
the same time.
To avoid increasing the size of arginfo structures, the
pass_by_reference and is_variadic fields are now stored as part of
the type_mask (8-bit are reserved for custom use).
Different types of pointer payloads are distinguished based on bits
in the type_mask.
Diffstat (limited to 'Zend/zend_inheritance.c')
-rw-r--r-- | Zend/zend_inheritance.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index a1ecb9e2b7..af81c327e1 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -350,7 +350,7 @@ static inheritance_status zend_perform_covariant_type_check( } return unlinked_instanceof(fe_ce, proto_ce) ? INHERITANCE_SUCCESS : INHERITANCE_ERROR; - } else if (ZEND_TYPE_MASK(proto_type) & MAY_BE_ITERABLE) { + } else if (ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_ITERABLE) { if (ZEND_TYPE_IS_CLASS(fe_type)) { zend_string *fe_class_name = resolve_class_name(fe->common.scope, ZEND_TYPE_NAME(fe_type)); @@ -363,9 +363,9 @@ static inheritance_status zend_perform_covariant_type_check( ? INHERITANCE_SUCCESS : INHERITANCE_ERROR; } - return ZEND_TYPE_MASK(fe_type) & (MAY_BE_ARRAY|MAY_BE_ITERABLE) + return ZEND_TYPE_FULL_MASK(fe_type) & (MAY_BE_ARRAY|MAY_BE_ITERABLE) ? INHERITANCE_SUCCESS : INHERITANCE_ERROR; - } else if (ZEND_TYPE_MASK(proto_type) & MAY_BE_OBJECT) { + } else if (ZEND_TYPE_FULL_MASK(proto_type) & MAY_BE_OBJECT) { if (ZEND_TYPE_IS_CLASS(fe_type)) { /* Currently, any class name would be allowed here. We still perform a class lookup * for forward-compatibility reasons, as we may have named types in the future that @@ -380,10 +380,10 @@ static inheritance_status zend_perform_covariant_type_check( return INHERITANCE_SUCCESS; } - return ZEND_TYPE_MASK(fe_type) & MAY_BE_OBJECT ? INHERITANCE_SUCCESS : INHERITANCE_ERROR; + return ZEND_TYPE_FULL_MASK(fe_type) & MAY_BE_OBJECT + ? INHERITANCE_SUCCESS : INHERITANCE_ERROR; } else { - return ZEND_TYPE_MASK(ZEND_TYPE_WITHOUT_NULL(fe_type)) - == ZEND_TYPE_MASK(ZEND_TYPE_WITHOUT_NULL(proto_type)) + return ZEND_TYPE_PURE_MASK_WITHOUT_NULL(fe_type) == ZEND_TYPE_PURE_MASK_WITHOUT_NULL(proto_type) ? INHERITANCE_SUCCESS : INHERITANCE_ERROR; } } @@ -490,7 +490,7 @@ static inheritance_status zend_do_perform_implementation_check( } /* by-ref constraints on arguments are invariant */ - if (fe_arg_info->pass_by_reference != proto_arg_info->pass_by_reference) { + if (ZEND_ARG_SEND_MODE(fe_arg_info) != ZEND_ARG_SEND_MODE(proto_arg_info)) { return INHERITANCE_ERROR; } } @@ -561,11 +561,11 @@ static ZEND_COLD zend_string *zend_get_function_declaration(const zend_function for (i = 0; i < num_args;) { zend_append_type_hint(&str, fptr, arg_info, 0); - if (arg_info->pass_by_reference) { + if (ZEND_ARG_SEND_MODE(arg_info)) { smart_str_appendc(&str, '&'); } - if (arg_info->is_variadic) { + if (ZEND_ARG_IS_VARIADIC(arg_info)) { smart_str_appends(&str, "..."); } @@ -582,7 +582,7 @@ static ZEND_COLD zend_string *zend_get_function_declaration(const zend_function smart_str_append_unsigned(&str, i); } - if (i >= required && !arg_info->is_variadic) { + if (i >= required && !ZEND_ARG_IS_VARIADIC(arg_info)) { smart_str_appends(&str, " = "); if (fptr->type == ZEND_USER_FUNCTION) { zend_op *precv = NULL; @@ -847,7 +847,8 @@ inheritance_status property_types_compatible( const zend_property_info *parent_info, const zend_property_info *child_info) { zend_string *parent_name, *child_name; zend_class_entry *parent_type_ce, *child_type_ce; - if (parent_info->type == child_info->type) { + if (ZEND_TYPE_PURE_MASK(parent_info->type) == ZEND_TYPE_PURE_MASK(child_info->type) + && ZEND_TYPE_NAME(parent_info->type) == ZEND_TYPE_NAME(child_info->type)) { return INHERITANCE_SUCCESS; } |