summaryrefslogtreecommitdiff
path: root/Zend/zend_types.h
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-01-07 14:53:25 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-01-07 14:55:52 +0100
commit1e4920c1191c8e324604bdfe3b3cd0397faf44a7 (patch)
tree5ba6863e05a98076f7c3300f672da9bc643acea5 /Zend/zend_types.h
parentda48d25ea24ca05cfca872648654d17c3abafce3 (diff)
downloadphp-git-1e4920c1191c8e324604bdfe3b3cd0397faf44a7.tar.gz
Renumber zval types, clarify allowed overlap
Make it clear that types used for type declarations can overlap with the rest, and can also overlap in MAY_BE space. This makes things more robust against the addition of new primitive types.
Diffstat (limited to 'Zend/zend_types.h')
-rw-r--r--Zend/zend_types.h18
1 files changed, 10 insertions, 8 deletions
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index e32538591b..20fddd74c9 100644
--- a/Zend/zend_types.h
+++ b/Zend/zend_types.h
@@ -137,7 +137,6 @@ typedef struct {
#define _ZEND_TYPE_EXTRA_FLAGS_SHIFT 24
#define _ZEND_TYPE_MASK ((1u << 24) - 1)
-#define _ZEND_TYPE_MAY_BE_MASK ((1u << (IS_VOID+1)) - 1)
/* Only one of these bits may be set. */
#define _ZEND_TYPE_NAME_BIT (1u << 23)
#define _ZEND_TYPE_CE_BIT (1u << 22)
@@ -145,6 +144,8 @@ typedef struct {
#define _ZEND_TYPE_KIND_MASK (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_CE_BIT|_ZEND_TYPE_NAME_BIT)
/* Whether the type list is arena allocated */
#define _ZEND_TYPE_ARENA_BIT (1u << 20)
+/* Type mask excluding the flags above. */
+#define _ZEND_TYPE_MAY_BE_MASK ((1u << 20) - 1)
/* Must have same value as MAY_BE_NULL */
#define _ZEND_TYPE_NULLABLE_BIT 0x2
@@ -533,20 +534,21 @@ struct _zend_ast_ref {
#define IS_REFERENCE 10
#define IS_CONSTANT_AST 11 /* Constant expressions */
-/* Fake types used only for type hinting. IS_VOID should be the last. */
+/* Fake types used only for type hinting.
+ * These are allowed to overlap with the types below. */
#define IS_CALLABLE 12
#define IS_ITERABLE 13
#define IS_VOID 14
/* internal types */
-#define IS_INDIRECT 15
-#define IS_PTR 16
-#define IS_ALIAS_PTR 17
-#define _IS_ERROR 17
+#define IS_INDIRECT 12
+#define IS_PTR 13
+#define IS_ALIAS_PTR 14
+#define _IS_ERROR 15
/* used for casts */
-#define _IS_BOOL 18
-#define _IS_NUMBER 19
+#define _IS_BOOL 16
+#define _IS_NUMBER 17
static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
return pz->u1.v.type;