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.2dev" 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) 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 # define ZEND_AST_ARROW_FUNC 0x5ff 53 #endif 54 55 #if PHP_VERSION_ID < 80000 56 /* NOTE: For list nodes, the first set bit is 0x80 */ 57 # define ZEND_AST_TYPE_UNION ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 2) 58 # define ZEND_AST_ATTRIBUTE_LIST ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 3) 59 # define ZEND_AST_MATCH_ARM_LIST ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 4) 60 # define ZEND_AST_ATTRIBUTE_GROUP ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 5) 61 /* 2 child nodes */ 62 # define ZEND_AST_CLASS_CONST_GROUP 0x2fe 63 # define ZEND_AST_ATTRIBUTE 0x2fd 64 # define ZEND_AST_MATCH 0x2fc 65 # define ZEND_AST_MATCH_ARM 0x2fb 66 # define ZEND_AST_NAMED_ARG 0x2fa 67 # define ZEND_AST_NULLSAFE_PROP 0x2f9 68 /* 3 child nodes */ 69 # define ZEND_AST_NULLSAFE_METHOD_CALL 0x3ff 70 // NOTE: The first hex digit is the number of child nodes a given kind has 71 #endif 72 73 #if PHP_VERSION_ID < 80100 74 # define ZEND_ACC_ENUM (1 << 22) 75 # define ZEND_ACC_READONLY (1 << 7) 76 77 /* 0 child nodes */ 78 # define ZEND_AST_CALLABLE_CONVERT 3 79 /* 3 child nodes - name, expr, attributes */ 80 # define ZEND_AST_ENUM_CASE 0x3fe 81 # define ZEND_AST_TYPE_INTERSECTION ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 6) 82 #endif 83 84 #if PHP_VERSION_ID < 80200 85 # define ZEND_ACC_READONLY_CLASS (1 << 23) 86 #endif 87 88 /* Pretend it still exists */ 89 # define ZEND_AST_LIST ((1 << (ZEND_AST_IS_LIST_SHIFT + 1)) - 1) 90 91 extern const size_t ast_kinds_count; 92 extern const zend_ast_kind ast_kinds[]; 93 94 const char *ast_kind_to_name(zend_ast_kind kind); 95 zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child); 96 void ast_register_kind_constants(INIT_FUNC_ARGS); 97 98 #endif /* PHP_AST_H */ 99 100 101 /* 102 * Local variables: 103 * tab-width: 4 104 * c-basic-offset: 4 105 * End: 106 * vim600: noet sw=4 ts=4 fdm=marker 107 * vim<600: noet sw=4 ts=4 108 */ 109