1 #ifndef PHP_AST_H 2 #define PHP_AST_H 3 4 #include "php.h" 5 #include "ast_str_defs.h" 6 7 extern zend_module_entry ast_module_entry; 8 #define phpext_ast_ptr &ast_module_entry 9 10 #define PHP_AST_VERSION "1.1.3dev" 11 12 #ifdef PHP_WIN32 13 # define PHP_AST_API __declspec(dllexport) 14 #elif defined(__GNUC__) && __GNUC__ >= 4 15 # define PHP_AST_API __attribute__ ((visibility("default"))) 16 #else 17 # define PHP_AST_API 18 #endif 19 20 #ifdef ZTS 21 #include "TSRM.h" 22 #endif 23 ZEND_BEGIN_MODULE_GLOBALS(ast)24ZEND_BEGIN_MODULE_GLOBALS(ast) 25 zval metadata; 26 ZEND_END_MODULE_GLOBALS(ast) 27 28 ZEND_EXTERN_MODULE_GLOBALS(ast) 29 30 #define AST_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(ast, v) 31 32 typedef struct _ast_str_globals { 33 #define X(str, value) zend_string *str_ ## str; 34 AST_STR_DEFS 35 #undef X 36 } ast_str_globals; 37 38 extern ast_str_globals str_globals; 39 40 #define AST_STR(str) str_globals.str 41 42 /* Custom ast kind for names */ 43 #define AST_NAME 2048 44 #define AST_CLOSURE_VAR 2049 45 #define AST_NULLABLE_TYPE 2050 46 47 // 544 is already taken by ZEND_AST_GROUP_USE 48 #if PHP_VERSION_ID < 70400 49 // NOTE: The first hex digit is the number of child nodes a given kind has 50 # define ZEND_AST_CLASS_NAME 0x1ff 51 # define ZEND_AST_PROP_GROUP 0x2ff 52 // ZEND_AST_ARROW_FUNC technically should have been in the ZEND_AST_SPECIAL_SHIFT group, but keeping this value for compatibility with older releases. (e.g. serialized ast Nodes) 53 # define ZEND_AST_ARROW_FUNC 0x5ff 54 #endif 55 56 #if PHP_VERSION_ID < 80000 57 /* NOTE: For list nodes, the first set bit is 0x80 */ 58 # define ZEND_AST_TYPE_UNION ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 2) 59 # define ZEND_AST_ATTRIBUTE_LIST ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 3) 60 # define ZEND_AST_MATCH_ARM_LIST ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 4) 61 # define ZEND_AST_ATTRIBUTE_GROUP ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 5) 62 /* 2 child nodes */ 63 # define ZEND_AST_CLASS_CONST_GROUP 0x2fe 64 # define ZEND_AST_ATTRIBUTE 0x2fd 65 # define ZEND_AST_MATCH 0x2fc 66 # define ZEND_AST_MATCH_ARM 0x2fb 67 # define ZEND_AST_NAMED_ARG 0x2fa 68 # define ZEND_AST_NULLSAFE_PROP 0x2f9 69 /* 3 child nodes */ 70 # define ZEND_AST_NULLSAFE_METHOD_CALL 0x3ff 71 // NOTE: The first hex digit is the number of child nodes a given kind has 72 #endif 73 74 #if PHP_VERSION_ID < 80100 75 # define ZEND_ACC_ENUM (1 << 22) 76 # define ZEND_ACC_READONLY (1 << 7) 77 78 /* 0 child nodes */ 79 # define ZEND_AST_CALLABLE_CONVERT 3 80 /* 3 child nodes - name, expr, attributes */ 81 # define ZEND_AST_ENUM_CASE 0x3fe 82 # define ZEND_AST_TYPE_INTERSECTION ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 6) 83 #endif 84 85 #if PHP_VERSION_ID < 80200 86 # define ZEND_ACC_READONLY_CLASS (1 << 23) 87 #endif 88 89 #if PHP_VERSION_ID < 80400 90 # define ZEND_AST_PROPERTY_HOOK ((1 << (ZEND_AST_SPECIAL_SHIFT + 1)) - 1) 91 // NOTE: The first hex digit is the number of child nodes a given kind has 92 # define ZEND_AST_PROPERTY_HOOK_SHORT_BODY 0x1fe 93 # define ZEND_AST_PARENT_PROPERTY_HOOK_CALL 0x2f8 94 #endif 95 96 /* Pretend it still exists */ 97 # define ZEND_AST_LIST ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 1) 98 99 extern const size_t ast_kinds_count; 100 extern const zend_ast_kind ast_kinds[]; 101 102 const char *ast_kind_to_name(zend_ast_kind kind); 103 zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child); 104 void ast_register_kind_constants(INIT_FUNC_ARGS); 105 106 #endif /* PHP_AST_H */ 107 108 109 /* 110 * Local variables: 111 * tab-width: 4 112 * c-basic-offset: 4 113 * End: 114 * vim600: noet sw=4 ts=4 fdm=marker 115 * vim<600: noet sw=4 ts=4 116 */ 117