Zend/zend_ast: Add const qualifier

This commit is contained in:
Gina Peter Banyard 2025-05-05 14:19:43 +01:00
parent d8e014dfbe
commit 36ec3370fb
3 changed files with 54 additions and 54 deletions

View file

@ -33,7 +33,7 @@ static inline void *zend_ast_alloc(size_t size) {
return zend_arena_alloc(&CG(ast_arena), size); return zend_arena_alloc(&CG(ast_arena), size);
} }
static inline void *zend_ast_realloc(void *old, size_t old_size, size_t new_size) { static inline void *zend_ast_realloc(const void *old, size_t old_size, size_t new_size) {
void *new = zend_ast_alloc(new_size); void *new = zend_ast_alloc(new_size);
memcpy(new, old, old_size); memcpy(new, old, old_size);
return new; return new;
@ -43,7 +43,7 @@ static inline size_t zend_ast_list_size(uint32_t children) {
return sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * children; return sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * children;
} }
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(znode *node) { ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(const znode *node) {
zend_ast_znode *ast; zend_ast_znode *ast;
ast = zend_ast_alloc(sizeof(zend_ast_znode)); ast = zend_ast_alloc(sizeof(zend_ast_znode));
@ -66,7 +66,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_fcc(void) {
return (zend_ast *) ast; return (zend_ast *) ast;
} }
static zend_always_inline zend_ast * zend_ast_create_zval_int(zval *zv, uint32_t attr, uint32_t lineno) { static zend_always_inline zend_ast * zend_ast_create_zval_int(const zval *zv, uint32_t attr, uint32_t lineno) {
zend_ast_zval *ast; zend_ast_zval *ast;
ast = zend_ast_alloc(sizeof(zend_ast_zval)); ast = zend_ast_alloc(sizeof(zend_ast_zval));
@ -77,15 +77,15 @@ static zend_always_inline zend_ast * zend_ast_create_zval_int(zval *zv, uint32_t
return (zend_ast *) ast; return (zend_ast *) ast;
} }
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(zval *zv, uint32_t lineno) { ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(const zval *zv, uint32_t lineno) {
return zend_ast_create_zval_int(zv, 0, lineno); return zend_ast_create_zval_int(zv, 0, lineno);
} }
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr) { ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(const zval *zv, zend_ast_attr attr) {
return zend_ast_create_zval_int(zv, attr, CG(zend_lineno)); return zend_ast_create_zval_int(zv, attr, CG(zend_lineno));
} }
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(zval *zv) { ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(const zval *zv) {
return zend_ast_create_zval_int(zv, 0, CG(zend_lineno)); return zend_ast_create_zval_int(zv, 0, CG(zend_lineno));
} }
@ -508,7 +508,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *ast, zend_ast *op)
return (zend_ast *) list; return (zend_ast *) list;
} }
static zend_result zend_ast_add_array_element(zval *result, zval *offset, zval *expr) static zend_result zend_ast_add_array_element(const zval *result, zval *offset, zval *expr)
{ {
if (Z_TYPE_P(offset) == IS_UNDEF) { if (Z_TYPE_P(offset) == IS_UNDEF) {
if (!zend_hash_next_index_insert(Z_ARRVAL_P(result), expr)) { if (!zend_hash_next_index_insert(Z_ARRVAL_P(result), expr)) {
@ -528,9 +528,9 @@ static zend_result zend_ast_add_array_element(zval *result, zval *offset, zval *
return SUCCESS; return SUCCESS;
} }
static zend_result zend_ast_add_unpacked_element(zval *result, zval *expr) { static zend_result zend_ast_add_unpacked_element(const zval *result, const zval *expr) {
if (EXPECTED(Z_TYPE_P(expr) == IS_ARRAY)) { if (EXPECTED(Z_TYPE_P(expr) == IS_ARRAY)) {
HashTable *ht = Z_ARRVAL_P(expr); const HashTable *ht = Z_ARRVAL_P(expr);
zval *val; zval *val;
zend_string *key; zend_string *key;
@ -1243,7 +1243,7 @@ static size_t ZEND_FASTCALL zend_ast_tree_size(zend_ast *ast)
size = sizeof(zend_ast_fcc); size = sizeof(zend_ast_fcc);
} else if (zend_ast_is_list(ast)) { } else if (zend_ast_is_list(ast)) {
uint32_t i; uint32_t i;
zend_ast_list *list = zend_ast_get_list(ast); const zend_ast_list *list = zend_ast_get_list(ast);
size = zend_ast_list_size(list->children); size = zend_ast_list_size(list->children);
for (i = 0; i < list->children; i++) { for (i = 0; i < list->children; i++) {
@ -1284,7 +1284,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
Z_LINENO(new->val) = zend_ast_get_lineno(ast); Z_LINENO(new->val) = zend_ast_get_lineno(ast);
buf = (void*)((char*)buf + sizeof(zend_ast_zval)); buf = (void*)((char*)buf + sizeof(zend_ast_zval));
} else if (zend_ast_is_list(ast)) { } else if (zend_ast_is_list(ast)) {
zend_ast_list *list = zend_ast_get_list(ast); const zend_ast_list *list = zend_ast_get_list(ast);
zend_ast_list *new = (zend_ast_list*)buf; zend_ast_list *new = (zend_ast_list*)buf;
uint32_t i; uint32_t i;
new->kind = list->kind; new->kind = list->kind;
@ -1301,7 +1301,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
} }
} }
} else if (ast->kind == ZEND_AST_OP_ARRAY) { } else if (ast->kind == ZEND_AST_OP_ARRAY) {
zend_ast_op_array *old = zend_ast_get_op_array(ast); const zend_ast_op_array *old = zend_ast_get_op_array(ast);
zend_ast_op_array *new = (zend_ast_op_array*)buf; zend_ast_op_array *new = (zend_ast_op_array*)buf;
new->kind = old->kind; new->kind = old->kind;
new->attr = old->attr; new->attr = old->attr;
@ -1310,7 +1310,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
function_add_ref((zend_function *)new->op_array); function_add_ref((zend_function *)new->op_array);
buf = (void*)((char*)buf + sizeof(zend_ast_op_array)); buf = (void*)((char*)buf + sizeof(zend_ast_op_array));
} else if (ast->kind == ZEND_AST_CALLABLE_CONVERT) { } else if (ast->kind == ZEND_AST_CALLABLE_CONVERT) {
zend_ast_fcc *old = (zend_ast_fcc*)ast; const zend_ast_fcc *old = (zend_ast_fcc*)ast;
zend_ast_fcc *new = (zend_ast_fcc*)buf; zend_ast_fcc *new = (zend_ast_fcc*)buf;
new->kind = old->kind; new->kind = old->kind;
new->attr = old->attr; new->attr = old->attr;
@ -1371,7 +1371,7 @@ tail_call:
} else if (EXPECTED(ast->kind == ZEND_AST_ZVAL)) { } else if (EXPECTED(ast->kind == ZEND_AST_ZVAL)) {
zval_ptr_dtor_nogc(zend_ast_get_zval(ast)); zval_ptr_dtor_nogc(zend_ast_get_zval(ast));
} else if (EXPECTED(zend_ast_is_list(ast))) { } else if (EXPECTED(zend_ast_is_list(ast))) {
zend_ast_list *list = zend_ast_get_list(ast); const zend_ast_list *list = zend_ast_get_list(ast);
if (list->children) { if (list->children) {
uint32_t i; uint32_t i;
@ -1386,7 +1386,7 @@ tail_call:
} else if (EXPECTED(ast->kind == ZEND_AST_OP_ARRAY)) { } else if (EXPECTED(ast->kind == ZEND_AST_OP_ARRAY)) {
destroy_op_array(zend_ast_get_op_array(ast)->op_array); destroy_op_array(zend_ast_get_op_array(ast)->op_array);
} else if (EXPECTED(zend_ast_is_decl(ast))) { } else if (EXPECTED(zend_ast_is_decl(ast))) {
zend_ast_decl *decl = (zend_ast_decl *) ast; const zend_ast_decl *decl = (const zend_ast_decl *) ast;
if (decl->name) { if (decl->name) {
zend_string_release_ex(decl->name, 0); zend_string_release_ex(decl->name, 0);
@ -1465,7 +1465,7 @@ ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn, void *contex
static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int priority, int indent); static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int priority, int indent);
static ZEND_COLD void zend_ast_export_str(smart_str *str, zend_string *s) static ZEND_COLD void zend_ast_export_str(smart_str *str, const zend_string *s)
{ {
size_t i; size_t i;
@ -1480,7 +1480,7 @@ static ZEND_COLD void zend_ast_export_str(smart_str *str, zend_string *s)
} }
} }
static ZEND_COLD void zend_ast_export_qstr(smart_str *str, char quote, zend_string *s) static ZEND_COLD void zend_ast_export_qstr(smart_str *str, char quote, const zend_string *s)
{ {
size_t i; size_t i;
@ -1536,7 +1536,7 @@ static ZEND_COLD void zend_ast_export_indent(smart_str *str, int indent)
static ZEND_COLD void zend_ast_export_name(smart_str *str, zend_ast *ast, int priority, int indent) static ZEND_COLD void zend_ast_export_name(smart_str *str, zend_ast *ast, int priority, int indent)
{ {
if (ast->kind == ZEND_AST_ZVAL) { if (ast->kind == ZEND_AST_ZVAL) {
zval *zv = zend_ast_get_zval(ast); const zval *zv = zend_ast_get_zval(ast);
if (Z_TYPE_P(zv) == IS_STRING) { if (Z_TYPE_P(zv) == IS_STRING) {
smart_str_append(str, Z_STR_P(zv)); smart_str_append(str, Z_STR_P(zv));
@ -1549,7 +1549,7 @@ static ZEND_COLD void zend_ast_export_name(smart_str *str, zend_ast *ast, int pr
static ZEND_COLD void zend_ast_export_ns_name(smart_str *str, zend_ast *ast, int priority, int indent) static ZEND_COLD void zend_ast_export_ns_name(smart_str *str, zend_ast *ast, int priority, int indent)
{ {
if (ast->kind == ZEND_AST_ZVAL) { if (ast->kind == ZEND_AST_ZVAL) {
zval *zv = zend_ast_get_zval(ast); const zval *zv = zend_ast_get_zval(ast);
if (Z_TYPE_P(zv) == IS_STRING) { if (Z_TYPE_P(zv) == IS_STRING) {
if (ast->attr == ZEND_NAME_FQ) { if (ast->attr == ZEND_NAME_FQ) {
@ -1628,7 +1628,7 @@ static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int pri
/* Use zend_ast_export_list() unless fewer than `list->children` children should /* Use zend_ast_export_list() unless fewer than `list->children` children should
* be exported. */ * be exported. */
static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, zend_ast_list *list, bool separator, int priority, int indent, int children) static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, const zend_ast_list *list, bool separator, int priority, int indent, int children)
{ {
ZEND_ASSERT(children <= list->children); ZEND_ASSERT(children <= list->children);
uint32_t i = 0; uint32_t i = 0;
@ -1642,12 +1642,12 @@ static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, zend_ast_list *lis
} }
} }
static ZEND_COLD void zend_ast_export_list(smart_str *str, zend_ast_list *list, bool separator, int priority, int indent) static ZEND_COLD void zend_ast_export_list(smart_str *str, const zend_ast_list *list, bool separator, int priority, int indent)
{ {
zend_ast_export_list_ex(str, list, separator, priority, indent, list->children); zend_ast_export_list_ex(str, list, separator, priority, indent, list->children);
} }
static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, zend_ast_list *list, int indent) static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, const zend_ast_list *list, int indent)
{ {
uint32_t i = 0; uint32_t i = 0;
zend_ast *ast; zend_ast *ast;
@ -1655,7 +1655,7 @@ static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, ze
while (i < list->children) { while (i < list->children) {
ast = list->child[i]; ast = list->child[i];
if (ast->kind == ZEND_AST_ZVAL) { if (ast->kind == ZEND_AST_ZVAL) {
zval *zv = zend_ast_get_zval(ast); const zval *zv = zend_ast_get_zval(ast);
ZEND_ASSERT(Z_TYPE_P(zv) == IS_STRING); ZEND_ASSERT(Z_TYPE_P(zv) == IS_STRING);
zend_ast_export_qstr(str, quote, Z_STR_P(zv)); zend_ast_export_qstr(str, quote, Z_STR_P(zv));
@ -1676,7 +1676,7 @@ static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, ze
} }
} }
static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, zend_ast_list *list, int indent, const char *separator) static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, const zend_ast_list *list, int indent, const char *separator)
{ {
uint32_t i = 0; uint32_t i = 0;
@ -1692,7 +1692,7 @@ static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, zend_ast_list
#define zend_ast_export_name_list(s, l, i) zend_ast_export_name_list_ex(s, l, i, ", ") #define zend_ast_export_name_list(s, l, i) zend_ast_export_name_list_ex(s, l, i, ", ")
#define zend_ast_export_catch_name_list(s, l, i) zend_ast_export_name_list_ex(s, l, i, "|") #define zend_ast_export_catch_name_list(s, l, i) zend_ast_export_name_list_ex(s, l, i, "|")
static ZEND_COLD void zend_ast_export_var_list(smart_str *str, zend_ast_list *list, int indent) static ZEND_COLD void zend_ast_export_var_list(smart_str *str, const zend_ast_list *list, int indent)
{ {
uint32_t i = 0; uint32_t i = 0;
@ -1717,7 +1717,7 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
if (ast->kind == ZEND_AST_STMT_LIST || if (ast->kind == ZEND_AST_STMT_LIST ||
ast->kind == ZEND_AST_TRAIT_ADAPTATIONS) { ast->kind == ZEND_AST_TRAIT_ADAPTATIONS) {
zend_ast_list *list = (zend_ast_list*)ast; const zend_ast_list *list = (const zend_ast_list*)ast;
uint32_t i = 0; uint32_t i = 0;
while (i < list->children) { while (i < list->children) {
@ -1744,8 +1744,8 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
case ZEND_AST_DECLARE: case ZEND_AST_DECLARE:
break; break;
case ZEND_AST_PROP_GROUP: { case ZEND_AST_PROP_GROUP: {
zend_ast *first_prop = zend_ast_get_list(ast->child[1])->child[0]; const zend_ast *first_prop = zend_ast_get_list(ast->child[1])->child[0];
zend_ast *hook_list = first_prop->child[3]; const zend_ast *hook_list = first_prop->child[3];
if (hook_list == NULL) { if (hook_list == NULL) {
smart_str_appendc(str, ';'); smart_str_appendc(str, ';');
} }
@ -1759,7 +1759,7 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
} }
} }
static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, zend_ast_list *list, int indent) static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, const zend_ast_list *list, int indent)
{ {
uint32_t i; uint32_t i;
zend_ast *ast; zend_ast *ast;
@ -1783,7 +1783,7 @@ tail_call:
zend_ast_export_indent(str, indent); zend_ast_export_indent(str, indent);
smart_str_appends(str, "} else "); smart_str_appends(str, "} else ");
if (ast->child[1] && ast->child[1]->kind == ZEND_AST_IF) { if (ast->child[1] && ast->child[1]->kind == ZEND_AST_IF) {
list = (zend_ast_list*)ast->child[1]; list = (const zend_ast_list*)ast->child[1];
goto tail_call; goto tail_call;
} else { } else {
smart_str_appends(str, "{\n"); smart_str_appends(str, "{\n");
@ -1796,7 +1796,7 @@ tail_call:
smart_str_appendc(str, '}'); smart_str_appendc(str, '}');
} }
static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priority, int indent) static ZEND_COLD void zend_ast_export_zval(smart_str *str, const zval *zv, int priority, int indent)
{ {
ZVAL_DEREF(zv); ZVAL_DEREF(zv);
switch (Z_TYPE_P(zv)) { switch (Z_TYPE_P(zv)) {
@ -1853,7 +1853,7 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priorit
} }
} }
static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, zend_ast_decl *decl, int indent) { static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, const zend_ast_decl *decl, int indent) {
if (decl->child[0]) { if (decl->child[0]) {
smart_str_appends(str, " extends "); smart_str_appends(str, " extends ");
zend_ast_export_ns_name(str, decl->child[0], 0, indent); zend_ast_export_ns_name(str, decl->child[0], 0, indent);
@ -1869,9 +1869,9 @@ static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, zend_ast_d
} }
static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *ast, int indent) { static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *ast, int indent) {
zend_ast_list *list = zend_ast_get_list(ast); const zend_ast_list *list = zend_ast_get_list(ast);
for (uint32_t i = 0; i < list->children; i++) { for (uint32_t i = 0; i < list->children; i++) {
zend_ast *attr = list->child[i]; const zend_ast *attr = list->child[i];
if (i) { if (i) {
smart_str_appends(str, ", "); smart_str_appends(str, ", ");
@ -1887,7 +1887,7 @@ static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *
} }
static ZEND_COLD void zend_ast_export_attributes(smart_str *str, zend_ast *ast, int indent, bool newlines) { static ZEND_COLD void zend_ast_export_attributes(smart_str *str, zend_ast *ast, int indent, bool newlines) {
zend_ast_list *list = zend_ast_get_list(ast); const zend_ast_list *list = zend_ast_get_list(ast);
uint32_t i; uint32_t i;
for (i = 0; i < list->children; i++) { for (i = 0; i < list->children; i++) {
@ -1926,7 +1926,7 @@ static ZEND_COLD void zend_ast_export_visibility(smart_str *str, uint32_t flags,
static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int indent) { static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int indent) {
if (ast->kind == ZEND_AST_TYPE_UNION) { if (ast->kind == ZEND_AST_TYPE_UNION) {
zend_ast_list *list = zend_ast_get_list(ast); const zend_ast_list *list = zend_ast_get_list(ast);
for (uint32_t i = 0; i < list->children; i++) { for (uint32_t i = 0; i < list->children; i++) {
if (i != 0) { if (i != 0) {
smart_str_appendc(str, '|'); smart_str_appendc(str, '|');
@ -1936,7 +1936,7 @@ static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int in
return; return;
} }
if (ast->kind == ZEND_AST_TYPE_INTERSECTION) { if (ast->kind == ZEND_AST_TYPE_INTERSECTION) {
zend_ast_list *list = zend_ast_get_list(ast); const zend_ast_list *list = zend_ast_get_list(ast);
for (uint32_t i = 0; i < list->children; i++) { for (uint32_t i = 0; i < list->children; i++) {
if (i != 0) { if (i != 0) {
smart_str_appendc(str, '&'); smart_str_appendc(str, '&');
@ -1951,7 +1951,7 @@ static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int in
zend_ast_export_ns_name(str, ast, 0, indent); zend_ast_export_ns_name(str, ast, 0, indent);
} }
static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, zend_ast_list *hook_list, int indent) static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, const zend_ast_list *hook_list, int indent)
{ {
smart_str_appends(str, " {"); smart_str_appends(str, " {");
smart_str_appendc(str, '\n'); smart_str_appendc(str, '\n');
@ -1959,7 +1959,7 @@ static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, zend_ast_list *h
zend_ast_export_indent(str, indent); zend_ast_export_indent(str, indent);
for (uint32_t i = 0; i < hook_list->children; i++) { for (uint32_t i = 0; i < hook_list->children; i++) {
zend_ast_decl *hook = (zend_ast_decl *)hook_list->child[i]; const zend_ast_decl *hook = (const zend_ast_decl *)hook_list->child[i];
zend_ast_export_visibility(str, hook->flags, ZEND_MODIFIER_TARGET_PROPERTY); zend_ast_export_visibility(str, hook->flags, ZEND_MODIFIER_TARGET_PROPERTY);
if (hook->flags & ZEND_ACC_FINAL) { if (hook->flags & ZEND_ACC_FINAL) {
smart_str_appends(str, "final "); smart_str_appends(str, "final ");
@ -2033,7 +2033,7 @@ static ZEND_COLD void zend_ast_export_hook_list(smart_str *str, zend_ast_list *h
static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int priority, int indent) static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int priority, int indent)
{ {
zend_ast_decl *decl; const zend_ast_decl *decl;
int p, pl, pr; int p, pl, pr;
const char *op; const char *op;
@ -2069,7 +2069,7 @@ tail_call:
case ZEND_AST_CLOSURE: case ZEND_AST_CLOSURE:
case ZEND_AST_ARROW_FUNC: case ZEND_AST_ARROW_FUNC:
case ZEND_AST_METHOD: case ZEND_AST_METHOD:
decl = (zend_ast_decl *) ast; decl = (const zend_ast_decl *) ast;
if (decl->child[4]) { if (decl->child[4]) {
bool newlines = !(ast->kind == ZEND_AST_CLOSURE || ast->kind == ZEND_AST_ARROW_FUNC); bool newlines = !(ast->kind == ZEND_AST_CLOSURE || ast->kind == ZEND_AST_ARROW_FUNC);
zend_ast_export_attributes(str, decl->child[4], indent, newlines); zend_ast_export_attributes(str, decl->child[4], indent, newlines);
@ -2128,7 +2128,7 @@ tail_call:
} }
break; break;
case ZEND_AST_CLASS: case ZEND_AST_CLASS:
decl = (zend_ast_decl *) ast; decl = (const zend_ast_decl *) ast;
if (decl->child[3]) { if (decl->child[3]) {
zend_ast_export_attributes(str, decl->child[3], indent, 1); zend_ast_export_attributes(str, decl->child[3], indent, 1);
} }
@ -2523,7 +2523,7 @@ simple_list:
case ZEND_AST_NEW: case ZEND_AST_NEW:
smart_str_appends(str, "new "); smart_str_appends(str, "new ");
if (ast->child[0]->kind == ZEND_AST_CLASS) { if (ast->child[0]->kind == ZEND_AST_CLASS) {
zend_ast_decl *decl = (zend_ast_decl *) ast->child[0]; const zend_ast_decl *decl = (const zend_ast_decl *) ast->child[0];
if (decl->child[3]) { if (decl->child[3]) {
zend_ast_export_attributes(str, decl->child[3], indent, 0); zend_ast_export_attributes(str, decl->child[3], indent, 0);
} }

View file

@ -239,9 +239,9 @@ typedef struct _zend_ast_fcc {
typedef void (*zend_ast_process_t)(zend_ast *ast); typedef void (*zend_ast_process_t)(zend_ast *ast);
extern ZEND_API zend_ast_process_t zend_ast_process; extern ZEND_API zend_ast_process_t zend_ast_process;
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(zval *zv, uint32_t lineno); ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(const zval *zv, uint32_t lineno);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr); ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(const zval *zv, zend_ast_attr attr);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(zval *zv); ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(const zval *zv);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str(zend_string *str); ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str(zend_string *str);
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_long lval); ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_long lval);
@ -348,15 +348,15 @@ static zend_always_inline size_t zend_ast_size(uint32_t children) {
return XtOffsetOf(zend_ast, child) + (sizeof(zend_ast *) * children); return XtOffsetOf(zend_ast, child) + (sizeof(zend_ast *) * children);
} }
static zend_always_inline bool zend_ast_is_special(zend_ast *ast) { static zend_always_inline bool zend_ast_is_special(const zend_ast *ast) {
return (ast->kind >> ZEND_AST_SPECIAL_SHIFT) & 1; return (ast->kind >> ZEND_AST_SPECIAL_SHIFT) & 1;
} }
static zend_always_inline bool zend_ast_is_decl(zend_ast *ast) { static zend_always_inline bool zend_ast_is_decl(const zend_ast *ast) {
return zend_ast_is_special(ast) && ast->kind >= ZEND_AST_FUNC_DECL; return zend_ast_is_special(ast) && ast->kind >= ZEND_AST_FUNC_DECL;
} }
static zend_always_inline bool zend_ast_is_list(zend_ast *ast) { static zend_always_inline bool zend_ast_is_list(const zend_ast *ast) {
return (ast->kind >> ZEND_AST_IS_LIST_SHIFT) & 1; return (ast->kind >> ZEND_AST_IS_LIST_SHIFT) & 1;
} }
static zend_always_inline zend_ast_list *zend_ast_get_list(zend_ast *ast) { static zend_always_inline zend_ast_list *zend_ast_get_list(zend_ast *ast) {
@ -369,7 +369,7 @@ static zend_always_inline zval *zend_ast_get_zval(zend_ast *ast) {
return &((zend_ast_zval *) ast)->val; return &((zend_ast_zval *) ast)->val;
} }
static zend_always_inline zend_string *zend_ast_get_str(zend_ast *ast) { static zend_always_inline zend_string *zend_ast_get_str(zend_ast *ast) {
zval *zv = zend_ast_get_zval(ast); const zval *zv = zend_ast_get_zval(ast);
ZEND_ASSERT(Z_TYPE_P(zv) == IS_STRING); ZEND_ASSERT(Z_TYPE_P(zv) == IS_STRING);
return Z_STR_P(zv); return Z_STR_P(zv);
} }
@ -385,7 +385,7 @@ static zend_always_inline zend_string *zend_ast_get_constant_name(zend_ast *ast)
return Z_STR(((zend_ast_zval *) ast)->val); return Z_STR(((zend_ast_zval *) ast)->val);
} }
static zend_always_inline uint32_t zend_ast_get_num_children(zend_ast *ast) { static zend_always_inline uint32_t zend_ast_get_num_children(const zend_ast *ast) {
ZEND_ASSERT(!zend_ast_is_list(ast)); ZEND_ASSERT(!zend_ast_is_list(ast));
ZEND_ASSERT(!zend_ast_is_special(ast)); ZEND_ASSERT(!zend_ast_is_special(ast));
@ -393,10 +393,10 @@ static zend_always_inline uint32_t zend_ast_get_num_children(zend_ast *ast) {
} }
static zend_always_inline uint32_t zend_ast_get_lineno(zend_ast *ast) { static zend_always_inline uint32_t zend_ast_get_lineno(zend_ast *ast) {
if (ast->kind == ZEND_AST_ZVAL) { if (ast->kind == ZEND_AST_ZVAL) {
zval *zv = zend_ast_get_zval(ast); const zval *zv = zend_ast_get_zval(ast);
return Z_LINENO_P(zv); return Z_LINENO_P(zv);
} else if (ast->kind == ZEND_AST_CONSTANT) { } else if (ast->kind == ZEND_AST_CONSTANT) {
zval *zv = &((zend_ast_zval *) ast)->val; const zval *zv = &((const zend_ast_zval *) ast)->val;
return Z_LINENO_P(zv); return Z_LINENO_P(zv);
} else { } else {
return ast->lineno; return ast->lineno;

View file

@ -97,7 +97,7 @@ typedef struct _zend_ast_znode {
znode node; znode node;
} zend_ast_znode; } zend_ast_znode;
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(znode *node); ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(const znode *node);
static zend_always_inline znode *zend_ast_get_znode(zend_ast *ast) { static zend_always_inline znode *zend_ast_get_znode(zend_ast *ast) {
return &((zend_ast_znode *) ast)->node; return &((zend_ast_znode *) ast)->node;