@@ -100,14 +100,16 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(zend_string *name, ze
100100 return (zend_ast * ) ast ;
101101}
102102
103- ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_op_array (zend_op_array * op_array , zend_ast * original_ast , zend_ast_attr attr ) {
103+ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_op_array (zend_op_array * op_array , zend_string * original_ast ) {
104104 zend_ast_op_array * ast ;
105105
106106 ast = zend_ast_alloc (sizeof (zend_ast_op_array ));
107107 ast -> kind = ZEND_AST_OP_ARRAY ;
108- ast -> attr = attr ;
108+ ast -> attr = 0 ;
109+ ast -> lineno = CG (zend_lineno );
109110 ast -> op_array = op_array ;
110- ast -> ast = original_ast ;
111+ ZEND_ASSERT (ZSTR_IS_INTERNED (original_ast ));
112+ ast -> original_ast = original_ast ;
111113
112114 return (zend_ast * ) ast ;
113115}
@@ -1091,7 +1093,7 @@ static size_t ZEND_FASTCALL zend_ast_tree_size(zend_ast *ast)
10911093 if (ast -> kind == ZEND_AST_ZVAL || ast -> kind == ZEND_AST_CONSTANT ) {
10921094 size = sizeof (zend_ast_zval );
10931095 } else if (ast -> kind == ZEND_AST_OP_ARRAY ) {
1094- size = sizeof (zend_ast_op_array ) + zend_ast_tree_size ( zend_ast_get_op_array ( ast ) -> ast ) ;
1096+ size = sizeof (zend_ast_op_array );
10951097 } else if (zend_ast_is_list (ast )) {
10961098 uint32_t i ;
10971099 zend_ast_list * list = zend_ast_get_list (ast );
@@ -1103,13 +1105,8 @@ static size_t ZEND_FASTCALL zend_ast_tree_size(zend_ast *ast)
11031105 }
11041106 }
11051107 } else if (zend_ast_is_decl (ast )) {
1106- zend_ast_decl * decl = (zend_ast_decl * )ast ;
1107- size = sizeof (zend_ast_decl );
1108- for (size_t i = 0 ; i < 5 ; i ++ ) {
1109- if (decl -> child [i ]) {
1110- size += zend_ast_tree_size (decl -> child [i ]);
1111- }
1112- }
1108+ /* Not implemented. */
1109+ ZEND_UNREACHABLE ();
11131110 } else {
11141111 uint32_t i , children = zend_ast_get_num_children (ast );
11151112
@@ -1161,38 +1158,13 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
11611158 zend_ast_op_array * new = (zend_ast_op_array * )buf ;
11621159 new -> kind = old -> kind ;
11631160 new -> attr = old -> attr ;
1161+ new -> lineno = old -> lineno ;
11641162 new -> op_array = old -> op_array ;
1163+ new -> original_ast = old -> original_ast ;
11651164 buf = (void * )((char * )buf + sizeof (zend_ast_op_array ));
1166- new -> ast = (zend_ast * )buf ;
1167- buf = zend_ast_tree_copy (old -> ast , buf );
11681165 } else if (zend_ast_is_decl (ast )) {
1169- zend_ast_decl * old = (zend_ast_decl * )ast ;
1170- zend_ast_decl * new = (zend_ast_decl * )buf ;
1171- new -> kind = old -> kind ;
1172- new -> attr = old -> attr ;
1173- new -> start_lineno = old -> start_lineno ;
1174- new -> end_lineno = old -> end_lineno ;
1175- new -> flags = old -> flags ;
1176- if (old -> doc_comment ) {
1177- new -> doc_comment = zend_string_copy (old -> doc_comment );
1178- } else {
1179- new -> doc_comment = NULL ;
1180- }
1181- if (old -> name ) {
1182- new -> name = zend_string_copy (old -> name );
1183- } else {
1184- new -> name = NULL ;
1185- }
1186-
1187- buf = (void * )((char * )buf + sizeof (zend_ast_decl ));
1188- for (size_t i = 0 ; i < 5 ; i ++ ) {
1189- if (old -> child [i ]) {
1190- new -> child [i ] = (zend_ast * )buf ;
1191- buf = zend_ast_tree_copy (old -> child [i ], buf );
1192- } else {
1193- new -> child [i ] = NULL ;
1194- }
1195- }
1166+ /* Not implemented. */
1167+ ZEND_UNREACHABLE ();
11961168 } else {
11971169 uint32_t i , children = zend_ast_get_num_children (ast );
11981170 zend_ast * new = (zend_ast * )buf ;
@@ -1257,8 +1229,8 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast)
12571229 } else if (EXPECTED (ast -> kind == ZEND_AST_CONSTANT )) {
12581230 zend_string_release_ex (zend_ast_get_constant_name (ast ), 0 );
12591231 } else if (EXPECTED (ast -> kind == ZEND_AST_OP_ARRAY )) {
1260- zend_ast_destroy (zend_ast_get_op_array (ast )-> ast );
1261- } else if (zend_ast_is_decl (ast )) {
1232+ zend_string_release_ex (zend_ast_get_op_array (ast )-> original_ast , 0 );
1233+ } else if (EXPECTED ( zend_ast_is_decl (ast ) )) {
12621234 zend_ast_decl * decl = (zend_ast_decl * ) ast ;
12631235
12641236 if (decl -> name ) {
@@ -1875,10 +1847,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
18751847 smart_str_appendl (str , ZSTR_VAL (name ), ZSTR_LEN (name ));
18761848 break ;
18771849 }
1878- case ZEND_AST_OP_ARRAY : {
1879- zend_ast_export_ex (str , zend_ast_get_op_array (ast )-> ast , priority , indent );
1850+ case ZEND_AST_OP_ARRAY :
1851+ smart_str_append (str , zend_ast_get_op_array (ast )-> original_ast );
18801852 break ;
1881- }
18821853 case ZEND_AST_CONSTANT_CLASS :
18831854 smart_str_appendl (str , "__CLASS__" , sizeof ("__CLASS__" )- 1 );
18841855 break ;
0 commit comments