diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-09-19 12:11:29 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-09-23 15:31:35 +0200 |
commit | 9e8ba7891e74a80265e09ff5b810ec947680c1ce (patch) | |
tree | 6550898580da2445d9d54370d2adef6e68a881b3 /Zend/zend_type_info.h | |
parent | 9ec2480bd6d8cadd8ca2ecac07f00fd3d411bc7a (diff) | |
download | php-git-9e8ba7891e74a80265e09ff5b810ec947680c1ce.tar.gz |
Change representation of zend_type from type code to MAY_BE_* mask
This switches zend_type from storing a single IS_* type code to
storing a MAY_BE_* type mask. Right now most code still assumes
that there is only a single type in the mask (or two together
with MAY_BE_NULL). But this will make it a lot simpler to introduce
union types.
An additional advantage (and why I'm doing this separately), is
that a number of special cases no longer need to be handled
separately: We can do a single mask & (1 << type) check to handle
all simple types, booleans (true|false) and null.
Diffstat (limited to 'Zend/zend_type_info.h')
-rw-r--r-- | Zend/zend_type_info.h | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/Zend/zend_type_info.h b/Zend/zend_type_info.h index 72550b6fc3..c991fd5db5 100644 --- a/Zend/zend_type_info.h +++ b/Zend/zend_type_info.h @@ -34,7 +34,12 @@ #define MAY_BE_ANY (MAY_BE_NULL|MAY_BE_FALSE|MAY_BE_TRUE|MAY_BE_LONG|MAY_BE_DOUBLE|MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE) #define MAY_BE_REF (1 << IS_REFERENCE) /* may be reference */ -#define MAY_BE_ARRAY_SHIFT (IS_REFERENCE) +/* These are used in zend_type, but not for type inference. */ +#define MAY_BE_CALLABLE (1 << IS_CALLABLE) +#define MAY_BE_ITERABLE (1 << IS_ITERABLE) +#define MAY_BE_VOID (1 << IS_VOID) + +#define MAY_BE_ARRAY_SHIFT (IS_VOID) #define MAY_BE_ARRAY_OF_NULL (MAY_BE_NULL << MAY_BE_ARRAY_SHIFT) #define MAY_BE_ARRAY_OF_FALSE (MAY_BE_FALSE << MAY_BE_ARRAY_SHIFT) @@ -48,11 +53,11 @@ #define MAY_BE_ARRAY_OF_ANY (MAY_BE_ANY << MAY_BE_ARRAY_SHIFT) #define MAY_BE_ARRAY_OF_REF (MAY_BE_REF << MAY_BE_ARRAY_SHIFT) -#define MAY_BE_ARRAY_KEY_LONG (1<<21) -#define MAY_BE_ARRAY_KEY_STRING (1<<22) +#define MAY_BE_ARRAY_KEY_LONG (1<<25) +#define MAY_BE_ARRAY_KEY_STRING (1<<26) #define MAY_BE_ARRAY_KEY_ANY (MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_KEY_STRING) -#define MAY_BE_ERROR (1<<23) -#define MAY_BE_CLASS (1<<24) +#define MAY_BE_ERROR (1<<27) +#define MAY_BE_CLASS (1<<28) #endif /* ZEND_TYPE_INFO_H */ |