1 #include "php_ast.h"
2
3 const zend_ast_kind ast_kinds[] = {
4 ZEND_AST_ARG_LIST,
5 ZEND_AST_LIST,
6 ZEND_AST_ARRAY,
7 ZEND_AST_ENCAPS_LIST,
8 ZEND_AST_EXPR_LIST,
9 ZEND_AST_STMT_LIST,
10 ZEND_AST_IF,
11 ZEND_AST_SWITCH_LIST,
12 ZEND_AST_CATCH_LIST,
13 ZEND_AST_PARAM_LIST,
14 ZEND_AST_CLOSURE_USES,
15 ZEND_AST_PROP_DECL,
16 ZEND_AST_CONST_DECL,
17 ZEND_AST_CLASS_CONST_DECL,
18 ZEND_AST_NAME_LIST,
19 ZEND_AST_TRAIT_ADAPTATIONS,
20 ZEND_AST_USE,
21 ZEND_AST_TYPE_UNION,
22 ZEND_AST_TYPE_INTERSECTION,
23 ZEND_AST_ATTRIBUTE_LIST,
24 ZEND_AST_ATTRIBUTE_GROUP,
25 ZEND_AST_MATCH_ARM_LIST,
26 AST_NAME,
27 AST_CLOSURE_VAR,
28 AST_NULLABLE_TYPE,
29 ZEND_AST_FUNC_DECL,
30 ZEND_AST_CLOSURE,
31 ZEND_AST_METHOD,
32 ZEND_AST_ARROW_FUNC,
33 ZEND_AST_CLASS,
34 ZEND_AST_PROPERTY_HOOK,
35 ZEND_AST_MAGIC_CONST,
36 ZEND_AST_TYPE,
37 ZEND_AST_CALLABLE_CONVERT,
38 ZEND_AST_VAR,
39 ZEND_AST_CONST,
40 ZEND_AST_UNPACK,
41 ZEND_AST_CAST,
42 ZEND_AST_EMPTY,
43 ZEND_AST_ISSET,
44 ZEND_AST_SHELL_EXEC,
45 ZEND_AST_CLONE,
46 ZEND_AST_EXIT,
47 ZEND_AST_PRINT,
48 ZEND_AST_INCLUDE_OR_EVAL,
49 ZEND_AST_UNARY_OP,
50 ZEND_AST_PRE_INC,
51 ZEND_AST_PRE_DEC,
52 ZEND_AST_POST_INC,
53 ZEND_AST_POST_DEC,
54 ZEND_AST_YIELD_FROM,
55 ZEND_AST_GLOBAL,
56 ZEND_AST_UNSET,
57 ZEND_AST_RETURN,
58 ZEND_AST_LABEL,
59 ZEND_AST_REF,
60 ZEND_AST_HALT_COMPILER,
61 ZEND_AST_ECHO,
62 ZEND_AST_THROW,
63 ZEND_AST_GOTO,
64 ZEND_AST_BREAK,
65 ZEND_AST_CONTINUE,
66 ZEND_AST_CLASS_NAME,
67 ZEND_AST_PROPERTY_HOOK_SHORT_BODY,
68 ZEND_AST_CLASS_CONST_GROUP,
69 ZEND_AST_DIM,
70 ZEND_AST_PROP,
71 ZEND_AST_NULLSAFE_PROP,
72 ZEND_AST_STATIC_PROP,
73 ZEND_AST_CALL,
74 ZEND_AST_CLASS_CONST,
75 ZEND_AST_ASSIGN,
76 ZEND_AST_ASSIGN_REF,
77 ZEND_AST_ASSIGN_OP,
78 ZEND_AST_BINARY_OP,
79 ZEND_AST_ARRAY_ELEM,
80 ZEND_AST_NEW,
81 ZEND_AST_INSTANCEOF,
82 ZEND_AST_YIELD,
83 ZEND_AST_STATIC,
84 ZEND_AST_WHILE,
85 ZEND_AST_DO_WHILE,
86 ZEND_AST_IF_ELEM,
87 ZEND_AST_SWITCH,
88 ZEND_AST_SWITCH_CASE,
89 ZEND_AST_DECLARE,
90 ZEND_AST_PROP_ELEM,
91 ZEND_AST_PROP_GROUP,
92 ZEND_AST_CONST_ELEM,
93 ZEND_AST_USE_TRAIT,
94 ZEND_AST_TRAIT_PRECEDENCE,
95 ZEND_AST_METHOD_REFERENCE,
96 ZEND_AST_NAMESPACE,
97 ZEND_AST_USE_ELEM,
98 ZEND_AST_TRAIT_ALIAS,
99 ZEND_AST_GROUP_USE,
100 ZEND_AST_ATTRIBUTE,
101 ZEND_AST_MATCH,
102 ZEND_AST_MATCH_ARM,
103 ZEND_AST_NAMED_ARG,
104 ZEND_AST_METHOD_CALL,
105 ZEND_AST_NULLSAFE_METHOD_CALL,
106 ZEND_AST_STATIC_CALL,
107 ZEND_AST_CONDITIONAL,
108 ZEND_AST_TRY,
109 ZEND_AST_CATCH,
110 ZEND_AST_FOR,
111 ZEND_AST_FOREACH,
112 ZEND_AST_ENUM_CASE,
113 ZEND_AST_PARAM,
114 };
115
116 const size_t ast_kinds_count = sizeof(ast_kinds) / sizeof(ast_kinds[0]);
117
ast_kind_to_name(zend_ast_kind kind)118 const char *ast_kind_to_name(zend_ast_kind kind) {
119 switch (kind) {
120 case ZEND_AST_ARG_LIST: return "AST_ARG_LIST";
121 case ZEND_AST_LIST: return "AST_LIST";
122 case ZEND_AST_ARRAY: return "AST_ARRAY";
123 case ZEND_AST_ENCAPS_LIST: return "AST_ENCAPS_LIST";
124 case ZEND_AST_EXPR_LIST: return "AST_EXPR_LIST";
125 case ZEND_AST_STMT_LIST: return "AST_STMT_LIST";
126 case ZEND_AST_IF: return "AST_IF";
127 case ZEND_AST_SWITCH_LIST: return "AST_SWITCH_LIST";
128 case ZEND_AST_CATCH_LIST: return "AST_CATCH_LIST";
129 case ZEND_AST_PARAM_LIST: return "AST_PARAM_LIST";
130 case ZEND_AST_CLOSURE_USES: return "AST_CLOSURE_USES";
131 case ZEND_AST_PROP_DECL: return "AST_PROP_DECL";
132 case ZEND_AST_CONST_DECL: return "AST_CONST_DECL";
133 case ZEND_AST_CLASS_CONST_DECL: return "AST_CLASS_CONST_DECL";
134 case ZEND_AST_NAME_LIST: return "AST_NAME_LIST";
135 case ZEND_AST_TRAIT_ADAPTATIONS: return "AST_TRAIT_ADAPTATIONS";
136 case ZEND_AST_USE: return "AST_USE";
137 case ZEND_AST_TYPE_UNION: return "AST_TYPE_UNION";
138 case ZEND_AST_TYPE_INTERSECTION: return "AST_TYPE_INTERSECTION";
139 case ZEND_AST_ATTRIBUTE_LIST: return "AST_ATTRIBUTE_LIST";
140 case ZEND_AST_ATTRIBUTE_GROUP: return "AST_ATTRIBUTE_GROUP";
141 case ZEND_AST_MATCH_ARM_LIST: return "AST_MATCH_ARM_LIST";
142 case AST_NAME: return "AST_NAME";
143 case AST_CLOSURE_VAR: return "AST_CLOSURE_VAR";
144 case AST_NULLABLE_TYPE: return "AST_NULLABLE_TYPE";
145 case ZEND_AST_FUNC_DECL: return "AST_FUNC_DECL";
146 case ZEND_AST_CLOSURE: return "AST_CLOSURE";
147 case ZEND_AST_METHOD: return "AST_METHOD";
148 case ZEND_AST_ARROW_FUNC: return "AST_ARROW_FUNC";
149 case ZEND_AST_CLASS: return "AST_CLASS";
150 case ZEND_AST_PROPERTY_HOOK: return "AST_PROPERTY_HOOK";
151 case ZEND_AST_MAGIC_CONST: return "AST_MAGIC_CONST";
152 case ZEND_AST_TYPE: return "AST_TYPE";
153 case ZEND_AST_CALLABLE_CONVERT: return "AST_CALLABLE_CONVERT";
154 case ZEND_AST_VAR: return "AST_VAR";
155 case ZEND_AST_CONST: return "AST_CONST";
156 case ZEND_AST_UNPACK: return "AST_UNPACK";
157 case ZEND_AST_CAST: return "AST_CAST";
158 case ZEND_AST_EMPTY: return "AST_EMPTY";
159 case ZEND_AST_ISSET: return "AST_ISSET";
160 case ZEND_AST_SHELL_EXEC: return "AST_SHELL_EXEC";
161 case ZEND_AST_CLONE: return "AST_CLONE";
162 case ZEND_AST_EXIT: return "AST_EXIT";
163 case ZEND_AST_PRINT: return "AST_PRINT";
164 case ZEND_AST_INCLUDE_OR_EVAL: return "AST_INCLUDE_OR_EVAL";
165 case ZEND_AST_UNARY_OP: return "AST_UNARY_OP";
166 case ZEND_AST_PRE_INC: return "AST_PRE_INC";
167 case ZEND_AST_PRE_DEC: return "AST_PRE_DEC";
168 case ZEND_AST_POST_INC: return "AST_POST_INC";
169 case ZEND_AST_POST_DEC: return "AST_POST_DEC";
170 case ZEND_AST_YIELD_FROM: return "AST_YIELD_FROM";
171 case ZEND_AST_GLOBAL: return "AST_GLOBAL";
172 case ZEND_AST_UNSET: return "AST_UNSET";
173 case ZEND_AST_RETURN: return "AST_RETURN";
174 case ZEND_AST_LABEL: return "AST_LABEL";
175 case ZEND_AST_REF: return "AST_REF";
176 case ZEND_AST_HALT_COMPILER: return "AST_HALT_COMPILER";
177 case ZEND_AST_ECHO: return "AST_ECHO";
178 case ZEND_AST_THROW: return "AST_THROW";
179 case ZEND_AST_GOTO: return "AST_GOTO";
180 case ZEND_AST_BREAK: return "AST_BREAK";
181 case ZEND_AST_CONTINUE: return "AST_CONTINUE";
182 case ZEND_AST_CLASS_NAME: return "AST_CLASS_NAME";
183 case ZEND_AST_PROPERTY_HOOK_SHORT_BODY: return "AST_PROPERTY_HOOK_SHORT_BODY";
184 case ZEND_AST_CLASS_CONST_GROUP: return "AST_CLASS_CONST_GROUP";
185 case ZEND_AST_DIM: return "AST_DIM";
186 case ZEND_AST_PROP: return "AST_PROP";
187 case ZEND_AST_NULLSAFE_PROP: return "AST_NULLSAFE_PROP";
188 case ZEND_AST_STATIC_PROP: return "AST_STATIC_PROP";
189 case ZEND_AST_CALL: return "AST_CALL";
190 case ZEND_AST_CLASS_CONST: return "AST_CLASS_CONST";
191 case ZEND_AST_ASSIGN: return "AST_ASSIGN";
192 case ZEND_AST_ASSIGN_REF: return "AST_ASSIGN_REF";
193 case ZEND_AST_ASSIGN_OP: return "AST_ASSIGN_OP";
194 case ZEND_AST_BINARY_OP: return "AST_BINARY_OP";
195 case ZEND_AST_ARRAY_ELEM: return "AST_ARRAY_ELEM";
196 case ZEND_AST_NEW: return "AST_NEW";
197 case ZEND_AST_INSTANCEOF: return "AST_INSTANCEOF";
198 case ZEND_AST_YIELD: return "AST_YIELD";
199 case ZEND_AST_STATIC: return "AST_STATIC";
200 case ZEND_AST_WHILE: return "AST_WHILE";
201 case ZEND_AST_DO_WHILE: return "AST_DO_WHILE";
202 case ZEND_AST_IF_ELEM: return "AST_IF_ELEM";
203 case ZEND_AST_SWITCH: return "AST_SWITCH";
204 case ZEND_AST_SWITCH_CASE: return "AST_SWITCH_CASE";
205 case ZEND_AST_DECLARE: return "AST_DECLARE";
206 case ZEND_AST_PROP_ELEM: return "AST_PROP_ELEM";
207 case ZEND_AST_PROP_GROUP: return "AST_PROP_GROUP";
208 case ZEND_AST_CONST_ELEM: return "AST_CONST_ELEM";
209 case ZEND_AST_USE_TRAIT: return "AST_USE_TRAIT";
210 case ZEND_AST_TRAIT_PRECEDENCE: return "AST_TRAIT_PRECEDENCE";
211 case ZEND_AST_METHOD_REFERENCE: return "AST_METHOD_REFERENCE";
212 case ZEND_AST_NAMESPACE: return "AST_NAMESPACE";
213 case ZEND_AST_USE_ELEM: return "AST_USE_ELEM";
214 case ZEND_AST_TRAIT_ALIAS: return "AST_TRAIT_ALIAS";
215 case ZEND_AST_GROUP_USE: return "AST_GROUP_USE";
216 case ZEND_AST_ATTRIBUTE: return "AST_ATTRIBUTE";
217 case ZEND_AST_MATCH: return "AST_MATCH";
218 case ZEND_AST_MATCH_ARM: return "AST_MATCH_ARM";
219 case ZEND_AST_NAMED_ARG: return "AST_NAMED_ARG";
220 case ZEND_AST_METHOD_CALL: return "AST_METHOD_CALL";
221 case ZEND_AST_NULLSAFE_METHOD_CALL: return "AST_NULLSAFE_METHOD_CALL";
222 case ZEND_AST_STATIC_CALL: return "AST_STATIC_CALL";
223 case ZEND_AST_CONDITIONAL: return "AST_CONDITIONAL";
224 case ZEND_AST_TRY: return "AST_TRY";
225 case ZEND_AST_CATCH: return "AST_CATCH";
226 case ZEND_AST_FOR: return "AST_FOR";
227 case ZEND_AST_FOREACH: return "AST_FOREACH";
228 case ZEND_AST_ENUM_CASE: return "AST_ENUM_CASE";
229 case ZEND_AST_PARAM: return "AST_PARAM";
230 }
231
232 return NULL;
233 }
234
ast_kind_child_name(zend_ast_kind kind,uint32_t child)235 zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
236 switch (kind) {
237 case AST_NAME:
238 case AST_CLOSURE_VAR:
239 case ZEND_AST_VAR:
240 case ZEND_AST_CONST:
241 case ZEND_AST_LABEL:
242 switch (child) {
243 case 0: return AST_STR(str_name);
244 }
245 return NULL;
246 case AST_NULLABLE_TYPE:
247 switch (child) {
248 case 0: return AST_STR(str_type);
249 }
250 return NULL;
251 case ZEND_AST_FUNC_DECL:
252 case ZEND_AST_CLOSURE:
253 case ZEND_AST_METHOD:
254 case ZEND_AST_ARROW_FUNC:
255 case ZEND_AST_PROPERTY_HOOK:
256 switch (child) {
257 case 0: return AST_STR(str_params);
258 case 1: return AST_STR(str_uses);
259 case 2: return AST_STR(str_stmts);
260 case 3: return AST_STR(str_returnType);
261 case 4: return AST_STR(str_attributes);
262 }
263 return NULL;
264 case ZEND_AST_CLASS:
265 switch (child) {
266 case 0: return AST_STR(str_extends);
267 case 1: return AST_STR(str_implements);
268 case 2: return AST_STR(str_stmts);
269 case 3: return AST_STR(str_attributes);
270 case 4: return AST_STR(str_type);
271 }
272 return NULL;
273 case ZEND_AST_MAGIC_CONST:
274 case ZEND_AST_TYPE:
275 case ZEND_AST_CALLABLE_CONVERT:
276 return NULL;
277 case ZEND_AST_UNPACK:
278 case ZEND_AST_CAST:
279 case ZEND_AST_EMPTY:
280 case ZEND_AST_SHELL_EXEC:
281 case ZEND_AST_CLONE:
282 case ZEND_AST_EXIT:
283 case ZEND_AST_PRINT:
284 case ZEND_AST_INCLUDE_OR_EVAL:
285 case ZEND_AST_UNARY_OP:
286 case ZEND_AST_YIELD_FROM:
287 case ZEND_AST_RETURN:
288 case ZEND_AST_ECHO:
289 case ZEND_AST_THROW:
290 case ZEND_AST_PROPERTY_HOOK_SHORT_BODY:
291 switch (child) {
292 case 0: return AST_STR(str_expr);
293 }
294 return NULL;
295 case ZEND_AST_ISSET:
296 case ZEND_AST_PRE_INC:
297 case ZEND_AST_PRE_DEC:
298 case ZEND_AST_POST_INC:
299 case ZEND_AST_POST_DEC:
300 case ZEND_AST_GLOBAL:
301 case ZEND_AST_UNSET:
302 case ZEND_AST_REF:
303 switch (child) {
304 case 0: return AST_STR(str_var);
305 }
306 return NULL;
307 case ZEND_AST_HALT_COMPILER:
308 switch (child) {
309 case 0: return AST_STR(str_offset);
310 }
311 return NULL;
312 case ZEND_AST_GOTO:
313 switch (child) {
314 case 0: return AST_STR(str_label);
315 }
316 return NULL;
317 case ZEND_AST_BREAK:
318 case ZEND_AST_CONTINUE:
319 switch (child) {
320 case 0: return AST_STR(str_depth);
321 }
322 return NULL;
323 case ZEND_AST_CLASS_NAME:
324 switch (child) {
325 case 0: return AST_STR(str_class);
326 }
327 return NULL;
328 case ZEND_AST_CLASS_CONST_GROUP:
329 switch (child) {
330 case 0: return AST_STR(str_const);
331 case 1: return AST_STR(str_attributes);
332 case 2: return AST_STR(str_type);
333 }
334 return NULL;
335 case ZEND_AST_DIM:
336 switch (child) {
337 case 0: return AST_STR(str_expr);
338 case 1: return AST_STR(str_dim);
339 }
340 return NULL;
341 case ZEND_AST_PROP:
342 case ZEND_AST_NULLSAFE_PROP:
343 switch (child) {
344 case 0: return AST_STR(str_expr);
345 case 1: return AST_STR(str_prop);
346 }
347 return NULL;
348 case ZEND_AST_STATIC_PROP:
349 switch (child) {
350 case 0: return AST_STR(str_class);
351 case 1: return AST_STR(str_prop);
352 }
353 return NULL;
354 case ZEND_AST_CALL:
355 switch (child) {
356 case 0: return AST_STR(str_expr);
357 case 1: return AST_STR(str_args);
358 }
359 return NULL;
360 case ZEND_AST_CLASS_CONST:
361 switch (child) {
362 case 0: return AST_STR(str_class);
363 case 1: return AST_STR(str_const);
364 }
365 return NULL;
366 case ZEND_AST_ASSIGN:
367 case ZEND_AST_ASSIGN_REF:
368 case ZEND_AST_ASSIGN_OP:
369 switch (child) {
370 case 0: return AST_STR(str_var);
371 case 1: return AST_STR(str_expr);
372 }
373 return NULL;
374 case ZEND_AST_BINARY_OP:
375 switch (child) {
376 case 0: return AST_STR(str_left);
377 case 1: return AST_STR(str_right);
378 }
379 return NULL;
380 case ZEND_AST_ARRAY_ELEM:
381 case ZEND_AST_YIELD:
382 switch (child) {
383 case 0: return AST_STR(str_value);
384 case 1: return AST_STR(str_key);
385 }
386 return NULL;
387 case ZEND_AST_NEW:
388 case ZEND_AST_ATTRIBUTE:
389 switch (child) {
390 case 0: return AST_STR(str_class);
391 case 1: return AST_STR(str_args);
392 }
393 return NULL;
394 case ZEND_AST_INSTANCEOF:
395 switch (child) {
396 case 0: return AST_STR(str_expr);
397 case 1: return AST_STR(str_class);
398 }
399 return NULL;
400 case ZEND_AST_STATIC:
401 switch (child) {
402 case 0: return AST_STR(str_var);
403 case 1: return AST_STR(str_default);
404 }
405 return NULL;
406 case ZEND_AST_WHILE:
407 case ZEND_AST_IF_ELEM:
408 case ZEND_AST_SWITCH:
409 case ZEND_AST_SWITCH_CASE:
410 case ZEND_AST_MATCH:
411 switch (child) {
412 case 0: return AST_STR(str_cond);
413 case 1: return AST_STR(str_stmts);
414 }
415 return NULL;
416 case ZEND_AST_DO_WHILE:
417 switch (child) {
418 case 0: return AST_STR(str_stmts);
419 case 1: return AST_STR(str_cond);
420 }
421 return NULL;
422 case ZEND_AST_DECLARE:
423 switch (child) {
424 case 0: return AST_STR(str_declares);
425 case 1: return AST_STR(str_stmts);
426 }
427 return NULL;
428 case ZEND_AST_PROP_ELEM:
429 switch (child) {
430 case 0: return AST_STR(str_name);
431 case 1: return AST_STR(str_default);
432 case 2: return AST_STR(str_docComment);
433 case 3: return AST_STR(str_hooks);
434 }
435 return NULL;
436 case ZEND_AST_PROP_GROUP:
437 switch (child) {
438 case 0: return AST_STR(str_type);
439 case 1: return AST_STR(str_props);
440 case 2: return AST_STR(str_attributes);
441 }
442 return NULL;
443 case ZEND_AST_CONST_ELEM:
444 switch (child) {
445 case 0: return AST_STR(str_name);
446 case 1: return AST_STR(str_value);
447 case 2: return AST_STR(str_docComment);
448 }
449 return NULL;
450 case ZEND_AST_USE_TRAIT:
451 switch (child) {
452 case 0: return AST_STR(str_traits);
453 case 1: return AST_STR(str_adaptations);
454 }
455 return NULL;
456 case ZEND_AST_TRAIT_PRECEDENCE:
457 switch (child) {
458 case 0: return AST_STR(str_method);
459 case 1: return AST_STR(str_insteadof);
460 }
461 return NULL;
462 case ZEND_AST_METHOD_REFERENCE:
463 switch (child) {
464 case 0: return AST_STR(str_class);
465 case 1: return AST_STR(str_method);
466 }
467 return NULL;
468 case ZEND_AST_NAMESPACE:
469 switch (child) {
470 case 0: return AST_STR(str_name);
471 case 1: return AST_STR(str_stmts);
472 }
473 return NULL;
474 case ZEND_AST_USE_ELEM:
475 switch (child) {
476 case 0: return AST_STR(str_name);
477 case 1: return AST_STR(str_alias);
478 }
479 return NULL;
480 case ZEND_AST_TRAIT_ALIAS:
481 switch (child) {
482 case 0: return AST_STR(str_method);
483 case 1: return AST_STR(str_alias);
484 }
485 return NULL;
486 case ZEND_AST_GROUP_USE:
487 switch (child) {
488 case 0: return AST_STR(str_prefix);
489 case 1: return AST_STR(str_uses);
490 }
491 return NULL;
492 case ZEND_AST_MATCH_ARM:
493 switch (child) {
494 case 0: return AST_STR(str_cond);
495 case 1: return AST_STR(str_expr);
496 }
497 return NULL;
498 case ZEND_AST_NAMED_ARG:
499 switch (child) {
500 case 0: return AST_STR(str_name);
501 case 1: return AST_STR(str_expr);
502 }
503 return NULL;
504 case ZEND_AST_METHOD_CALL:
505 case ZEND_AST_NULLSAFE_METHOD_CALL:
506 switch (child) {
507 case 0: return AST_STR(str_expr);
508 case 1: return AST_STR(str_method);
509 case 2: return AST_STR(str_args);
510 }
511 return NULL;
512 case ZEND_AST_STATIC_CALL:
513 switch (child) {
514 case 0: return AST_STR(str_class);
515 case 1: return AST_STR(str_method);
516 case 2: return AST_STR(str_args);
517 }
518 return NULL;
519 case ZEND_AST_CONDITIONAL:
520 switch (child) {
521 case 0: return AST_STR(str_cond);
522 case 1: return AST_STR(str_true);
523 case 2: return AST_STR(str_false);
524 }
525 return NULL;
526 case ZEND_AST_TRY:
527 switch (child) {
528 case 0: return AST_STR(str_try);
529 case 1: return AST_STR(str_catches);
530 case 2: return AST_STR(str_finally);
531 }
532 return NULL;
533 case ZEND_AST_CATCH:
534 switch (child) {
535 case 0: return AST_STR(str_class);
536 case 1: return AST_STR(str_var);
537 case 2: return AST_STR(str_stmts);
538 }
539 return NULL;
540 case ZEND_AST_FOR:
541 switch (child) {
542 case 0: return AST_STR(str_init);
543 case 1: return AST_STR(str_cond);
544 case 2: return AST_STR(str_loop);
545 case 3: return AST_STR(str_stmts);
546 }
547 return NULL;
548 case ZEND_AST_FOREACH:
549 switch (child) {
550 case 0: return AST_STR(str_expr);
551 case 1: return AST_STR(str_value);
552 case 2: return AST_STR(str_key);
553 case 3: return AST_STR(str_stmts);
554 }
555 return NULL;
556 case ZEND_AST_ENUM_CASE:
557 switch (child) {
558 case 0: return AST_STR(str_name);
559 case 1: return AST_STR(str_expr);
560 case 2: return AST_STR(str_docComment);
561 case 3: return AST_STR(str_attributes);
562 }
563 return NULL;
564 case ZEND_AST_PARAM:
565 switch (child) {
566 case 0: return AST_STR(str_type);
567 case 1: return AST_STR(str_name);
568 case 2: return AST_STR(str_default);
569 case 3: return AST_STR(str_attributes);
570 case 4: return AST_STR(str_docComment);
571 case 5: return AST_STR(str_hooks);
572 }
573 return NULL;
574 }
575
576 return NULL;
577 }
578
ast_register_kind_constants(INIT_FUNC_ARGS)579 void ast_register_kind_constants(INIT_FUNC_ARGS) {
580 REGISTER_NS_LONG_CONSTANT("ast", "AST_ARG_LIST", ZEND_AST_ARG_LIST, CONST_CS | CONST_PERSISTENT);
581 REGISTER_NS_LONG_CONSTANT("ast", "AST_LIST", ZEND_AST_LIST, CONST_CS | CONST_PERSISTENT);
582 REGISTER_NS_LONG_CONSTANT("ast", "AST_ARRAY", ZEND_AST_ARRAY, CONST_CS | CONST_PERSISTENT);
583 REGISTER_NS_LONG_CONSTANT("ast", "AST_ENCAPS_LIST", ZEND_AST_ENCAPS_LIST, CONST_CS | CONST_PERSISTENT);
584 REGISTER_NS_LONG_CONSTANT("ast", "AST_EXPR_LIST", ZEND_AST_EXPR_LIST, CONST_CS | CONST_PERSISTENT);
585 REGISTER_NS_LONG_CONSTANT("ast", "AST_STMT_LIST", ZEND_AST_STMT_LIST, CONST_CS | CONST_PERSISTENT);
586 REGISTER_NS_LONG_CONSTANT("ast", "AST_IF", ZEND_AST_IF, CONST_CS | CONST_PERSISTENT);
587 REGISTER_NS_LONG_CONSTANT("ast", "AST_SWITCH_LIST", ZEND_AST_SWITCH_LIST, CONST_CS | CONST_PERSISTENT);
588 REGISTER_NS_LONG_CONSTANT("ast", "AST_CATCH_LIST", ZEND_AST_CATCH_LIST, CONST_CS | CONST_PERSISTENT);
589 REGISTER_NS_LONG_CONSTANT("ast", "AST_PARAM_LIST", ZEND_AST_PARAM_LIST, CONST_CS | CONST_PERSISTENT);
590 REGISTER_NS_LONG_CONSTANT("ast", "AST_CLOSURE_USES", ZEND_AST_CLOSURE_USES, CONST_CS | CONST_PERSISTENT);
591 REGISTER_NS_LONG_CONSTANT("ast", "AST_PROP_DECL", ZEND_AST_PROP_DECL, CONST_CS | CONST_PERSISTENT);
592 REGISTER_NS_LONG_CONSTANT("ast", "AST_CONST_DECL", ZEND_AST_CONST_DECL, CONST_CS | CONST_PERSISTENT);
593 REGISTER_NS_LONG_CONSTANT("ast", "AST_CLASS_CONST_DECL", ZEND_AST_CLASS_CONST_DECL, CONST_CS | CONST_PERSISTENT);
594 REGISTER_NS_LONG_CONSTANT("ast", "AST_NAME_LIST", ZEND_AST_NAME_LIST, CONST_CS | CONST_PERSISTENT);
595 REGISTER_NS_LONG_CONSTANT("ast", "AST_TRAIT_ADAPTATIONS", ZEND_AST_TRAIT_ADAPTATIONS, CONST_CS | CONST_PERSISTENT);
596 REGISTER_NS_LONG_CONSTANT("ast", "AST_USE", ZEND_AST_USE, CONST_CS | CONST_PERSISTENT);
597 REGISTER_NS_LONG_CONSTANT("ast", "AST_TYPE_UNION", ZEND_AST_TYPE_UNION, CONST_CS | CONST_PERSISTENT);
598 REGISTER_NS_LONG_CONSTANT("ast", "AST_TYPE_INTERSECTION", ZEND_AST_TYPE_INTERSECTION, CONST_CS | CONST_PERSISTENT);
599 REGISTER_NS_LONG_CONSTANT("ast", "AST_ATTRIBUTE_LIST", ZEND_AST_ATTRIBUTE_LIST, CONST_CS | CONST_PERSISTENT);
600 REGISTER_NS_LONG_CONSTANT("ast", "AST_ATTRIBUTE_GROUP", ZEND_AST_ATTRIBUTE_GROUP, CONST_CS | CONST_PERSISTENT);
601 REGISTER_NS_LONG_CONSTANT("ast", "AST_MATCH_ARM_LIST", ZEND_AST_MATCH_ARM_LIST, CONST_CS | CONST_PERSISTENT);
602 REGISTER_NS_LONG_CONSTANT("ast", "AST_NAME", AST_NAME, CONST_CS | CONST_PERSISTENT);
603 REGISTER_NS_LONG_CONSTANT("ast", "AST_CLOSURE_VAR", AST_CLOSURE_VAR, CONST_CS | CONST_PERSISTENT);
604 REGISTER_NS_LONG_CONSTANT("ast", "AST_NULLABLE_TYPE", AST_NULLABLE_TYPE, CONST_CS | CONST_PERSISTENT);
605 REGISTER_NS_LONG_CONSTANT("ast", "AST_FUNC_DECL", ZEND_AST_FUNC_DECL, CONST_CS | CONST_PERSISTENT);
606 REGISTER_NS_LONG_CONSTANT("ast", "AST_CLOSURE", ZEND_AST_CLOSURE, CONST_CS | CONST_PERSISTENT);
607 REGISTER_NS_LONG_CONSTANT("ast", "AST_METHOD", ZEND_AST_METHOD, CONST_CS | CONST_PERSISTENT);
608 REGISTER_NS_LONG_CONSTANT("ast", "AST_ARROW_FUNC", ZEND_AST_ARROW_FUNC, CONST_CS | CONST_PERSISTENT);
609 REGISTER_NS_LONG_CONSTANT("ast", "AST_CLASS", ZEND_AST_CLASS, CONST_CS | CONST_PERSISTENT);
610 REGISTER_NS_LONG_CONSTANT("ast", "AST_PROPERTY_HOOK", ZEND_AST_PROPERTY_HOOK, CONST_CS | CONST_PERSISTENT);
611 REGISTER_NS_LONG_CONSTANT("ast", "AST_MAGIC_CONST", ZEND_AST_MAGIC_CONST, CONST_CS | CONST_PERSISTENT);
612 REGISTER_NS_LONG_CONSTANT("ast", "AST_TYPE", ZEND_AST_TYPE, CONST_CS | CONST_PERSISTENT);
613 REGISTER_NS_LONG_CONSTANT("ast", "AST_CALLABLE_CONVERT", ZEND_AST_CALLABLE_CONVERT, CONST_CS | CONST_PERSISTENT);
614 REGISTER_NS_LONG_CONSTANT("ast", "AST_VAR", ZEND_AST_VAR, CONST_CS | CONST_PERSISTENT);
615 REGISTER_NS_LONG_CONSTANT("ast", "AST_CONST", ZEND_AST_CONST, CONST_CS | CONST_PERSISTENT);
616 REGISTER_NS_LONG_CONSTANT("ast", "AST_UNPACK", ZEND_AST_UNPACK, CONST_CS | CONST_PERSISTENT);
617 REGISTER_NS_LONG_CONSTANT("ast", "AST_CAST", ZEND_AST_CAST, CONST_CS | CONST_PERSISTENT);
618 REGISTER_NS_LONG_CONSTANT("ast", "AST_EMPTY", ZEND_AST_EMPTY, CONST_CS | CONST_PERSISTENT);
619 REGISTER_NS_LONG_CONSTANT("ast", "AST_ISSET", ZEND_AST_ISSET, CONST_CS | CONST_PERSISTENT);
620 REGISTER_NS_LONG_CONSTANT("ast", "AST_SHELL_EXEC", ZEND_AST_SHELL_EXEC, CONST_CS | CONST_PERSISTENT);
621 REGISTER_NS_LONG_CONSTANT("ast", "AST_CLONE", ZEND_AST_CLONE, CONST_CS | CONST_PERSISTENT);
622 REGISTER_NS_LONG_CONSTANT("ast", "AST_EXIT", ZEND_AST_EXIT, CONST_CS | CONST_PERSISTENT);
623 REGISTER_NS_LONG_CONSTANT("ast", "AST_PRINT", ZEND_AST_PRINT, CONST_CS | CONST_PERSISTENT);
624 REGISTER_NS_LONG_CONSTANT("ast", "AST_INCLUDE_OR_EVAL", ZEND_AST_INCLUDE_OR_EVAL, CONST_CS | CONST_PERSISTENT);
625 REGISTER_NS_LONG_CONSTANT("ast", "AST_UNARY_OP", ZEND_AST_UNARY_OP, CONST_CS | CONST_PERSISTENT);
626 REGISTER_NS_LONG_CONSTANT("ast", "AST_PRE_INC", ZEND_AST_PRE_INC, CONST_CS | CONST_PERSISTENT);
627 REGISTER_NS_LONG_CONSTANT("ast", "AST_PRE_DEC", ZEND_AST_PRE_DEC, CONST_CS | CONST_PERSISTENT);
628 REGISTER_NS_LONG_CONSTANT("ast", "AST_POST_INC", ZEND_AST_POST_INC, CONST_CS | CONST_PERSISTENT);
629 REGISTER_NS_LONG_CONSTANT("ast", "AST_POST_DEC", ZEND_AST_POST_DEC, CONST_CS | CONST_PERSISTENT);
630 REGISTER_NS_LONG_CONSTANT("ast", "AST_YIELD_FROM", ZEND_AST_YIELD_FROM, CONST_CS | CONST_PERSISTENT);
631 REGISTER_NS_LONG_CONSTANT("ast", "AST_GLOBAL", ZEND_AST_GLOBAL, CONST_CS | CONST_PERSISTENT);
632 REGISTER_NS_LONG_CONSTANT("ast", "AST_UNSET", ZEND_AST_UNSET, CONST_CS | CONST_PERSISTENT);
633 REGISTER_NS_LONG_CONSTANT("ast", "AST_RETURN", ZEND_AST_RETURN, CONST_CS | CONST_PERSISTENT);
634 REGISTER_NS_LONG_CONSTANT("ast", "AST_LABEL", ZEND_AST_LABEL, CONST_CS | CONST_PERSISTENT);
635 REGISTER_NS_LONG_CONSTANT("ast", "AST_REF", ZEND_AST_REF, CONST_CS | CONST_PERSISTENT);
636 REGISTER_NS_LONG_CONSTANT("ast", "AST_HALT_COMPILER", ZEND_AST_HALT_COMPILER, CONST_CS | CONST_PERSISTENT);
637 REGISTER_NS_LONG_CONSTANT("ast", "AST_ECHO", ZEND_AST_ECHO, CONST_CS | CONST_PERSISTENT);
638 REGISTER_NS_LONG_CONSTANT("ast", "AST_THROW", ZEND_AST_THROW, CONST_CS | CONST_PERSISTENT);
639 REGISTER_NS_LONG_CONSTANT("ast", "AST_GOTO", ZEND_AST_GOTO, CONST_CS | CONST_PERSISTENT);
640 REGISTER_NS_LONG_CONSTANT("ast", "AST_BREAK", ZEND_AST_BREAK, CONST_CS | CONST_PERSISTENT);
641 REGISTER_NS_LONG_CONSTANT("ast", "AST_CONTINUE", ZEND_AST_CONTINUE, CONST_CS | CONST_PERSISTENT);
642 REGISTER_NS_LONG_CONSTANT("ast", "AST_CLASS_NAME", ZEND_AST_CLASS_NAME, CONST_CS | CONST_PERSISTENT);
643 REGISTER_NS_LONG_CONSTANT("ast", "AST_PROPERTY_HOOK_SHORT_BODY", ZEND_AST_PROPERTY_HOOK_SHORT_BODY, CONST_CS | CONST_PERSISTENT);
644 REGISTER_NS_LONG_CONSTANT("ast", "AST_CLASS_CONST_GROUP", ZEND_AST_CLASS_CONST_GROUP, CONST_CS | CONST_PERSISTENT);
645 REGISTER_NS_LONG_CONSTANT("ast", "AST_DIM", ZEND_AST_DIM, CONST_CS | CONST_PERSISTENT);
646 REGISTER_NS_LONG_CONSTANT("ast", "AST_PROP", ZEND_AST_PROP, CONST_CS | CONST_PERSISTENT);
647 REGISTER_NS_LONG_CONSTANT("ast", "AST_NULLSAFE_PROP", ZEND_AST_NULLSAFE_PROP, CONST_CS | CONST_PERSISTENT);
648 REGISTER_NS_LONG_CONSTANT("ast", "AST_STATIC_PROP", ZEND_AST_STATIC_PROP, CONST_CS | CONST_PERSISTENT);
649 REGISTER_NS_LONG_CONSTANT("ast", "AST_CALL", ZEND_AST_CALL, CONST_CS | CONST_PERSISTENT);
650 REGISTER_NS_LONG_CONSTANT("ast", "AST_CLASS_CONST", ZEND_AST_CLASS_CONST, CONST_CS | CONST_PERSISTENT);
651 REGISTER_NS_LONG_CONSTANT("ast", "AST_ASSIGN", ZEND_AST_ASSIGN, CONST_CS | CONST_PERSISTENT);
652 REGISTER_NS_LONG_CONSTANT("ast", "AST_ASSIGN_REF", ZEND_AST_ASSIGN_REF, CONST_CS | CONST_PERSISTENT);
653 REGISTER_NS_LONG_CONSTANT("ast", "AST_ASSIGN_OP", ZEND_AST_ASSIGN_OP, CONST_CS | CONST_PERSISTENT);
654 REGISTER_NS_LONG_CONSTANT("ast", "AST_BINARY_OP", ZEND_AST_BINARY_OP, CONST_CS | CONST_PERSISTENT);
655 REGISTER_NS_LONG_CONSTANT("ast", "AST_ARRAY_ELEM", ZEND_AST_ARRAY_ELEM, CONST_CS | CONST_PERSISTENT);
656 REGISTER_NS_LONG_CONSTANT("ast", "AST_NEW", ZEND_AST_NEW, CONST_CS | CONST_PERSISTENT);
657 REGISTER_NS_LONG_CONSTANT("ast", "AST_INSTANCEOF", ZEND_AST_INSTANCEOF, CONST_CS | CONST_PERSISTENT);
658 REGISTER_NS_LONG_CONSTANT("ast", "AST_YIELD", ZEND_AST_YIELD, CONST_CS | CONST_PERSISTENT);
659 REGISTER_NS_LONG_CONSTANT("ast", "AST_STATIC", ZEND_AST_STATIC, CONST_CS | CONST_PERSISTENT);
660 REGISTER_NS_LONG_CONSTANT("ast", "AST_WHILE", ZEND_AST_WHILE, CONST_CS | CONST_PERSISTENT);
661 REGISTER_NS_LONG_CONSTANT("ast", "AST_DO_WHILE", ZEND_AST_DO_WHILE, CONST_CS | CONST_PERSISTENT);
662 REGISTER_NS_LONG_CONSTANT("ast", "AST_IF_ELEM", ZEND_AST_IF_ELEM, CONST_CS | CONST_PERSISTENT);
663 REGISTER_NS_LONG_CONSTANT("ast", "AST_SWITCH", ZEND_AST_SWITCH, CONST_CS | CONST_PERSISTENT);
664 REGISTER_NS_LONG_CONSTANT("ast", "AST_SWITCH_CASE", ZEND_AST_SWITCH_CASE, CONST_CS | CONST_PERSISTENT);
665 REGISTER_NS_LONG_CONSTANT("ast", "AST_DECLARE", ZEND_AST_DECLARE, CONST_CS | CONST_PERSISTENT);
666 REGISTER_NS_LONG_CONSTANT("ast", "AST_PROP_ELEM", ZEND_AST_PROP_ELEM, CONST_CS | CONST_PERSISTENT);
667 REGISTER_NS_LONG_CONSTANT("ast", "AST_PROP_GROUP", ZEND_AST_PROP_GROUP, CONST_CS | CONST_PERSISTENT);
668 REGISTER_NS_LONG_CONSTANT("ast", "AST_CONST_ELEM", ZEND_AST_CONST_ELEM, CONST_CS | CONST_PERSISTENT);
669 REGISTER_NS_LONG_CONSTANT("ast", "AST_USE_TRAIT", ZEND_AST_USE_TRAIT, CONST_CS | CONST_PERSISTENT);
670 REGISTER_NS_LONG_CONSTANT("ast", "AST_TRAIT_PRECEDENCE", ZEND_AST_TRAIT_PRECEDENCE, CONST_CS | CONST_PERSISTENT);
671 REGISTER_NS_LONG_CONSTANT("ast", "AST_METHOD_REFERENCE", ZEND_AST_METHOD_REFERENCE, CONST_CS | CONST_PERSISTENT);
672 REGISTER_NS_LONG_CONSTANT("ast", "AST_NAMESPACE", ZEND_AST_NAMESPACE, CONST_CS | CONST_PERSISTENT);
673 REGISTER_NS_LONG_CONSTANT("ast", "AST_USE_ELEM", ZEND_AST_USE_ELEM, CONST_CS | CONST_PERSISTENT);
674 REGISTER_NS_LONG_CONSTANT("ast", "AST_TRAIT_ALIAS", ZEND_AST_TRAIT_ALIAS, CONST_CS | CONST_PERSISTENT);
675 REGISTER_NS_LONG_CONSTANT("ast", "AST_GROUP_USE", ZEND_AST_GROUP_USE, CONST_CS | CONST_PERSISTENT);
676 REGISTER_NS_LONG_CONSTANT("ast", "AST_ATTRIBUTE", ZEND_AST_ATTRIBUTE, CONST_CS | CONST_PERSISTENT);
677 REGISTER_NS_LONG_CONSTANT("ast", "AST_MATCH", ZEND_AST_MATCH, CONST_CS | CONST_PERSISTENT);
678 REGISTER_NS_LONG_CONSTANT("ast", "AST_MATCH_ARM", ZEND_AST_MATCH_ARM, CONST_CS | CONST_PERSISTENT);
679 REGISTER_NS_LONG_CONSTANT("ast", "AST_NAMED_ARG", ZEND_AST_NAMED_ARG, CONST_CS | CONST_PERSISTENT);
680 REGISTER_NS_LONG_CONSTANT("ast", "AST_METHOD_CALL", ZEND_AST_METHOD_CALL, CONST_CS | CONST_PERSISTENT);
681 REGISTER_NS_LONG_CONSTANT("ast", "AST_NULLSAFE_METHOD_CALL", ZEND_AST_NULLSAFE_METHOD_CALL, CONST_CS | CONST_PERSISTENT);
682 REGISTER_NS_LONG_CONSTANT("ast", "AST_STATIC_CALL", ZEND_AST_STATIC_CALL, CONST_CS | CONST_PERSISTENT);
683 REGISTER_NS_LONG_CONSTANT("ast", "AST_CONDITIONAL", ZEND_AST_CONDITIONAL, CONST_CS | CONST_PERSISTENT);
684 REGISTER_NS_LONG_CONSTANT("ast", "AST_TRY", ZEND_AST_TRY, CONST_CS | CONST_PERSISTENT);
685 REGISTER_NS_LONG_CONSTANT("ast", "AST_CATCH", ZEND_AST_CATCH, CONST_CS | CONST_PERSISTENT);
686 REGISTER_NS_LONG_CONSTANT("ast", "AST_FOR", ZEND_AST_FOR, CONST_CS | CONST_PERSISTENT);
687 REGISTER_NS_LONG_CONSTANT("ast", "AST_FOREACH", ZEND_AST_FOREACH, CONST_CS | CONST_PERSISTENT);
688 REGISTER_NS_LONG_CONSTANT("ast", "AST_ENUM_CASE", ZEND_AST_ENUM_CASE, CONST_CS | CONST_PERSISTENT);
689 REGISTER_NS_LONG_CONSTANT("ast", "AST_PARAM", ZEND_AST_PARAM, CONST_CS | CONST_PERSISTENT);
690 }
691