Skip to content

Commit a65e668

Browse files
committed
Use distinct constants for AST attrs, simplify placeholder types
1 parent 1ac09e0 commit a65e668

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

Zend/zend_ast.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,7 +1146,7 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
11461146

11471147
zend_ast_list *args = zend_ast_get_list(fcc_ast->args);
11481148
ZEND_ASSERT(args->children > 0);
1149-
if (args->children != 1 || args->child[0]->attr != _IS_PLACEHOLDER_VARIADIC) {
1149+
if (args->children != 1 || args->child[0]->attr != ZEND_PLACEHOLDER_VARIADIC) {
11501150
/* TODO: PFAs */
11511151
return FAILURE;
11521152
}
@@ -1180,7 +1180,7 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
11801180

11811181
zend_ast_list *args = zend_ast_get_list(fcc_ast->args);
11821182
ZEND_ASSERT(args->children > 0);
1183-
if (args->children != 1 || args->child[0]->attr != _IS_PLACEHOLDER_VARIADIC) {
1183+
if (args->children != 1 || args->child[0]->attr != ZEND_PLACEHOLDER_VARIADIC) {
11841184
/* TODO: PFAs */
11851185
return FAILURE;
11861186
}
@@ -2405,12 +2405,10 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
24052405
}
24062406
break;
24072407
case ZEND_AST_PLACEHOLDER_ARG:
2408-
if (ast->attr == _IS_PLACEHOLDER_ARG) {
2409-
APPEND_STR("?");
2410-
} else if (ast->attr == _IS_PLACEHOLDER_VARIADIC) {
2408+
if (ast->attr == ZEND_PLACEHOLDER_VARIADIC) {
24112409
APPEND_STR("...");
2412-
} else {
2413-
ZEND_UNREACHABLE();
2410+
} else {
2411+
APPEND_STR("?");
24142412
}
24152413
break;
24162414

Zend/zend_compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3951,7 +3951,7 @@ static bool zend_compile_call_common(znode *result, zend_ast *args_ast, const ze
39513951
}
39523952

39533953
zend_ast_list *args = zend_ast_get_list(((zend_ast_fcc*)args_ast)->args);
3954-
if (args->children != 1 || args->child[0]->attr != _IS_PLACEHOLDER_VARIADIC) {
3954+
if (args->children != 1 || args->child[0]->attr != ZEND_PLACEHOLDER_VARIADIC) {
39553955
zend_error_noreturn(E_COMPILE_ERROR, "Cannot create a Closure for call expression with more than one argument, or non-variadic placeholders");
39563956
}
39573957

Zend/zend_compile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,9 @@ static zend_always_inline bool zend_check_arg_send_type(const zend_function *zf,
12361236
#define ZEND_IS_BINARY_ASSIGN_OP_OPCODE(opcode) \
12371237
(((opcode) >= ZEND_ADD) && ((opcode) <= ZEND_POW))
12381238

1239+
/* PFAs/FCCs */
1240+
#define ZEND_PLACEHOLDER_VARIADIC (1<<0)
1241+
12391242
/* Pseudo-opcodes that are used only temporarily during compilation */
12401243
#define ZEND_GOTO 253
12411244
#define ZEND_BRK 254

Zend/zend_language_parser.y

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,11 +940,11 @@ argument_no_expr:
940940
identifier ':' expr
941941
{ $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1, $3); }
942942
| T_ELLIPSIS
943-
{ $$ = zend_ast_create_ex(ZEND_AST_PLACEHOLDER_ARG, _IS_PLACEHOLDER_VARIADIC); }
943+
{ $$ = zend_ast_create_ex(ZEND_AST_PLACEHOLDER_ARG, ZEND_PLACEHOLDER_VARIADIC); }
944944
| '?'
945-
{ $$ = zend_ast_create_ex(ZEND_AST_PLACEHOLDER_ARG, _IS_PLACEHOLDER_ARG); }
945+
{ $$ = zend_ast_create(ZEND_AST_PLACEHOLDER_ARG); }
946946
| identifier ':' '?'
947-
{ $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1, zend_ast_create_ex(ZEND_AST_PLACEHOLDER_ARG, _IS_PLACEHOLDER_ARG)); }
947+
{ $$ = zend_ast_create(ZEND_AST_NAMED_ARG, $1, zend_ast_create(ZEND_AST_PLACEHOLDER_ARG)); }
948948
| T_ELLIPSIS expr
949949
{ $$ = zend_ast_create(ZEND_AST_UNPACK, $2); }
950950
;

Zend/zend_types.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,7 @@ struct _zend_ast_ref {
639639
#define _IS_NUMBER 19
640640

641641
/* used for PFAs/FCCs */
642-
#define _IS_PLACEHOLDER_ARG 20
643-
#define _IS_PLACEHOLDER_VARIADIC 21
642+
#define _IS_PLACEHOLDER 20
644643

645644
/* guard flags */
646645
#define ZEND_GUARD_PROPERTY_GET (1<<0)

0 commit comments

Comments
 (0)