Lines Matching refs:ast
47 zend_ast_znode *ast; in zend_ast_create_znode() local
49 ast = zend_ast_alloc(sizeof(zend_ast_znode)); in zend_ast_create_znode()
50 ast->kind = ZEND_AST_ZNODE; in zend_ast_create_znode()
51 ast->attr = 0; in zend_ast_create_znode()
52 ast->lineno = CG(zend_lineno); in zend_ast_create_znode()
53 ast->node = *node; in zend_ast_create_znode()
54 return (zend_ast *) ast; in zend_ast_create_znode()
58 zend_ast_zval *ast; in zend_ast_create_zval_int() local
60 ast = zend_ast_alloc(sizeof(zend_ast_zval)); in zend_ast_create_zval_int()
61 ast->kind = ZEND_AST_ZVAL; in zend_ast_create_zval_int()
62 ast->attr = attr; in zend_ast_create_zval_int()
63 ZVAL_COPY_VALUE(&ast->val, zv); in zend_ast_create_zval_int()
64 Z_LINENO(ast->val) = lineno; in zend_ast_create_zval_int()
65 return (zend_ast *) ast; in zend_ast_create_zval_int()
93 zend_ast_zval *ast; in zend_ast_create_constant() local
95 ast = zend_ast_alloc(sizeof(zend_ast_zval)); in zend_ast_create_constant()
96 ast->kind = ZEND_AST_CONSTANT; in zend_ast_create_constant()
97 ast->attr = attr; in zend_ast_create_constant()
98 ZVAL_STR(&ast->val, name); in zend_ast_create_constant()
99 Z_LINENO(ast->val) = CG(zend_lineno); in zend_ast_create_constant()
100 return (zend_ast *) ast; in zend_ast_create_constant()
117 zend_ast_decl *ast; in zend_ast_create_decl() local
119 ast = zend_ast_alloc(sizeof(zend_ast_decl)); in zend_ast_create_decl()
120 ast->kind = kind; in zend_ast_create_decl()
121 ast->attr = 0; in zend_ast_create_decl()
122 ast->start_lineno = start_lineno; in zend_ast_create_decl()
123 ast->end_lineno = CG(zend_lineno); in zend_ast_create_decl()
124 ast->flags = flags; in zend_ast_create_decl()
125 ast->doc_comment = doc_comment; in zend_ast_create_decl()
126 ast->name = name; in zend_ast_create_decl()
127 ast->child[0] = child0; in zend_ast_create_decl()
128 ast->child[1] = child1; in zend_ast_create_decl()
129 ast->child[2] = child2; in zend_ast_create_decl()
130 ast->child[3] = child3; in zend_ast_create_decl()
131 ast->child[4] = child4; in zend_ast_create_decl()
133 return (zend_ast *) ast; in zend_ast_create_decl()
138 zend_ast *ast; in zend_ast_create_0() local
141 ast = zend_ast_alloc(zend_ast_size(0)); in zend_ast_create_0()
142 ast->kind = kind; in zend_ast_create_0()
143 ast->attr = 0; in zend_ast_create_0()
144 ast->lineno = CG(zend_lineno); in zend_ast_create_0()
146 return ast; in zend_ast_create_0()
150 zend_ast *ast; in zend_ast_create_1() local
154 ast = zend_ast_alloc(zend_ast_size(1)); in zend_ast_create_1()
155 ast->kind = kind; in zend_ast_create_1()
156 ast->attr = 0; in zend_ast_create_1()
157 ast->child[0] = child; in zend_ast_create_1()
163 ast->lineno = lineno; in zend_ast_create_1()
165 return ast; in zend_ast_create_1()
169 zend_ast *ast; in zend_ast_create_2() local
173 ast = zend_ast_alloc(zend_ast_size(2)); in zend_ast_create_2()
174 ast->kind = kind; in zend_ast_create_2()
175 ast->attr = 0; in zend_ast_create_2()
176 ast->child[0] = child1; in zend_ast_create_2()
177 ast->child[1] = child2; in zend_ast_create_2()
185 ast->lineno = lineno; in zend_ast_create_2()
187 return ast; in zend_ast_create_2()
191 zend_ast *ast; in zend_ast_create_3() local
195 ast = zend_ast_alloc(zend_ast_size(3)); in zend_ast_create_3()
196 ast->kind = kind; in zend_ast_create_3()
197 ast->attr = 0; in zend_ast_create_3()
198 ast->child[0] = child1; in zend_ast_create_3()
199 ast->child[1] = child2; in zend_ast_create_3()
200 ast->child[2] = child3; in zend_ast_create_3()
210 ast->lineno = lineno; in zend_ast_create_3()
212 return ast; in zend_ast_create_3()
216 zend_ast *ast; in zend_ast_create_4() local
220 ast = zend_ast_alloc(zend_ast_size(4)); in zend_ast_create_4()
221 ast->kind = kind; in zend_ast_create_4()
222 ast->attr = 0; in zend_ast_create_4()
223 ast->child[0] = child1; in zend_ast_create_4()
224 ast->child[1] = child2; in zend_ast_create_4()
225 ast->child[2] = child3; in zend_ast_create_4()
226 ast->child[3] = child4; in zend_ast_create_4()
238 ast->lineno = lineno; in zend_ast_create_4()
240 return ast; in zend_ast_create_4()
244 zend_ast *ast; in zend_ast_create_5() local
248 ast = zend_ast_alloc(zend_ast_size(5)); in zend_ast_create_5()
249 ast->kind = kind; in zend_ast_create_5()
250 ast->attr = 0; in zend_ast_create_5()
251 ast->child[0] = child1; in zend_ast_create_5()
252 ast->child[1] = child2; in zend_ast_create_5()
253 ast->child[2] = child3; in zend_ast_create_5()
254 ast->child[3] = child4; in zend_ast_create_5()
255 ast->child[4] = child5; in zend_ast_create_5()
269 ast->lineno = lineno; in zend_ast_create_5()
271 return ast; in zend_ast_create_5()
278 zend_ast *ast = zend_ast_alloc(zend_ast_size(children)); in zend_ast_create_va() local
279 ast->kind = kind; in zend_ast_create_va()
280 ast->attr = attr; in zend_ast_create_va()
282 ast->child[i] = va_arg(*va, zend_ast *); in zend_ast_create_va()
283 if (lineno != (uint32_t)-1 && ast->child[i]) { in zend_ast_create_va()
284 lineno = zend_ast_get_lineno(ast->child[i]); in zend_ast_create_va()
290 ast->lineno = lineno; in zend_ast_create_va()
291 return ast; in zend_ast_create_va()
297 zend_ast *ast = zend_ast_create_va(kind, 0, &va); in zend_ast_create_n() local
299 return ast; in zend_ast_create_n()
306 zend_ast *ast = zend_ast_create_va(kind, attr, &va); in zend_ast_create_ex_n() local
308 return ast; in zend_ast_create_ex_n()
312 zend_ast *ast; in zend_ast_create_list_0() local
315 ast = zend_ast_alloc(zend_ast_list_size(4)); in zend_ast_create_list_0()
316 list = (zend_ast_list *) ast; in zend_ast_create_list_0()
322 return ast; in zend_ast_create_list_0()
326 zend_ast *ast; in zend_ast_create_list_1() local
330 ast = zend_ast_alloc(zend_ast_list_size(4)); in zend_ast_create_list_1()
331 list = (zend_ast_list *) ast; in zend_ast_create_list_1()
346 return ast; in zend_ast_create_list_1()
350 zend_ast *ast; in zend_ast_create_list_2() local
354 ast = zend_ast_alloc(zend_ast_list_size(4)); in zend_ast_create_list_2()
355 list = (zend_ast_list *) ast; in zend_ast_create_list_2()
377 return ast; in zend_ast_create_list_2()
382 zend_ast *ast; in zend_ast_create_from_va_list() local
384 ast = zend_ast_alloc(zend_ast_size(children)); in zend_ast_create_from_va_list()
385 ast->kind = kind; in zend_ast_create_from_va_list()
386 ast->attr = attr; in zend_ast_create_from_va_list()
387 ast->lineno = (uint32_t) -1; in zend_ast_create_from_va_list()
390 ast->child[i] = va_arg(va, zend_ast *); in zend_ast_create_from_va_list()
391 if (ast->child[i] != NULL) { in zend_ast_create_from_va_list()
392 uint32_t lineno = zend_ast_get_lineno(ast->child[i]); in zend_ast_create_from_va_list()
393 if (lineno < ast->lineno) { in zend_ast_create_from_va_list()
394 ast->lineno = lineno; in zend_ast_create_from_va_list()
399 if (ast->lineno == UINT_MAX) { in zend_ast_create_from_va_list()
400 ast->lineno = CG(zend_lineno); in zend_ast_create_from_va_list()
403 return ast; in zend_ast_create_from_va_list()
408 zend_ast *ast; in zend_ast_create_ex() local
411 ast = zend_ast_create_from_va_list(kind, attr, va); in zend_ast_create_ex()
414 return ast; in zend_ast_create_ex()
419 zend_ast *ast; in zend_ast_create() local
422 ast = zend_ast_create_from_va_list(kind, 0, va); in zend_ast_create()
425 return ast; in zend_ast_create()
429 zend_ast *ast; in zend_ast_create_list() local
432 ast = zend_ast_alloc(zend_ast_list_size(4)); in zend_ast_create_list()
433 list = (zend_ast_list *) ast; in zend_ast_create_list()
445 ast = zend_ast_list_add(ast, child); in zend_ast_create_list()
448 if (lineno < ast->lineno) { in zend_ast_create_list()
449 ast->lineno = lineno; in zend_ast_create_list()
456 return ast; in zend_ast_create_list()
477 ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *ast, zend_ast *op) { in zend_ast_list_add() argument
478 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_list_add()
532 static zend_class_entry *zend_ast_fetch_class(zend_ast *ast, zend_class_entry *scope) in zend_ast_fetch_class() argument
534 …return zend_fetch_class_with_scope(zend_ast_get_str(ast), (ast->attr >> ZEND_CONST_EXPR_NEW_FETCH_… in zend_ast_fetch_class()
539 zend_ast *ast,
547 zend_ast *ast, in zend_ast_evaluate_ex() argument
558 EG(lineno_override) = zend_ast_get_lineno(ast); in zend_ast_evaluate_ex()
560 zend_result r = zend_ast_evaluate_inner(result, ast, scope, short_circuited_ptr, ctx); in zend_ast_evaluate_ex()
570 zend_ast *ast, in zend_ast_evaluate_inner() argument
580 switch (ast->kind) { in zend_ast_evaluate_inner()
582 …if (UNEXPECTED(zend_ast_evaluate_ex(&op1, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
584 …} else if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[1], scope, &short_circuited, ctx) != S… in zend_ast_evaluate_inner()
588 binary_op_type op = get_binary_op(ast->attr); in zend_ast_evaluate_inner()
596 …if (UNEXPECTED(zend_ast_evaluate_ex(&op1, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
598 …} else if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[1], scope, &short_circuited, ctx) != S… in zend_ast_evaluate_inner()
603 binary_op_type op = ast->kind == ZEND_AST_GREATER in zend_ast_evaluate_inner()
611 …if (UNEXPECTED(zend_ast_evaluate_ex(&op1, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
614 unary_op_type op = get_unary_op(ast->attr); in zend_ast_evaluate_inner()
621 zval *zv = zend_ast_get_zval(ast); in zend_ast_evaluate_inner()
628 zend_string *name = zend_ast_get_constant_name(ast); in zend_ast_evaluate_inner()
629 zval *zv = zend_get_constant_ex(name, scope, ast->attr); in zend_ast_evaluate_inner()
650 if (ast->attr == ZEND_FETCH_CLASS_SELF) { in zend_ast_evaluate_inner()
652 } else if (ast->attr == ZEND_FETCH_CLASS_PARENT) { in zend_ast_evaluate_inner()
664 …if (UNEXPECTED(zend_ast_evaluate_ex(&op1, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
669 …if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[1], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
682 …if (UNEXPECTED(zend_ast_evaluate_ex(&op1, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
689 …if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[1], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
700 …if (UNEXPECTED(zend_ast_evaluate_ex(&op1, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
705 if (!ast->child[1]) { in zend_ast_evaluate_inner()
708 …if (UNEXPECTED(zend_ast_evaluate_ex(result, ast->child[1], scope, &short_circuited, ctx) != SUCCES… in zend_ast_evaluate_inner()
716 …if (UNEXPECTED(zend_ast_evaluate_ex(result, ast->child[2], scope, &short_circuited, ctx) != SUCCES… in zend_ast_evaluate_inner()
725 …if (UNEXPECTED(zend_ast_evaluate_ex(&op1, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
732 …if (UNEXPECTED(zend_ast_evaluate_ex(result, ast->child[1], scope, &short_circuited, ctx) != SUCCES… in zend_ast_evaluate_inner()
741 …if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
750 …if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
761 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_evaluate_inner()
806 if (ast->child[1] == NULL) { in zend_ast_evaluate_inner()
810 …if (UNEXPECTED(zend_ast_evaluate_ex(&op1, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
828 …if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[1], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
834 zend_fetch_dimension_const(result, &op1, &op2, (ast->attr & ZEND_DIM_IS) ? BP_VAR_IS : BP_VAR_R); in zend_ast_evaluate_inner()
851 zend_ast *class_name_ast = ast->child[0]; in zend_ast_evaluate_inner()
854 zend_ast *case_name_ast = ast->child[1]; in zend_ast_evaluate_inner()
857 zend_ast *case_value_ast = ast->child[2]; in zend_ast_evaluate_inner()
874 zend_string *class_name = zend_ast_get_str(ast->child[0]); in zend_ast_evaluate_inner()
875 …if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[1], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
891 EG(lineno_override) = zend_ast_get_lineno(ast); in zend_ast_evaluate_inner()
893 zval *zv = zend_get_class_constant_ex(class_name, const_name, scope, ast->attr); in zend_ast_evaluate_inner()
910 zend_class_entry *ce = zend_ast_fetch_class(ast->child[0], scope); in zend_ast_evaluate_inner()
922 zend_ast_list *args_ast = zend_ast_get_list(ast->child[1]); in zend_ast_evaluate_inner()
995 zend_function *func = Z_PTR_P(&((zend_ast_zval*)(ast))->val); in zend_ast_evaluate_inner()
1003 …if (UNEXPECTED(zend_ast_evaluate_ex(&op1, ast->child[0], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
1011 if (ast->kind == ZEND_AST_NULLSAFE_PROP && Z_TYPE(op1) == IS_NULL) { in zend_ast_evaluate_inner()
1017 …if (UNEXPECTED(zend_ast_evaluate_ex(&op2, ast->child[1], scope, &short_circuited, ctx) != SUCCESS)… in zend_ast_evaluate_inner()
1068 ZEND_API zend_result ZEND_FASTCALL zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry … in zend_ast_evaluate() argument
1072 return zend_ast_evaluate_ex(result, ast, scope, &short_circuited, &ctx); in zend_ast_evaluate()
1075 static size_t ZEND_FASTCALL zend_ast_tree_size(zend_ast *ast) in zend_ast_tree_size() argument
1079 …if (ast->kind == ZEND_AST_ZVAL || ast->kind == ZEND_AST_CONSTANT || ast->kind == ZEND_AST_OP_ARRAY… in zend_ast_tree_size()
1081 } else if (zend_ast_is_list(ast)) { in zend_ast_tree_size()
1083 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_tree_size()
1092 uint32_t i, children = zend_ast_get_num_children(ast); in zend_ast_tree_size()
1096 if (ast->child[i]) { in zend_ast_tree_size()
1097 size += zend_ast_tree_size(ast->child[i]); in zend_ast_tree_size()
1104 static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf) in zend_ast_tree_copy() argument
1106 if (ast->kind == ZEND_AST_ZVAL) { in zend_ast_tree_copy()
1109 new->attr = ast->attr; in zend_ast_tree_copy()
1110 ZVAL_COPY(&new->val, zend_ast_get_zval(ast)); in zend_ast_tree_copy()
1111 Z_LINENO(new->val) = zend_ast_get_lineno(ast); in zend_ast_tree_copy()
1113 } else if (ast->kind == ZEND_AST_CONSTANT) { in zend_ast_tree_copy()
1116 new->attr = ast->attr; in zend_ast_tree_copy()
1117 ZVAL_STR_COPY(&new->val, zend_ast_get_constant_name(ast)); in zend_ast_tree_copy()
1118 Z_LINENO(new->val) = zend_ast_get_lineno(ast); in zend_ast_tree_copy()
1120 } else if (zend_ast_is_list(ast)) { in zend_ast_tree_copy()
1121 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_tree_copy()
1137 } else if (ast->kind == ZEND_AST_OP_ARRAY) { in zend_ast_tree_copy()
1140 new->attr = ast->attr; in zend_ast_tree_copy()
1141 ZVAL_COPY(&new->val, &((zend_ast_zval *) ast)->val); in zend_ast_tree_copy()
1142 Z_LINENO(new->val) = zend_ast_get_lineno(ast); in zend_ast_tree_copy()
1145 uint32_t i, children = zend_ast_get_num_children(ast); in zend_ast_tree_copy()
1147 new->kind = ast->kind; in zend_ast_tree_copy()
1148 new->attr = ast->attr; in zend_ast_tree_copy()
1149 new->lineno = ast->lineno; in zend_ast_tree_copy()
1152 if (ast->child[i]) { in zend_ast_tree_copy()
1154 buf = zend_ast_tree_copy(ast->child[i], buf); in zend_ast_tree_copy()
1163 ZEND_API zend_ast_ref * ZEND_FASTCALL zend_ast_copy(zend_ast *ast) in zend_ast_copy() argument
1168 ZEND_ASSERT(ast != NULL); in zend_ast_copy()
1169 tree_size = zend_ast_tree_size(ast) + sizeof(zend_ast_ref); in zend_ast_copy()
1171 zend_ast_tree_copy(ast, GC_AST(ref)); in zend_ast_copy()
1177 ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast) in zend_ast_destroy() argument
1180 if (!ast) { in zend_ast_destroy()
1184 if (EXPECTED(ast->kind >= ZEND_AST_VAR)) { in zend_ast_destroy()
1185 uint32_t i, children = zend_ast_get_num_children(ast); in zend_ast_destroy()
1188 zend_ast_destroy(ast->child[i]); in zend_ast_destroy()
1190 ast = ast->child[0]; in zend_ast_destroy()
1192 } else if (EXPECTED(ast->kind == ZEND_AST_ZVAL)) { in zend_ast_destroy()
1193 zval_ptr_dtor_nogc(zend_ast_get_zval(ast)); in zend_ast_destroy()
1194 } else if (EXPECTED(zend_ast_is_list(ast))) { in zend_ast_destroy()
1195 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_destroy()
1202 ast = list->child[0]; in zend_ast_destroy()
1205 } else if (EXPECTED(ast->kind == ZEND_AST_CONSTANT)) { in zend_ast_destroy()
1206 zend_string_release_ex(zend_ast_get_constant_name(ast), 0); in zend_ast_destroy()
1207 } else if (EXPECTED(ast->kind == ZEND_AST_OP_ARRAY)) { in zend_ast_destroy()
1208 ZEND_ASSERT(!Z_REFCOUNTED(((zend_ast_zval*)(ast))->val)); in zend_ast_destroy()
1209 } else if (EXPECTED(ast->kind >= ZEND_AST_FUNC_DECL)) { in zend_ast_destroy()
1210 zend_ast_decl *decl = (zend_ast_decl *) ast; in zend_ast_destroy()
1222 ast = decl->child[4]; in zend_ast_destroy()
1227 ZEND_API void ZEND_FASTCALL zend_ast_ref_destroy(zend_ast_ref *ast) in zend_ast_ref_destroy() argument
1229 zend_ast_destroy(GC_AST(ast)); in zend_ast_ref_destroy()
1230 efree(ast); in zend_ast_ref_destroy()
1233 ZEND_API void zend_ast_apply(zend_ast *ast, zend_ast_apply_func fn, void *context) { in zend_ast_apply() argument
1234 if (zend_ast_is_list(ast)) { in zend_ast_apply()
1235 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_apply()
1241 uint32_t i, children = zend_ast_get_num_children(ast); in zend_ast_apply()
1243 fn(&ast->child[i], context); in zend_ast_apply()
1284 static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int priority, int indent);
1354 static ZEND_COLD void zend_ast_export_name(smart_str *str, zend_ast *ast, int priority, int indent) in zend_ast_export_name() argument
1356 if (ast->kind == ZEND_AST_ZVAL) { in zend_ast_export_name()
1357 zval *zv = zend_ast_get_zval(ast); in zend_ast_export_name()
1364 zend_ast_export_ex(str, ast, priority, indent); in zend_ast_export_name()
1367 static ZEND_COLD void zend_ast_export_ns_name(smart_str *str, zend_ast *ast, int priority, int inde… in zend_ast_export_ns_name() argument
1369 if (ast->kind == ZEND_AST_ZVAL) { in zend_ast_export_ns_name()
1370 zval *zv = zend_ast_get_zval(ast); in zend_ast_export_ns_name()
1373 if (ast->attr == ZEND_NAME_FQ) { in zend_ast_export_ns_name()
1375 } else if (ast->attr == ZEND_NAME_RELATIVE) { in zend_ast_export_ns_name()
1382 zend_ast_export_ex(str, ast, priority, indent); in zend_ast_export_ns_name()
1429 static ZEND_COLD void zend_ast_export_var(smart_str *str, zend_ast *ast, int priority, int indent) in zend_ast_export_var() argument
1431 if (ast->kind == ZEND_AST_ZVAL) { in zend_ast_export_var()
1432 zval *zv = zend_ast_get_zval(ast); in zend_ast_export_var()
1438 } else if (ast->kind == ZEND_AST_VAR) { in zend_ast_export_var()
1439 zend_ast_export_ex(str, ast, 0, indent); in zend_ast_export_var()
1443 zend_ast_export_name(str, ast, 0, indent); in zend_ast_export_var()
1463 zend_ast *ast; in zend_ast_export_encaps_list() local
1466 ast = list->child[i]; in zend_ast_export_encaps_list()
1467 if (ast->kind == ZEND_AST_ZVAL) { in zend_ast_export_encaps_list()
1468 zval *zv = zend_ast_get_zval(ast); in zend_ast_export_encaps_list()
1472 } else if (ast->kind == ZEND_AST_VAR && in zend_ast_export_encaps_list()
1473 ast->child[0]->kind == ZEND_AST_ZVAL && in zend_ast_export_encaps_list()
1479 zend_ast_export_ex(str, ast, 0, indent); in zend_ast_export_encaps_list()
1482 zend_ast_export_ex(str, ast, 0, indent); in zend_ast_export_encaps_list()
1522 static ZEND_COLD void zend_ast_export_stmt(smart_str *str, zend_ast *ast, int indent) in zend_ast_export_stmt() argument
1524 if (!ast) { in zend_ast_export_stmt()
1528 if (ast->kind == ZEND_AST_STMT_LIST || in zend_ast_export_stmt()
1529 ast->kind == ZEND_AST_TRAIT_ADAPTATIONS) { in zend_ast_export_stmt()
1530 zend_ast_list *list = (zend_ast_list*)ast; in zend_ast_export_stmt()
1534 ast = list->child[i]; in zend_ast_export_stmt()
1535 zend_ast_export_stmt(str, ast, indent); in zend_ast_export_stmt()
1540 zend_ast_export_ex(str, ast, 0, indent); in zend_ast_export_stmt()
1541 switch (ast->kind) { in zend_ast_export_stmt()
1557 zend_ast *first_prop = zend_ast_get_list(ast->child[1])->child[0]; in zend_ast_export_stmt()
1575 zend_ast *ast; in zend_ast_export_if_stmt() local
1580 ast = list->child[i]; in zend_ast_export_if_stmt()
1581 ZEND_ASSERT(ast->kind == ZEND_AST_IF_ELEM); in zend_ast_export_if_stmt()
1582 if (ast->child[0]) { in zend_ast_export_if_stmt()
1589 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_if_stmt()
1591 zend_ast_export_stmt(str, ast->child[1], indent + 1); in zend_ast_export_if_stmt()
1595 if (ast->child[1] && ast->child[1]->kind == ZEND_AST_IF) { in zend_ast_export_if_stmt()
1596 list = (zend_ast_list*)ast->child[1]; in zend_ast_export_if_stmt()
1600 zend_ast_export_stmt(str, ast->child[1], indent + 1); in zend_ast_export_if_stmt()
1681 static ZEND_COLD void zend_ast_export_attribute_group(smart_str *str, zend_ast *ast, int indent) { in zend_ast_export_attribute_group() argument
1682 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_export_attribute_group()
1699 static ZEND_COLD void zend_ast_export_attributes(smart_str *str, zend_ast *ast, int indent, bool ne… in zend_ast_export_attributes() argument
1700 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_export_attributes()
1737 static ZEND_COLD void zend_ast_export_type(smart_str *str, zend_ast *ast, int indent) { in zend_ast_export_type() argument
1738 if (ast->kind == ZEND_AST_TYPE_UNION) { in zend_ast_export_type()
1739 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_export_type()
1748 if (ast->kind == ZEND_AST_TYPE_INTERSECTION) { in zend_ast_export_type()
1749 zend_ast_list *list = zend_ast_get_list(ast); in zend_ast_export_type()
1758 if (ast->attr & ZEND_TYPE_NULLABLE) { in zend_ast_export_type()
1761 zend_ast_export_ns_name(str, ast, 0, indent); in zend_ast_export_type()
1844 static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int priority, int indent) in zend_ast_export_ex() argument
1851 if (!ast) { in zend_ast_export_ex()
1854 switch (ast->kind) { in zend_ast_export_ex()
1857 zend_ast_export_zval(str, zend_ast_get_zval(ast), priority, indent); in zend_ast_export_ex()
1860 zend_string *name = zend_ast_get_constant_name(ast); in zend_ast_export_ex()
1877 decl = (zend_ast_decl *) ast; in zend_ast_export_ex()
1879 bool newlines = !(ast->kind == ZEND_AST_CLOSURE || ast->kind == ZEND_AST_ARROW_FUNC); in zend_ast_export_ex()
1902 if (ast->kind != ZEND_AST_CLOSURE && ast->kind != ZEND_AST_ARROW_FUNC) { in zend_ast_export_ex()
1928 if (ast->kind != ZEND_AST_CLOSURE) { in zend_ast_export_ex()
1936 decl = (zend_ast_decl *) ast; in zend_ast_export_ex()
1972 zend_ast_export_list(str, (zend_ast_list*)ast, 1, 20, indent); in zend_ast_export_ex()
1976 zend_ast_export_list(str, (zend_ast_list*)ast, 1, 20, indent); in zend_ast_export_ex()
1981 zend_ast_export_encaps_list(str, '"', (zend_ast_list*)ast, indent); in zend_ast_export_ex()
1986 zend_ast_export_stmt(str, ast, indent); in zend_ast_export_ex()
1989 zend_ast_export_if_stmt(str, (zend_ast_list*)ast, indent); in zend_ast_export_ex()
1994 zend_ast_export_list(str, (zend_ast_list*)ast, 0, 0, indent); in zend_ast_export_ex()
1998 zend_ast_export_var_list(str, (zend_ast_list*)ast, indent); in zend_ast_export_ex()
2002 zend_ast *type_ast = ast->child[0]; in zend_ast_export_ex()
2003 zend_ast *prop_ast = ast->child[1]; in zend_ast_export_ex()
2005 if (ast->child[2]) { in zend_ast_export_ex()
2006 zend_ast_export_attributes(str, ast->child[2], indent, 1); in zend_ast_export_ex()
2009 zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_PROPERTY); in zend_ast_export_ex()
2011 if (ast->attr & ZEND_ACC_STATIC) { in zend_ast_export_ex()
2014 if (ast->attr & ZEND_ACC_READONLY) { in zend_ast_export_ex()
2023 ast = prop_ast; in zend_ast_export_ex()
2031 if (ast->child[1]) { in zend_ast_export_ex()
2032 zend_ast_export_attributes(str, ast->child[1], indent, 1); in zend_ast_export_ex()
2035 zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_CONSTANT); in zend_ast_export_ex()
2037 if (ast->child[2]) { in zend_ast_export_ex()
2038 zend_ast_export_type(str, ast->child[2], indent); in zend_ast_export_ex()
2042 ast = ast->child[0]; in zend_ast_export_ex()
2046 zend_ast_export_name_list(str, (zend_ast_list*)ast, indent); in zend_ast_export_ex()
2050 if (ast->attr == T_FUNCTION) { in zend_ast_export_ex()
2052 } else if (ast->attr == T_CONST) { in zend_ast_export_ex()
2059 switch (ast->attr) { in zend_ast_export_ex()
2073 switch (ast->attr & ~ZEND_TYPE_NULLABLE) { in zend_ast_export_ex()
2085 zend_ast_export_var(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2088 zend_ast_export_ns_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2092 ast = ast->child[0]; in zend_ast_export_ex()
2097 switch (ast->attr) { in zend_ast_export_ex()
2116 if (ast->child[0]->kind == ZEND_AST_ENCAPS_LIST) { in zend_ast_export_ex()
2117 zend_ast_export_encaps_list(str, '`', (zend_ast_list*)ast->child[0], indent); in zend_ast_export_ex()
2120 ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_ZVAL); in zend_ast_export_ex()
2121 zv = zend_ast_get_zval(ast->child[0]); in zend_ast_export_ex()
2130 if (ast->child[0]) { in zend_ast_export_ex()
2139 switch (ast->attr) { in zend_ast_export_ex()
2149 switch (ast->attr) { in zend_ast_export_ex()
2171 zend_ast_export_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2176 ast = ast->child[0]; in zend_ast_export_ex()
2186 zend_ast_export_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2195 zend_ast_export_ex(str, ast->child[0], 260, indent); in zend_ast_export_ex()
2197 if (ast->child[1]) { in zend_ast_export_ex()
2198 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2204 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2205 smart_str_appends(str, ast->kind == ZEND_AST_NULLSAFE_PROP ? "?->" : "->"); in zend_ast_export_ex()
2206 zend_ast_export_var(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2209 zend_ast_export_ns_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2211 zend_ast_export_var(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2214 zend_ast_export_ns_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2216 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2220 smart_str_append(str, Z_STR_P(zend_ast_get_zval(ast->child[0]))); in zend_ast_export_ex()
2222 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2229 zend_ast_export_ns_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2231 zend_ast_export_name(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2234 if (ast->child[0] == NULL) { in zend_ast_export_ex()
2236 switch (ast->attr) { in zend_ast_export_ex()
2246 zend_ast_export_ns_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2253 switch (ast->attr) { in zend_ast_export_ex()
2271 switch (ast->attr) { in zend_ast_export_ex()
2300 if (ast->child[1]) { in zend_ast_export_ex()
2301 zend_ast_export_ex(str, ast->child[1], 80, indent); in zend_ast_export_ex()
2304 if (ast->attr) in zend_ast_export_ex()
2306 zend_ast_export_ex(str, ast->child[0], 80, indent); in zend_ast_export_ex()
2310 if (ast->child[0]->kind == ZEND_AST_CLASS) { in zend_ast_export_ex()
2311 zend_ast_decl *decl = (zend_ast_decl *) ast->child[0]; in zend_ast_export_ex()
2316 if (!zend_ast_is_list(ast->child[1]) in zend_ast_export_ex()
2317 || zend_ast_get_list(ast->child[1])->children) { in zend_ast_export_ex()
2319 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2324 zend_ast_export_ns_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2326 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2331 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2333 zend_ast_export_ns_name(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2338 if (ast->child[0]) { in zend_ast_export_ex()
2339 if (ast->child[1]) { in zend_ast_export_ex()
2340 zend_ast_export_ex(str, ast->child[1], 70, indent); in zend_ast_export_ex()
2343 zend_ast_export_ex(str, ast->child[0], 70, indent); in zend_ast_export_ex()
2352 zend_ast_export_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2356 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2358 zend_ast_export_stmt(str, ast->child[1], indent + 1); in zend_ast_export_ex()
2364 zend_ast_export_stmt(str, ast->child[0], indent + 1); in zend_ast_export_ex()
2367 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2372 if (ast->child[0]) { in zend_ast_export_ex()
2374 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2376 zend_ast_export_stmt(str, ast->child[1], indent + 1); in zend_ast_export_ex()
2379 zend_ast_export_stmt(str, ast->child[1], indent + 1); in zend_ast_export_ex()
2386 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2388 zend_ast_export_ex(str, ast->child[1], 0, indent + 1); in zend_ast_export_ex()
2394 if (ast->child[0]) { in zend_ast_export_ex()
2396 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2401 zend_ast_export_stmt(str, ast->child[1], indent + 1); in zend_ast_export_ex()
2405 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2407 zend_ast_export_ex(str, ast->child[1], 0, indent + 1); in zend_ast_export_ex()
2413 if (ast->child[0]) { in zend_ast_export_ex()
2414 zend_ast_export_list(str, (zend_ast_list*)ast->child[0], 1, 0, indent); in zend_ast_export_ex()
2419 zend_ast_export_ex(str, ast->child[1], 0, 0); in zend_ast_export_ex()
2424 ZEND_ASSERT(ast->child[0]->kind == ZEND_AST_CONST_DECL); in zend_ast_export_ex()
2425 zend_ast_export_list(str, (zend_ast_list*)ast->child[0], 1, 0, indent); in zend_ast_export_ex()
2427 if (ast->child[1]) { in zend_ast_export_ex()
2429 zend_ast_export_stmt(str, ast->child[1], indent + 1); in zend_ast_export_ex()
2438 zend_ast_export_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2440 zend_ast *default_value = ast->child[1]; in zend_ast_export_ex()
2446 if (ast->child[3]) { in zend_ast_export_ex()
2447 zend_ast_export_hook_list(str, zend_ast_get_list(ast->child[3]), indent); in zend_ast_export_ex()
2451 zend_ast_export_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2455 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2456 if (ast->child[1]) { in zend_ast_export_ex()
2458 zend_ast_export_ex(str, ast->child[1], 0, indent + 1); in zend_ast_export_ex()
2466 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2468 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2471 if (ast->child[0]) { in zend_ast_export_ex()
2472 zend_ast_export_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2475 zend_ast_export_name(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2479 if (ast->child[0]) { in zend_ast_export_ex()
2481 zend_ast_export_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2483 if (ast->child[1]) { in zend_ast_export_ex()
2485 zend_ast_export_stmt(str, ast->child[1], indent + 1); in zend_ast_export_ex()
2494 zend_ast_export_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2495 if (ast->attr & ZEND_ACC_PUBLIC) { in zend_ast_export_ex()
2497 } else if (ast->attr & ZEND_ACC_PROTECTED) { in zend_ast_export_ex()
2499 } else if (ast->attr & ZEND_ACC_PRIVATE) { in zend_ast_export_ex()
2501 } else if (ast->child[1]) { in zend_ast_export_ex()
2504 if (ast->child[1]) { in zend_ast_export_ex()
2506 zend_ast_export_name(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2510 smart_str_append(str, zend_ast_get_str(ast->child[0])); in zend_ast_export_ex()
2512 ast = ast->child[1]; in zend_ast_export_ex()
2518 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2519 smart_str_appends(str, ast->kind == ZEND_AST_NULLSAFE_METHOD_CALL ? "?->" : "->"); in zend_ast_export_ex()
2520 zend_ast_export_var(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2522 zend_ast_export_ex(str, ast->child[2], 0, indent); in zend_ast_export_ex()
2526 zend_ast_export_ns_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2528 zend_ast_export_var(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2530 zend_ast_export_ex(str, ast->child[2], 0, indent); in zend_ast_export_ex()
2535 zend_ast_export_ex(str, ast->child[0], 100, indent); in zend_ast_export_ex()
2536 if (ast->child[1]) { in zend_ast_export_ex()
2538 zend_ast_export_ex(str, ast->child[1], 101, indent); in zend_ast_export_ex()
2543 zend_ast_export_ex(str, ast->child[2], 101, indent); in zend_ast_export_ex()
2549 zend_ast_export_stmt(str, ast->child[0], indent + 1); in zend_ast_export_ex()
2551 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2552 if (ast->child[2]) { in zend_ast_export_ex()
2554 zend_ast_export_stmt(str, ast->child[2], indent + 1); in zend_ast_export_ex()
2561 zend_ast_export_catch_name_list(str, zend_ast_get_list(ast->child[0]), indent); in zend_ast_export_ex()
2562 if (ast->child[1]) { in zend_ast_export_ex()
2564 zend_ast_export_var(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2567 zend_ast_export_stmt(str, ast->child[2], indent + 1); in zend_ast_export_ex()
2571 if (ast->child[3]) { in zend_ast_export_ex()
2572 zend_ast_export_attributes(str, ast->child[3], indent, 0); in zend_ast_export_ex()
2574 zend_ast_export_visibility(str, ast->attr, ZEND_MODIFIER_TARGET_CPP); in zend_ast_export_ex()
2575 if (ast->child[0]) { in zend_ast_export_ex()
2576 zend_ast_export_type(str, ast->child[0], indent); in zend_ast_export_ex()
2579 if (ast->attr & ZEND_PARAM_REF) { in zend_ast_export_ex()
2582 if (ast->attr & ZEND_PARAM_VARIADIC) { in zend_ast_export_ex()
2586 zend_ast_export_name(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2587 if (ast->child[2]) { in zend_ast_export_ex()
2589 zend_ast_export_ex(str, ast->child[2], 0, indent); in zend_ast_export_ex()
2591 if (ast->child[5]) { in zend_ast_export_ex()
2592 zend_ast_export_hook_list(str, zend_ast_get_list(ast->child[5]), indent); in zend_ast_export_ex()
2596 if (ast->child[3]) { in zend_ast_export_ex()
2597 zend_ast_export_attributes(str, ast->child[3], indent, 1); in zend_ast_export_ex()
2600 zend_ast_export_name(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2601 if (ast->child[1]) { in zend_ast_export_ex()
2603 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2610 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2612 if (ast->child[1]) { in zend_ast_export_ex()
2614 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2617 if (ast->child[2]) { in zend_ast_export_ex()
2619 zend_ast_export_ex(str, ast->child[2], 0, indent); in zend_ast_export_ex()
2622 zend_ast_export_stmt(str, ast->child[3], indent + 1); in zend_ast_export_ex()
2628 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2630 if (ast->child[2]) { in zend_ast_export_ex()
2631 zend_ast_export_ex(str, ast->child[2], 0, indent); in zend_ast_export_ex()
2634 zend_ast_export_ex(str, ast->child[1], 0, indent); in zend_ast_export_ex()
2636 zend_ast_export_stmt(str, ast->child[3], indent + 1); in zend_ast_export_ex()
2646 zend_ast_export_ex(str, ast->child[0], pl, indent); in zend_ast_export_ex()
2648 zend_ast_export_ex(str, ast->child[1], pr, indent); in zend_ast_export_ex()
2655 zend_ast_export_ex(str, ast->child[0], pl, indent); in zend_ast_export_ex()
2661 zend_ast_export_ex(str, ast->child[0], pl, indent); in zend_ast_export_ex()
2669 zend_ast_export_ex(str, ast->child[0], 0, indent); in zend_ast_export_ex()
2675 if (ast->child[0]) { in zend_ast_export_ex()
2677 ast = ast->child[0]; in zend_ast_export_ex()
2687 if (ast->child[p]) { in zend_ast_export_ex()
2689 ast = ast->child[p]; in zend_ast_export_ex()
2695 ZEND_API ZEND_COLD zend_string *zend_ast_export(const char *prefix, zend_ast *ast, const char *suff… in zend_ast_export() argument
2700 zend_ast_export_ex(&str, ast, 0, 0); in zend_ast_export()
2706 zend_ast * ZEND_FASTCALL zend_ast_with_attributes(zend_ast *ast, zend_ast *attr) in zend_ast_with_attributes() argument
2710 switch (ast->kind) { in zend_ast_with_attributes()
2716 ((zend_ast_decl *) ast)->child[4] = attr; in zend_ast_with_attributes()
2719 ((zend_ast_decl *) ast)->child[3] = attr; in zend_ast_with_attributes()
2722 ast->child[2] = attr; in zend_ast_with_attributes()
2726 ast->child[3] = attr; in zend_ast_with_attributes()
2729 ast->child[1] = attr; in zend_ast_with_attributes()
2734 return ast; in zend_ast_with_attributes()