Skip to content

Support doc comments for php 8.1 code, combine equivalent switch cases #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
221 changes: 25 additions & 196 deletions ast_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ const zend_ast_kind ast_kinds[] = {
ZEND_AST_MATCH,
ZEND_AST_MATCH_ARM,
ZEND_AST_NAMED_ARG,
ZEND_AST_ENUM_CASE,
ZEND_AST_METHOD_CALL,
ZEND_AST_NULLSAFE_METHOD_CALL,
ZEND_AST_STATIC_CALL,
Expand All @@ -106,6 +105,7 @@ const zend_ast_kind ast_kinds[] = {
ZEND_AST_CATCH,
ZEND_AST_FOR,
ZEND_AST_FOREACH,
ZEND_AST_ENUM_CASE,
ZEND_AST_PARAM,
};

Expand Down Expand Up @@ -209,7 +209,6 @@ const char *ast_kind_to_name(zend_ast_kind kind) {
case ZEND_AST_MATCH: return "AST_MATCH";
case ZEND_AST_MATCH_ARM: return "AST_MATCH_ARM";
case ZEND_AST_NAMED_ARG: return "AST_NAMED_ARG";
case ZEND_AST_ENUM_CASE: return "AST_ENUM_CASE";
case ZEND_AST_METHOD_CALL: return "AST_METHOD_CALL";
case ZEND_AST_NULLSAFE_METHOD_CALL: return "AST_NULLSAFE_METHOD_CALL";
case ZEND_AST_STATIC_CALL: return "AST_STATIC_CALL";
Expand All @@ -218,6 +217,7 @@ const char *ast_kind_to_name(zend_ast_kind kind) {
case ZEND_AST_CATCH: return "AST_CATCH";
case ZEND_AST_FOR: return "AST_FOR";
case ZEND_AST_FOREACH: return "AST_FOREACH";
case ZEND_AST_ENUM_CASE: return "AST_ENUM_CASE";
case ZEND_AST_PARAM: return "AST_PARAM";
}

Expand All @@ -227,11 +227,10 @@ const char *ast_kind_to_name(zend_ast_kind kind) {
zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
switch (kind) {
case AST_NAME:
switch (child) {
case 0: return AST_STR(str_name);
}
return NULL;
case AST_CLOSURE_VAR:
case ZEND_AST_VAR:
case ZEND_AST_CONST:
case ZEND_AST_LABEL:
switch (child) {
case 0: return AST_STR(str_name);
}
Expand All @@ -242,32 +241,8 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
}
return NULL;
case ZEND_AST_FUNC_DECL:
switch (child) {
case 0: return AST_STR(str_params);
case 1: return AST_STR(str_uses);
case 2: return AST_STR(str_stmts);
case 3: return AST_STR(str_returnType);
case 4: return AST_STR(str_attributes);
}
return NULL;
case ZEND_AST_CLOSURE:
switch (child) {
case 0: return AST_STR(str_params);
case 1: return AST_STR(str_uses);
case 2: return AST_STR(str_stmts);
case 3: return AST_STR(str_returnType);
case 4: return AST_STR(str_attributes);
}
return NULL;
case ZEND_AST_METHOD:
switch (child) {
case 0: return AST_STR(str_params);
case 1: return AST_STR(str_uses);
case 2: return AST_STR(str_stmts);
case 3: return AST_STR(str_returnType);
case 4: return AST_STR(str_attributes);
}
return NULL;
case ZEND_AST_ARROW_FUNC:
switch (child) {
case 0: return AST_STR(str_params);
Expand All @@ -287,114 +262,32 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
}
return NULL;
case ZEND_AST_MAGIC_CONST:
return NULL;
case ZEND_AST_TYPE:
return NULL;
case ZEND_AST_VAR:
switch (child) {
case 0: return AST_STR(str_name);
}
return NULL;
case ZEND_AST_CONST:
switch (child) {
case 0: return AST_STR(str_name);
}
return NULL;
case ZEND_AST_UNPACK:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_CAST:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_EMPTY:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_ISSET:
switch (child) {
case 0: return AST_STR(str_var);
}
return NULL;
case ZEND_AST_SHELL_EXEC:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_CLONE:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_EXIT:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_PRINT:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_INCLUDE_OR_EVAL:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_UNARY_OP:
case ZEND_AST_YIELD_FROM:
case ZEND_AST_RETURN:
case ZEND_AST_ECHO:
case ZEND_AST_THROW:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_ISSET:
case ZEND_AST_PRE_INC:
switch (child) {
case 0: return AST_STR(str_var);
}
return NULL;
case ZEND_AST_PRE_DEC:
switch (child) {
case 0: return AST_STR(str_var);
}
return NULL;
case ZEND_AST_POST_INC:
switch (child) {
case 0: return AST_STR(str_var);
}
return NULL;
case ZEND_AST_POST_DEC:
switch (child) {
case 0: return AST_STR(str_var);
}
return NULL;
case ZEND_AST_YIELD_FROM:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_GLOBAL:
switch (child) {
case 0: return AST_STR(str_var);
}
return NULL;
case ZEND_AST_UNSET:
switch (child) {
case 0: return AST_STR(str_var);
}
return NULL;
case ZEND_AST_RETURN:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_LABEL:
switch (child) {
case 0: return AST_STR(str_name);
}
return NULL;
case ZEND_AST_REF:
switch (child) {
case 0: return AST_STR(str_var);
Expand All @@ -405,26 +298,12 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
case 0: return AST_STR(str_offset);
}
return NULL;
case ZEND_AST_ECHO:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_THROW:
switch (child) {
case 0: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_GOTO:
switch (child) {
case 0: return AST_STR(str_label);
}
return NULL;
case ZEND_AST_BREAK:
switch (child) {
case 0: return AST_STR(str_depth);
}
return NULL;
case ZEND_AST_CONTINUE:
switch (child) {
case 0: return AST_STR(str_depth);
Expand All @@ -448,11 +327,6 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
}
return NULL;
case ZEND_AST_PROP:
switch (child) {
case 0: return AST_STR(str_expr);
case 1: return AST_STR(str_prop);
}
return NULL;
case ZEND_AST_NULLSAFE_PROP:
switch (child) {
case 0: return AST_STR(str_expr);
Expand All @@ -478,17 +352,7 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
}
return NULL;
case ZEND_AST_ASSIGN:
switch (child) {
case 0: return AST_STR(str_var);
case 1: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_ASSIGN_REF:
switch (child) {
case 0: return AST_STR(str_var);
case 1: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_ASSIGN_OP:
switch (child) {
case 0: return AST_STR(str_var);
Expand All @@ -502,12 +366,14 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
}
return NULL;
case ZEND_AST_ARRAY_ELEM:
case ZEND_AST_YIELD:
switch (child) {
case 0: return AST_STR(str_value);
case 1: return AST_STR(str_key);
}
return NULL;
case ZEND_AST_NEW:
case ZEND_AST_ATTRIBUTE:
switch (child) {
case 0: return AST_STR(str_class);
case 1: return AST_STR(str_args);
Expand All @@ -519,19 +385,17 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
case 1: return AST_STR(str_class);
}
return NULL;
case ZEND_AST_YIELD:
switch (child) {
case 0: return AST_STR(str_value);
case 1: return AST_STR(str_key);
}
return NULL;
case ZEND_AST_STATIC:
switch (child) {
case 0: return AST_STR(str_var);
case 1: return AST_STR(str_default);
}
return NULL;
case ZEND_AST_WHILE:
case ZEND_AST_IF_ELEM:
case ZEND_AST_SWITCH:
case ZEND_AST_SWITCH_CASE:
case ZEND_AST_MATCH:
switch (child) {
case 0: return AST_STR(str_cond);
case 1: return AST_STR(str_stmts);
Expand All @@ -543,24 +407,6 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
case 1: return AST_STR(str_cond);
}
return NULL;
case ZEND_AST_IF_ELEM:
switch (child) {
case 0: return AST_STR(str_cond);
case 1: return AST_STR(str_stmts);
}
return NULL;
case ZEND_AST_SWITCH:
switch (child) {
case 0: return AST_STR(str_cond);
case 1: return AST_STR(str_stmts);
}
return NULL;
case ZEND_AST_SWITCH_CASE:
switch (child) {
case 0: return AST_STR(str_cond);
case 1: return AST_STR(str_stmts);
}
return NULL;
case ZEND_AST_DECLARE:
switch (child) {
case 0: return AST_STR(str_declares);
Expand Down Expand Up @@ -630,18 +476,6 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
case 1: return AST_STR(str_uses);
}
return NULL;
case ZEND_AST_ATTRIBUTE:
switch (child) {
case 0: return AST_STR(str_class);
case 1: return AST_STR(str_args);
}
return NULL;
case ZEND_AST_MATCH:
switch (child) {
case 0: return AST_STR(str_cond);
case 1: return AST_STR(str_stmts);
}
return NULL;
case ZEND_AST_MATCH_ARM:
switch (child) {
case 0: return AST_STR(str_cond);
Expand All @@ -654,20 +488,7 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
case 1: return AST_STR(str_expr);
}
return NULL;
case ZEND_AST_ENUM_CASE:
switch (child) {
case 0: return AST_STR(str_name);
case 1: return AST_STR(str_expr);
case 2: return AST_STR(str_attributes);
}
return NULL;
case ZEND_AST_METHOD_CALL:
switch (child) {
case 0: return AST_STR(str_expr);
case 1: return AST_STR(str_method);
case 2: return AST_STR(str_args);
}
return NULL;
case ZEND_AST_NULLSAFE_METHOD_CALL:
switch (child) {
case 0: return AST_STR(str_expr);
Expand Down Expand Up @@ -719,6 +540,14 @@ zend_string *ast_kind_child_name(zend_ast_kind kind, uint32_t child) {
case 3: return AST_STR(str_stmts);
}
return NULL;
case ZEND_AST_ENUM_CASE:
switch (child) {
case 0: return AST_STR(str_name);
case 1: return AST_STR(str_expr);
case 2: return AST_STR(str_docComment);
case 3: return AST_STR(str_attributes);
}
return NULL;
case ZEND_AST_PARAM:
switch (child) {
case 0: return AST_STR(str_type);
Expand Down Expand Up @@ -830,7 +659,6 @@ void ast_register_kind_constants(INIT_FUNC_ARGS) {
REGISTER_NS_LONG_CONSTANT("ast", "AST_MATCH", ZEND_AST_MATCH, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_MATCH_ARM", ZEND_AST_MATCH_ARM, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_NAMED_ARG", ZEND_AST_NAMED_ARG, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_ENUM_CASE", ZEND_AST_ENUM_CASE, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_METHOD_CALL", ZEND_AST_METHOD_CALL, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_NULLSAFE_METHOD_CALL", ZEND_AST_NULLSAFE_METHOD_CALL, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_STATIC_CALL", ZEND_AST_STATIC_CALL, CONST_CS | CONST_PERSISTENT);
Expand All @@ -839,5 +667,6 @@ void ast_register_kind_constants(INIT_FUNC_ARGS) {
REGISTER_NS_LONG_CONSTANT("ast", "AST_CATCH", ZEND_AST_CATCH, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_FOR", ZEND_AST_FOR, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_FOREACH", ZEND_AST_FOREACH, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_ENUM_CASE", ZEND_AST_ENUM_CASE, CONST_CS | CONST_PERSISTENT);
REGISTER_NS_LONG_CONSTANT("ast", "AST_PARAM", ZEND_AST_PARAM, CONST_CS | CONST_PERSISTENT);
}
Loading