@@ -33,7 +33,7 @@ static inline void *zend_ast_alloc(size_t size) {
33
33
return zend_arena_alloc (& CG (ast_arena ), size );
34
34
}
35
35
36
- static inline void * zend_ast_realloc (void * old , size_t old_size , size_t new_size ) {
36
+ static inline void * zend_ast_realloc (const void * old , size_t old_size , size_t new_size ) {
37
37
void * new = zend_ast_alloc (new_size );
38
38
memcpy (new , old , old_size );
39
39
return new ;
@@ -43,7 +43,7 @@ static inline size_t zend_ast_list_size(uint32_t children) {
43
43
return sizeof (zend_ast_list ) - sizeof (zend_ast * ) + sizeof (zend_ast * ) * children ;
44
44
}
45
45
46
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode (znode * node ) {
46
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode (const znode * node ) {
47
47
zend_ast_znode * ast ;
48
48
49
49
ast = zend_ast_alloc (sizeof (zend_ast_znode ));
@@ -66,7 +66,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_fcc(void) {
66
66
return (zend_ast * ) ast ;
67
67
}
68
68
69
- static zend_always_inline zend_ast * zend_ast_create_zval_int (zval * zv , uint32_t attr , uint32_t lineno ) {
69
+ static zend_always_inline zend_ast * zend_ast_create_zval_int (const zval * zv , uint32_t attr , uint32_t lineno ) {
70
70
zend_ast_zval * ast ;
71
71
72
72
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
77
77
return (zend_ast * ) ast ;
78
78
}
79
79
80
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno (zval * zv , uint32_t lineno ) {
80
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno (const zval * zv , uint32_t lineno ) {
81
81
return zend_ast_create_zval_int (zv , 0 , lineno );
82
82
}
83
83
84
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex (zval * zv , zend_ast_attr attr ) {
84
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex (const zval * zv , zend_ast_attr attr ) {
85
85
return zend_ast_create_zval_int (zv , attr , CG (zend_lineno ));
86
86
}
87
87
88
- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval (zval * zv ) {
88
+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval (const zval * zv ) {
89
89
return zend_ast_create_zval_int (zv , 0 , CG (zend_lineno ));
90
90
}
91
91
@@ -508,7 +508,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *ast, zend_ast *op)
508
508
return (zend_ast * ) list ;
509
509
}
510
510
511
- static zend_result zend_ast_add_array_element (zval * result , zval * offset , zval * expr )
511
+ static zend_result zend_ast_add_array_element (const zval * result , zval * offset , zval * expr )
512
512
{
513
513
if (Z_TYPE_P (offset ) == IS_UNDEF ) {
514
514
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 *
528
528
return SUCCESS ;
529
529
}
530
530
531
- static zend_result zend_ast_add_unpacked_element (zval * result , zval * expr ) {
531
+ static zend_result zend_ast_add_unpacked_element (const zval * result , const zval * expr ) {
532
532
if (EXPECTED (Z_TYPE_P (expr ) == IS_ARRAY )) {
533
- HashTable * ht = Z_ARRVAL_P (expr );
533
+ const HashTable * ht = Z_ARRVAL_P (expr );
534
534
zval * val ;
535
535
zend_string * key ;
536
536
@@ -1243,7 +1243,7 @@ static size_t ZEND_FASTCALL zend_ast_tree_size(zend_ast *ast)
1243
1243
size = sizeof (zend_ast_fcc );
1244
1244
} else if (zend_ast_is_list (ast )) {
1245
1245
uint32_t i ;
1246
- zend_ast_list * list = zend_ast_get_list (ast );
1246
+ const zend_ast_list * list = zend_ast_get_list (ast );
1247
1247
1248
1248
size = zend_ast_list_size (list -> children );
1249
1249
for (i = 0 ; i < list -> children ; i ++ ) {
@@ -1284,7 +1284,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
1284
1284
Z_LINENO (new -> val ) = zend_ast_get_lineno (ast );
1285
1285
buf = (void * )((char * )buf + sizeof (zend_ast_zval ));
1286
1286
} else if (zend_ast_is_list (ast )) {
1287
- zend_ast_list * list = zend_ast_get_list (ast );
1287
+ const zend_ast_list * list = zend_ast_get_list (ast );
1288
1288
zend_ast_list * new = (zend_ast_list * )buf ;
1289
1289
uint32_t i ;
1290
1290
new -> kind = list -> kind ;
@@ -1301,7 +1301,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
1301
1301
}
1302
1302
}
1303
1303
} else if (ast -> kind == ZEND_AST_OP_ARRAY ) {
1304
- zend_ast_op_array * old = zend_ast_get_op_array (ast );
1304
+ const zend_ast_op_array * old = zend_ast_get_op_array (ast );
1305
1305
zend_ast_op_array * new = (zend_ast_op_array * )buf ;
1306
1306
new -> kind = old -> kind ;
1307
1307
new -> attr = old -> attr ;
@@ -1310,7 +1310,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
1310
1310
function_add_ref ((zend_function * )new -> op_array );
1311
1311
buf = (void * )((char * )buf + sizeof (zend_ast_op_array ));
1312
1312
} else if (ast -> kind == ZEND_AST_CALLABLE_CONVERT ) {
1313
- zend_ast_fcc * old = (zend_ast_fcc * )ast ;
1313
+ const zend_ast_fcc * old = (zend_ast_fcc * )ast ;
1314
1314
zend_ast_fcc * new = (zend_ast_fcc * )buf ;
1315
1315
new -> kind = old -> kind ;
1316
1316
new -> attr = old -> attr ;
@@ -1371,7 +1371,7 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast)
1371
1371
} else if (EXPECTED (ast -> kind == ZEND_AST_ZVAL )) {
1372
1372
zval_ptr_dtor_nogc (zend_ast_get_zval (ast ));
1373
1373
} else if (EXPECTED (zend_ast_is_list (ast ))) {
1374
- zend_ast_list * list = zend_ast_get_list (ast );
1374
+ const zend_ast_list * list = zend_ast_get_list (ast );
1375
1375
if (list -> children ) {
1376
1376
uint32_t i ;
1377
1377
@@ -1386,7 +1386,7 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast)
1386
1386
} else if (EXPECTED (ast -> kind == ZEND_AST_OP_ARRAY )) {
1387
1387
destroy_op_array (zend_ast_get_op_array (ast )-> op_array );
1388
1388
} else if (EXPECTED (zend_ast_is_decl (ast ))) {
1389
- zend_ast_decl * decl = (zend_ast_decl * ) ast ;
1389
+ const zend_ast_decl * decl = (const zend_ast_decl * ) ast ;
1390
1390
1391
1391
if (decl -> name ) {
1392
1392
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
1465
1465
1466
1466
static ZEND_COLD void zend_ast_export_ex (smart_str * str , zend_ast * ast , int priority , int indent );
1467
1467
1468
- static ZEND_COLD void zend_ast_export_str (smart_str * str , zend_string * s )
1468
+ static ZEND_COLD void zend_ast_export_str (smart_str * str , const zend_string * s )
1469
1469
{
1470
1470
size_t i ;
1471
1471
@@ -1480,7 +1480,7 @@ static ZEND_COLD void zend_ast_export_str(smart_str *str, zend_string *s)
1480
1480
}
1481
1481
}
1482
1482
1483
- static ZEND_COLD void zend_ast_export_qstr (smart_str * str , char quote , zend_string * s )
1483
+ static ZEND_COLD void zend_ast_export_qstr (smart_str * str , char quote , const zend_string * s )
1484
1484
{
1485
1485
size_t i ;
1486
1486
@@ -1536,7 +1536,7 @@ static ZEND_COLD void zend_ast_export_indent(smart_str *str, int indent)
1536
1536
static ZEND_COLD void zend_ast_export_name (smart_str * str , zend_ast * ast , int priority , int indent )
1537
1537
{
1538
1538
if (ast -> kind == ZEND_AST_ZVAL ) {
1539
- zval * zv = zend_ast_get_zval (ast );
1539
+ const zval * zv = zend_ast_get_zval (ast );
1540
1540
1541
1541
if (Z_TYPE_P (zv ) == IS_STRING ) {
1542
1542
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
1549
1549
static ZEND_COLD void zend_ast_export_ns_name (smart_str * str , zend_ast * ast , int priority , int indent )
1550
1550
{
1551
1551
if (ast -> kind == ZEND_AST_ZVAL ) {
1552
- zval * zv = zend_ast_get_zval (ast );
1552
+ const zval * zv = zend_ast_get_zval (ast );
1553
1553
1554
1554
if (Z_TYPE_P (zv ) == IS_STRING ) {
1555
1555
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
1628
1628
1629
1629
/* Use zend_ast_export_list() unless fewer than `list->children` children should
1630
1630
* be exported. */
1631
- static ZEND_COLD void zend_ast_export_list_ex (smart_str * str , zend_ast_list * list , bool separator , int priority , int indent , int children )
1631
+ 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 )
1632
1632
{
1633
1633
ZEND_ASSERT (children <= list -> children );
1634
1634
uint32_t i = 0 ;
@@ -1642,20 +1642,20 @@ static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, zend_ast_list *lis
1642
1642
}
1643
1643
}
1644
1644
1645
- static ZEND_COLD void zend_ast_export_list (smart_str * str , zend_ast_list * list , bool separator , int priority , int indent )
1645
+ static ZEND_COLD void zend_ast_export_list (smart_str * str , const zend_ast_list * list , bool separator , int priority , int indent )
1646
1646
{
1647
1647
zend_ast_export_list_ex (str , list , separator , priority , indent , list -> children );
1648
1648
}
1649
1649
1650
- static ZEND_COLD void zend_ast_export_encaps_list (smart_str * str , char quote , zend_ast_list * list , int indent )
1650
+ static ZEND_COLD void zend_ast_export_encaps_list (smart_str * str , char quote , const zend_ast_list * list , int indent )
1651
1651
{
1652
1652
uint32_t i = 0 ;
1653
1653
zend_ast * ast ;
1654
1654
1655
1655
while (i < list -> children ) {
1656
1656
ast = list -> child [i ];
1657
1657
if (ast -> kind == ZEND_AST_ZVAL ) {
1658
- zval * zv = zend_ast_get_zval (ast );
1658
+ const zval * zv = zend_ast_get_zval (ast );
1659
1659
1660
1660
ZEND_ASSERT (Z_TYPE_P (zv ) == IS_STRING );
1661
1661
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
1676
1676
}
1677
1677
}
1678
1678
1679
- static ZEND_COLD void zend_ast_export_name_list_ex (smart_str * str , zend_ast_list * list , int indent , const char * separator )
1679
+ static ZEND_COLD void zend_ast_export_name_list_ex (smart_str * str , const zend_ast_list * list , int indent , const char * separator )
1680
1680
{
1681
1681
uint32_t i = 0 ;
1682
1682
@@ -1692,7 +1692,7 @@ static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, zend_ast_list
1692
1692
#define zend_ast_export_name_list (s , l , i ) zend_ast_export_name_list_ex(s, l, i, ", ")
1693
1693
#define zend_ast_export_catch_name_list (s , l , i ) zend_ast_export_name_list_ex(s, l, i, "|")
1694
1694
1695
- static ZEND_COLD void zend_ast_export_var_list (smart_str * str , zend_ast_list * list , int indent )
1695
+ static ZEND_COLD void zend_ast_export_var_list (smart_str * str , const zend_ast_list * list , int indent )
1696
1696
{
1697
1697
uint32_t i = 0 ;
1698
1698
@@ -1717,7 +1717,7 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
1717
1717
1718
1718
if (ast -> kind == ZEND_AST_STMT_LIST ||
1719
1719
ast -> kind == ZEND_AST_TRAIT_ADAPTATIONS ) {
1720
- zend_ast_list * list = (zend_ast_list * )ast ;
1720
+ const zend_ast_list * list = (const zend_ast_list * )ast ;
1721
1721
uint32_t i = 0 ;
1722
1722
1723
1723
while (i < list -> children ) {
@@ -1744,8 +1744,8 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
1744
1744
case ZEND_AST_DECLARE :
1745
1745
break ;
1746
1746
case ZEND_AST_PROP_GROUP : {
1747
- zend_ast * first_prop = zend_ast_get_list (ast -> child [1 ])-> child [0 ];
1748
- zend_ast * hook_list = first_prop -> child [3 ];
1747
+ const zend_ast * first_prop = zend_ast_get_list (ast -> child [1 ])-> child [0 ];
1748
+ const zend_ast * hook_list = first_prop -> child [3 ];
1749
1749
if (hook_list == NULL ) {
1750
1750
smart_str_appendc (str , ';' );
1751
1751
}
@@ -1759,7 +1759,7 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
1759
1759
}
1760
1760
}
1761
1761
1762
- static ZEND_COLD void zend_ast_export_if_stmt (smart_str * str , zend_ast_list * list , int indent )
1762
+ static ZEND_COLD void zend_ast_export_if_stmt (smart_str * str , const zend_ast_list * list , int indent )
1763
1763
{
1764
1764
uint32_t i ;
1765
1765
zend_ast * ast ;
@@ -1783,7 +1783,7 @@ static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, zend_ast_list *lis
1783
1783
zend_ast_export_indent (str , indent );
1784
1784
smart_str_appends (str , "} else " );
1785
1785
if (ast -> child [1 ] && ast -> child [1 ]-> kind == ZEND_AST_IF ) {
1786
- list = (zend_ast_list * )ast -> child [1 ];
1786
+ list = (const zend_ast_list * )ast -> child [1 ];
1787
1787
goto tail_call ;
1788
1788
} else {
1789
1789
smart_str_appends (str , "{\n" );
@@ -1796,7 +1796,7 @@ static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, zend_ast_list *lis
1796
1796
smart_str_appendc (str , '}' );
1797
1797
}
1798
1798
1799
- static ZEND_COLD void zend_ast_export_zval (smart_str * str , zval * zv , int priority , int indent )
1799
+ static ZEND_COLD void zend_ast_export_zval (smart_str * str , const zval * zv , int priority , int indent )
1800
1800
{
1801
1801
ZVAL_DEREF (zv );
1802
1802
switch (Z_TYPE_P (zv )) {
@@ -1853,7 +1853,7 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priorit
1853
1853
}
1854
1854
}
1855
1855
1856
- static ZEND_COLD void zend_ast_export_class_no_header (smart_str * str , zend_ast_decl * decl , int indent ) {
1856
+ static ZEND_COLD void zend_ast_export_class_no_header (smart_str * str , const zend_ast_decl * decl , int indent ) {
1857
1857
if (decl -> child [0 ]) {
1858
1858
smart_str_appends (str , " extends " );
1859
1859
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
1869
1869
}
1870
1870
1871
1871
static ZEND_COLD void zend_ast_export_attribute_group (smart_str * str , zend_ast * ast , int indent ) {
1872
- zend_ast_list * list = zend_ast_get_list (ast );
1872
+ const zend_ast_list * list = zend_ast_get_list (ast );
1873
1873
for (uint32_t i = 0 ; i < list -> children ; i ++ ) {
1874
- zend_ast * attr = list -> child [i ];
1874
+ const zend_ast * attr = list -> child [i ];
1875
1875
1876
1876
if (i ) {
1877
1877
smart_str_appends (str , ", " );
@@ -1887,7 +1887,7 @@ static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *
1887
1887
}
1888
1888
1889
1889
static ZEND_COLD void zend_ast_export_attributes (smart_str * str , zend_ast * ast , int indent , bool newlines ) {
1890
- zend_ast_list * list = zend_ast_get_list (ast );
1890
+ const zend_ast_list * list = zend_ast_get_list (ast );
1891
1891
uint32_t i ;
1892
1892
1893
1893
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,
1926
1926
1927
1927
static ZEND_COLD void zend_ast_export_type (smart_str * str , zend_ast * ast , int indent ) {
1928
1928
if (ast -> kind == ZEND_AST_TYPE_UNION ) {
1929
- zend_ast_list * list = zend_ast_get_list (ast );
1929
+ const zend_ast_list * list = zend_ast_get_list (ast );
1930
1930
for (uint32_t i = 0 ; i < list -> children ; i ++ ) {
1931
1931
if (i != 0 ) {
1932
1932
smart_str_appendc (str , '|' );
@@ -1936,7 +1936,7 @@ static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int in
1936
1936
return ;
1937
1937
}
1938
1938
if (ast -> kind == ZEND_AST_TYPE_INTERSECTION ) {
1939
- zend_ast_list * list = zend_ast_get_list (ast );
1939
+ const zend_ast_list * list = zend_ast_get_list (ast );
1940
1940
for (uint32_t i = 0 ; i < list -> children ; i ++ ) {
1941
1941
if (i != 0 ) {
1942
1942
smart_str_appendc (str , '&' );
@@ -1951,15 +1951,15 @@ static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int in
1951
1951
zend_ast_export_ns_name (str , ast , 0 , indent );
1952
1952
}
1953
1953
1954
- static ZEND_COLD void zend_ast_export_hook_list (smart_str * str , zend_ast_list * hook_list , int indent )
1954
+ static ZEND_COLD void zend_ast_export_hook_list (smart_str * str , const zend_ast_list * hook_list , int indent )
1955
1955
{
1956
1956
smart_str_appends (str , " {" );
1957
1957
smart_str_appendc (str , '\n' );
1958
1958
indent ++ ;
1959
1959
zend_ast_export_indent (str , indent );
1960
1960
1961
1961
for (uint32_t i = 0 ; i < hook_list -> children ; i ++ ) {
1962
- zend_ast_decl * hook = (zend_ast_decl * )hook_list -> child [i ];
1962
+ const zend_ast_decl * hook = (const zend_ast_decl * )hook_list -> child [i ];
1963
1963
zend_ast_export_visibility (str , hook -> flags , ZEND_MODIFIER_TARGET_PROPERTY );
1964
1964
if (hook -> flags & ZEND_ACC_FINAL ) {
1965
1965
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
2033
2033
2034
2034
static ZEND_COLD void zend_ast_export_ex (smart_str * str , zend_ast * ast , int priority , int indent )
2035
2035
{
2036
- zend_ast_decl * decl ;
2036
+ const zend_ast_decl * decl ;
2037
2037
int p , pl , pr ;
2038
2038
const char * op ;
2039
2039
@@ -2069,7 +2069,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
2069
2069
case ZEND_AST_CLOSURE :
2070
2070
case ZEND_AST_ARROW_FUNC :
2071
2071
case ZEND_AST_METHOD :
2072
- decl = (zend_ast_decl * ) ast ;
2072
+ decl = (const zend_ast_decl * ) ast ;
2073
2073
if (decl -> child [4 ]) {
2074
2074
bool newlines = !(ast -> kind == ZEND_AST_CLOSURE || ast -> kind == ZEND_AST_ARROW_FUNC );
2075
2075
zend_ast_export_attributes (str , decl -> child [4 ], indent , newlines );
@@ -2128,7 +2128,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
2128
2128
}
2129
2129
break ;
2130
2130
case ZEND_AST_CLASS :
2131
- decl = (zend_ast_decl * ) ast ;
2131
+ decl = (const zend_ast_decl * ) ast ;
2132
2132
if (decl -> child [3 ]) {
2133
2133
zend_ast_export_attributes (str , decl -> child [3 ], indent , 1 );
2134
2134
}
@@ -2523,7 +2523,7 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
2523
2523
case ZEND_AST_NEW :
2524
2524
smart_str_appends (str , "new " );
2525
2525
if (ast -> child [0 ]-> kind == ZEND_AST_CLASS ) {
2526
- zend_ast_decl * decl = (zend_ast_decl * ) ast -> child [0 ];
2526
+ const zend_ast_decl * decl = (const zend_ast_decl * ) ast -> child [0 ];
2527
2527
if (decl -> child [3 ]) {
2528
2528
zend_ast_export_attributes (str , decl -> child [3 ], indent , 0 );
2529
2529
}
0 commit comments