@@ -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
@@ -1248,7 +1248,7 @@ static size_t ZEND_FASTCALL zend_ast_tree_size(zend_ast *ast)
1248
1248
size = sizeof (zend_ast_fcc );
1249
1249
} else if (zend_ast_is_list (ast )) {
1250
1250
uint32_t i ;
1251
- zend_ast_list * list = zend_ast_get_list (ast );
1251
+ const zend_ast_list * list = zend_ast_get_list (ast );
1252
1252
1253
1253
size = zend_ast_list_size (list -> children );
1254
1254
for (i = 0 ; i < list -> children ; i ++ ) {
@@ -1289,7 +1289,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
1289
1289
Z_LINENO (new -> val ) = zend_ast_get_lineno (ast );
1290
1290
buf = (void * )((char * )buf + sizeof (zend_ast_zval ));
1291
1291
} else if (zend_ast_is_list (ast )) {
1292
- zend_ast_list * list = zend_ast_get_list (ast );
1292
+ const zend_ast_list * list = zend_ast_get_list (ast );
1293
1293
zend_ast_list * new = (zend_ast_list * )buf ;
1294
1294
uint32_t i ;
1295
1295
new -> kind = list -> kind ;
@@ -1306,7 +1306,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
1306
1306
}
1307
1307
}
1308
1308
} else if (ast -> kind == ZEND_AST_OP_ARRAY ) {
1309
- zend_ast_op_array * old = zend_ast_get_op_array (ast );
1309
+ const zend_ast_op_array * old = zend_ast_get_op_array (ast );
1310
1310
zend_ast_op_array * new = (zend_ast_op_array * )buf ;
1311
1311
new -> kind = old -> kind ;
1312
1312
new -> attr = old -> attr ;
@@ -1315,7 +1315,7 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
1315
1315
function_add_ref ((zend_function * )new -> op_array );
1316
1316
buf = (void * )((char * )buf + sizeof (zend_ast_op_array ));
1317
1317
} else if (ast -> kind == ZEND_AST_CALLABLE_CONVERT ) {
1318
- zend_ast_fcc * old = (zend_ast_fcc * )ast ;
1318
+ const zend_ast_fcc * old = (zend_ast_fcc * )ast ;
1319
1319
zend_ast_fcc * new = (zend_ast_fcc * )buf ;
1320
1320
new -> kind = old -> kind ;
1321
1321
new -> attr = old -> attr ;
@@ -1376,7 +1376,7 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast)
1376
1376
} else if (EXPECTED (ast -> kind == ZEND_AST_ZVAL )) {
1377
1377
zval_ptr_dtor_nogc (zend_ast_get_zval (ast ));
1378
1378
} else if (EXPECTED (zend_ast_is_list (ast ))) {
1379
- zend_ast_list * list = zend_ast_get_list (ast );
1379
+ const zend_ast_list * list = zend_ast_get_list (ast );
1380
1380
if (list -> children ) {
1381
1381
uint32_t i ;
1382
1382
@@ -1391,7 +1391,7 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast)
1391
1391
} else if (EXPECTED (ast -> kind == ZEND_AST_OP_ARRAY )) {
1392
1392
destroy_op_array (zend_ast_get_op_array (ast )-> op_array );
1393
1393
} else if (EXPECTED (zend_ast_is_decl (ast ))) {
1394
- zend_ast_decl * decl = (zend_ast_decl * ) ast ;
1394
+ const zend_ast_decl * decl = (zend_ast_decl * ) ast ;
1395
1395
1396
1396
if (decl -> name ) {
1397
1397
zend_string_release_ex (decl -> name , 0 );
@@ -1414,7 +1414,7 @@ ZEND_API void ZEND_FASTCALL zend_ast_ref_destroy(zend_ast_ref *ast)
1414
1414
efree (ast );
1415
1415
}
1416
1416
1417
- ZEND_API void zend_ast_apply (zend_ast * ast , zend_ast_apply_func fn , void * context ) {
1417
+ ZEND_API void zend_ast_apply (zend_ast * ast , const zend_ast_apply_func fn , void * context ) {
1418
1418
if (zend_ast_is_list (ast )) {
1419
1419
zend_ast_list * list = zend_ast_get_list (ast );
1420
1420
uint32_t i ;
@@ -1470,7 +1470,7 @@ ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn, void *contex
1470
1470
1471
1471
static ZEND_COLD void zend_ast_export_ex (smart_str * str , zend_ast * ast , int priority , int indent );
1472
1472
1473
- static ZEND_COLD void zend_ast_export_str (smart_str * str , zend_string * s )
1473
+ static ZEND_COLD void zend_ast_export_str (smart_str * str , const zend_string * s )
1474
1474
{
1475
1475
size_t i ;
1476
1476
@@ -1485,7 +1485,7 @@ static ZEND_COLD void zend_ast_export_str(smart_str *str, zend_string *s)
1485
1485
}
1486
1486
}
1487
1487
1488
- static ZEND_COLD void zend_ast_export_qstr (smart_str * str , char quote , zend_string * s )
1488
+ static ZEND_COLD void zend_ast_export_qstr (smart_str * str , char quote , const zend_string * s )
1489
1489
{
1490
1490
size_t i ;
1491
1491
@@ -1541,7 +1541,7 @@ static ZEND_COLD void zend_ast_export_indent(smart_str *str, int indent)
1541
1541
static ZEND_COLD void zend_ast_export_name (smart_str * str , zend_ast * ast , int priority , int indent )
1542
1542
{
1543
1543
if (ast -> kind == ZEND_AST_ZVAL ) {
1544
- zval * zv = zend_ast_get_zval (ast );
1544
+ const zval * zv = zend_ast_get_zval (ast );
1545
1545
1546
1546
if (Z_TYPE_P (zv ) == IS_STRING ) {
1547
1547
smart_str_append (str , Z_STR_P (zv ));
@@ -1554,7 +1554,7 @@ static ZEND_COLD void zend_ast_export_name(smart_str *str, zend_ast *ast, int pr
1554
1554
static ZEND_COLD void zend_ast_export_ns_name (smart_str * str , zend_ast * ast , int priority , int indent )
1555
1555
{
1556
1556
if (ast -> kind == ZEND_AST_ZVAL ) {
1557
- zval * zv = zend_ast_get_zval (ast );
1557
+ const zval * zv = zend_ast_get_zval (ast );
1558
1558
1559
1559
if (Z_TYPE_P (zv ) == IS_STRING ) {
1560
1560
if (ast -> attr == ZEND_NAME_FQ ) {
@@ -1633,7 +1633,7 @@ static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int pri
1633
1633
1634
1634
/* Use zend_ast_export_list() unless fewer than `list->children` children should
1635
1635
* be exported. */
1636
- static ZEND_COLD void zend_ast_export_list_ex (smart_str * str , zend_ast_list * list , bool separator , int priority , int indent , int children )
1636
+ 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 )
1637
1637
{
1638
1638
ZEND_ASSERT (children <= list -> children );
1639
1639
uint32_t i = 0 ;
@@ -1647,20 +1647,20 @@ static ZEND_COLD void zend_ast_export_list_ex(smart_str *str, zend_ast_list *lis
1647
1647
}
1648
1648
}
1649
1649
1650
- static ZEND_COLD void zend_ast_export_list (smart_str * str , zend_ast_list * list , bool separator , int priority , int indent )
1650
+ static ZEND_COLD void zend_ast_export_list (smart_str * str , const zend_ast_list * list , bool separator , int priority , int indent )
1651
1651
{
1652
1652
zend_ast_export_list_ex (str , list , separator , priority , indent , list -> children );
1653
1653
}
1654
1654
1655
- static ZEND_COLD void zend_ast_export_encaps_list (smart_str * str , char quote , zend_ast_list * list , int indent )
1655
+ static ZEND_COLD void zend_ast_export_encaps_list (smart_str * str , char quote , const zend_ast_list * list , int indent )
1656
1656
{
1657
1657
uint32_t i = 0 ;
1658
1658
zend_ast * ast ;
1659
1659
1660
1660
while (i < list -> children ) {
1661
1661
ast = list -> child [i ];
1662
1662
if (ast -> kind == ZEND_AST_ZVAL ) {
1663
- zval * zv = zend_ast_get_zval (ast );
1663
+ const zval * zv = zend_ast_get_zval (ast );
1664
1664
1665
1665
ZEND_ASSERT (Z_TYPE_P (zv ) == IS_STRING );
1666
1666
zend_ast_export_qstr (str , quote , Z_STR_P (zv ));
@@ -1681,7 +1681,7 @@ static ZEND_COLD void zend_ast_export_encaps_list(smart_str *str, char quote, ze
1681
1681
}
1682
1682
}
1683
1683
1684
- static ZEND_COLD void zend_ast_export_name_list_ex (smart_str * str , zend_ast_list * list , int indent , const char * separator )
1684
+ static ZEND_COLD void zend_ast_export_name_list_ex (smart_str * str , const zend_ast_list * list , int indent , const char * separator )
1685
1685
{
1686
1686
uint32_t i = 0 ;
1687
1687
@@ -1697,7 +1697,7 @@ static ZEND_COLD void zend_ast_export_name_list_ex(smart_str *str, zend_ast_list
1697
1697
#define zend_ast_export_name_list (s , l , i ) zend_ast_export_name_list_ex(s, l, i, ", ")
1698
1698
#define zend_ast_export_catch_name_list (s , l , i ) zend_ast_export_name_list_ex(s, l, i, "|")
1699
1699
1700
- static ZEND_COLD void zend_ast_export_var_list (smart_str * str , zend_ast_list * list , int indent )
1700
+ static ZEND_COLD void zend_ast_export_var_list (smart_str * str , const zend_ast_list * list , int indent )
1701
1701
{
1702
1702
uint32_t i = 0 ;
1703
1703
@@ -1722,7 +1722,7 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
1722
1722
1723
1723
if (ast -> kind == ZEND_AST_STMT_LIST ||
1724
1724
ast -> kind == ZEND_AST_TRAIT_ADAPTATIONS ) {
1725
- zend_ast_list * list = (zend_ast_list * )ast ;
1725
+ const zend_ast_list * list = (const zend_ast_list * )ast ;
1726
1726
uint32_t i = 0 ;
1727
1727
1728
1728
while (i < list -> children ) {
@@ -1749,8 +1749,8 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
1749
1749
case ZEND_AST_DECLARE :
1750
1750
break ;
1751
1751
case ZEND_AST_PROP_GROUP : {
1752
- zend_ast * first_prop = zend_ast_get_list (ast -> child [1 ])-> child [0 ];
1753
- zend_ast * hook_list = first_prop -> child [3 ];
1752
+ const zend_ast * first_prop = zend_ast_get_list (ast -> child [1 ])-> child [0 ];
1753
+ const zend_ast * hook_list = first_prop -> child [3 ];
1754
1754
if (hook_list == NULL ) {
1755
1755
smart_str_appendc (str , ';' );
1756
1756
}
@@ -1764,7 +1764,7 @@ static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int in
1764
1764
}
1765
1765
}
1766
1766
1767
- static ZEND_COLD void zend_ast_export_if_stmt (smart_str * str , zend_ast_list * list , int indent )
1767
+ static ZEND_COLD void zend_ast_export_if_stmt (smart_str * str , const zend_ast_list * list , int indent )
1768
1768
{
1769
1769
uint32_t i ;
1770
1770
zend_ast * ast ;
@@ -1788,7 +1788,7 @@ static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, zend_ast_list *lis
1788
1788
zend_ast_export_indent (str , indent );
1789
1789
smart_str_appends (str , "} else " );
1790
1790
if (ast -> child [1 ] && ast -> child [1 ]-> kind == ZEND_AST_IF ) {
1791
- list = (zend_ast_list * )ast -> child [1 ];
1791
+ list = (const zend_ast_list * )ast -> child [1 ];
1792
1792
goto tail_call ;
1793
1793
} else {
1794
1794
smart_str_appends (str , "{\n" );
@@ -1801,7 +1801,7 @@ static ZEND_COLD void zend_ast_export_if_stmt(smart_str *str, zend_ast_list *lis
1801
1801
smart_str_appendc (str , '}' );
1802
1802
}
1803
1803
1804
- static ZEND_COLD void zend_ast_export_zval (smart_str * str , zval * zv , int priority , int indent )
1804
+ static ZEND_COLD void zend_ast_export_zval (smart_str * str , const zval * zv , int priority , int indent )
1805
1805
{
1806
1806
ZVAL_DEREF (zv );
1807
1807
switch (Z_TYPE_P (zv )) {
@@ -1858,7 +1858,7 @@ static ZEND_COLD void zend_ast_export_zval(smart_str *str, zval *zv, int priorit
1858
1858
}
1859
1859
}
1860
1860
1861
- static ZEND_COLD void zend_ast_export_class_no_header (smart_str * str , zend_ast_decl * decl , int indent ) {
1861
+ static ZEND_COLD void zend_ast_export_class_no_header (smart_str * str , const zend_ast_decl * decl , int indent ) {
1862
1862
if (decl -> child [0 ]) {
1863
1863
smart_str_appends (str , " extends " );
1864
1864
zend_ast_export_ns_name (str , decl -> child [0 ], 0 , indent );
@@ -1874,9 +1874,9 @@ static ZEND_COLD void zend_ast_export_class_no_header(smart_str *str, zend_ast_d
1874
1874
}
1875
1875
1876
1876
static ZEND_COLD void zend_ast_export_attribute_group (smart_str * str , zend_ast * ast , int indent ) {
1877
- zend_ast_list * list = zend_ast_get_list (ast );
1877
+ const zend_ast_list * list = zend_ast_get_list (ast );
1878
1878
for (uint32_t i = 0 ; i < list -> children ; i ++ ) {
1879
- zend_ast * attr = list -> child [i ];
1879
+ const zend_ast * attr = list -> child [i ];
1880
1880
1881
1881
if (i ) {
1882
1882
smart_str_appends (str , ", " );
@@ -1892,7 +1892,7 @@ static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *
1892
1892
}
1893
1893
1894
1894
static ZEND_COLD void zend_ast_export_attributes (smart_str * str , zend_ast * ast , int indent , bool newlines ) {
1895
- zend_ast_list * list = zend_ast_get_list (ast );
1895
+ const zend_ast_list * list = zend_ast_get_list (ast );
1896
1896
uint32_t i ;
1897
1897
1898
1898
for (i = 0 ; i < list -> children ; i ++ ) {
@@ -1931,7 +1931,7 @@ static ZEND_COLD void zend_ast_export_visibility(smart_str *str, uint32_t flags,
1931
1931
1932
1932
static ZEND_COLD void zend_ast_export_type (smart_str * str , zend_ast * ast , int indent ) {
1933
1933
if (ast -> kind == ZEND_AST_TYPE_UNION ) {
1934
- zend_ast_list * list = zend_ast_get_list (ast );
1934
+ const zend_ast_list * list = zend_ast_get_list (ast );
1935
1935
for (uint32_t i = 0 ; i < list -> children ; i ++ ) {
1936
1936
if (i != 0 ) {
1937
1937
smart_str_appendc (str , '|' );
@@ -1941,7 +1941,7 @@ static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int in
1941
1941
return ;
1942
1942
}
1943
1943
if (ast -> kind == ZEND_AST_TYPE_INTERSECTION ) {
1944
- zend_ast_list * list = zend_ast_get_list (ast );
1944
+ const zend_ast_list * list = zend_ast_get_list (ast );
1945
1945
for (uint32_t i = 0 ; i < list -> children ; i ++ ) {
1946
1946
if (i != 0 ) {
1947
1947
smart_str_appendc (str , '&' );
@@ -1956,15 +1956,15 @@ static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int in
1956
1956
zend_ast_export_ns_name (str , ast , 0 , indent );
1957
1957
}
1958
1958
1959
- static ZEND_COLD void zend_ast_export_hook_list (smart_str * str , zend_ast_list * hook_list , int indent )
1959
+ static ZEND_COLD void zend_ast_export_hook_list (smart_str * str , const zend_ast_list * hook_list , int indent )
1960
1960
{
1961
1961
smart_str_appends (str , " {" );
1962
1962
smart_str_appendc (str , '\n' );
1963
1963
indent ++ ;
1964
1964
zend_ast_export_indent (str , indent );
1965
1965
1966
1966
for (uint32_t i = 0 ; i < hook_list -> children ; i ++ ) {
1967
- zend_ast_decl * hook = (zend_ast_decl * )hook_list -> child [i ];
1967
+ const zend_ast_decl * hook = (const zend_ast_decl * )hook_list -> child [i ];
1968
1968
zend_ast_export_visibility (str , hook -> flags , ZEND_MODIFIER_TARGET_PROPERTY );
1969
1969
if (hook -> flags & ZEND_ACC_FINAL ) {
1970
1970
smart_str_appends (str , "final " );
0 commit comments