xref: /PHP-8.2/Zend/zend_type_info.h (revision 1c95e227)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine                                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) Zend Technologies Ltd. (http://www.zend.com)           |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 2.00 of the Zend license,     |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.zend.com/license/2_00.txt.                                |
11    | If you did not receive a copy of the Zend license and are unable to  |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@zend.com so we can mail you a copy immediately.              |
14    +----------------------------------------------------------------------+
15    | Authors: Dmitry Stogov <dmitry@php.net>                              |
16    +----------------------------------------------------------------------+
17 */
18 
19 #ifndef ZEND_TYPE_INFO_H
20 #define ZEND_TYPE_INFO_H
21 
22 #include "zend_types.h"
23 
24 #define MAY_BE_UNDEF                (1 << IS_UNDEF)
25 #define MAY_BE_NULL		            (1 << IS_NULL)
26 #define MAY_BE_FALSE	            (1 << IS_FALSE)
27 #define MAY_BE_TRUE		            (1 << IS_TRUE)
28 #define MAY_BE_BOOL                 (MAY_BE_FALSE|MAY_BE_TRUE)
29 #define MAY_BE_LONG		            (1 << IS_LONG)
30 #define MAY_BE_DOUBLE	            (1 << IS_DOUBLE)
31 #define MAY_BE_STRING	            (1 << IS_STRING)
32 #define MAY_BE_ARRAY	            (1 << IS_ARRAY)
33 #define MAY_BE_OBJECT	            (1 << IS_OBJECT)
34 #define MAY_BE_RESOURCE	            (1 << IS_RESOURCE)
35 #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)
36 #define MAY_BE_REF                  (1 << IS_REFERENCE) /* may be reference */
37 
38 /* These are used in zend_type, but not for type inference.
39  * They are allowed to overlap with types used during inference. */
40 #define MAY_BE_CALLABLE             (1 << IS_CALLABLE)
41 #define MAY_BE_VOID                 (1 << IS_VOID)
42 #define MAY_BE_NEVER                (1 << IS_NEVER)
43 #define MAY_BE_STATIC               (1 << IS_STATIC)
44 
45 #define MAY_BE_ARRAY_SHIFT          (IS_REFERENCE)
46 
47 #define MAY_BE_ARRAY_OF_NULL		(MAY_BE_NULL     << MAY_BE_ARRAY_SHIFT)
48 #define MAY_BE_ARRAY_OF_FALSE		(MAY_BE_FALSE    << MAY_BE_ARRAY_SHIFT)
49 #define MAY_BE_ARRAY_OF_TRUE		(MAY_BE_TRUE     << MAY_BE_ARRAY_SHIFT)
50 #define MAY_BE_ARRAY_OF_LONG		(MAY_BE_LONG     << MAY_BE_ARRAY_SHIFT)
51 #define MAY_BE_ARRAY_OF_DOUBLE		(MAY_BE_DOUBLE   << MAY_BE_ARRAY_SHIFT)
52 #define MAY_BE_ARRAY_OF_STRING		(MAY_BE_STRING   << MAY_BE_ARRAY_SHIFT)
53 #define MAY_BE_ARRAY_OF_ARRAY		(MAY_BE_ARRAY    << MAY_BE_ARRAY_SHIFT)
54 #define MAY_BE_ARRAY_OF_OBJECT		(MAY_BE_OBJECT   << MAY_BE_ARRAY_SHIFT)
55 #define MAY_BE_ARRAY_OF_RESOURCE	(MAY_BE_RESOURCE << MAY_BE_ARRAY_SHIFT)
56 #define MAY_BE_ARRAY_OF_ANY			(MAY_BE_ANY      << MAY_BE_ARRAY_SHIFT)
57 #define MAY_BE_ARRAY_OF_REF			(MAY_BE_REF      << MAY_BE_ARRAY_SHIFT)
58 
59 #define MAY_BE_ARRAY_PACKED         (1<<21)
60 #define MAY_BE_ARRAY_NUMERIC_HASH   (1<<22) /* hash with numeric keys */
61 #define MAY_BE_ARRAY_STRING_HASH    (1<<23) /* hash with string keys */
62 #define MAY_BE_ARRAY_EMPTY          (1<<29)
63 
64 #define MAY_BE_ARRAY_KEY_LONG       (MAY_BE_ARRAY_PACKED | MAY_BE_ARRAY_NUMERIC_HASH)
65 #define MAY_BE_ARRAY_KEY_STRING     MAY_BE_ARRAY_STRING_HASH
66 #define MAY_BE_ARRAY_KEY_ANY        (MAY_BE_ARRAY_KEY_LONG | MAY_BE_ARRAY_KEY_STRING | MAY_BE_ARRAY_EMPTY)
67 
68 #define MAY_BE_PACKED(t)            ((t) & MAY_BE_ARRAY_PACKED)
69 #define MAY_BE_HASH(t)              ((t) & (MAY_BE_ARRAY_NUMERIC_HASH | MAY_BE_ARRAY_KEY_STRING))
70 #define MAY_BE_PACKED_ONLY(t)       (((t) & MAY_BE_ARRAY_KEY_ANY) == MAY_BE_ARRAY_PACKED)
71 #define MAY_BE_HASH_ONLY(t)         (MAY_BE_HASH(t) && !((t) & (MAY_BE_ARRAY_PACKED|MAY_BE_ARRAY_EMPTY)))
72 #define MAY_BE_EMPTY_ONLY(t)        (((t) & MAY_BE_ARRAY_KEY_ANY) == MAY_BE_ARRAY_EMPTY)
73 
74 #define MAY_BE_CLASS                (1<<24)
75 #define MAY_BE_INDIRECT             (1<<25)
76 
77 #define MAY_BE_RC1                  (1<<30) /* may be non-reference with refcount == 1 */
78 #define MAY_BE_RCN                  (1u<<31) /* may be non-reference with refcount > 1  */
79 
80 
81 #define MAY_BE_ANY_ARRAY \
82 	(MAY_BE_ARRAY|MAY_BE_ARRAY_KEY_ANY|MAY_BE_ARRAY_OF_ANY|MAY_BE_ARRAY_OF_REF)
83 
84 #endif /* ZEND_TYPE_INFO_H */
85