Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
47 changes: 25 additions & 22 deletions Zend/zend_ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -1139,19 +1139,22 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
{
zend_function *fptr;
zend_class_entry *called_scope = NULL;

zend_ast *args_ast = zend_ast_call_get_args(ast);
ZEND_ASSERT(args_ast && args_ast->kind == ZEND_AST_CALLABLE_CONVERT);

zend_ast_fcc *fcc_ast = (zend_ast_fcc*)args_ast;

zend_ast_list *args = zend_ast_get_list(fcc_ast->args);
ZEND_ASSERT(args->children > 0);
if (args->children != 1 || args->child[0]->attr != ZEND_PLACEHOLDER_VARIADIC) {
/* TODO: PFAs */
zend_error_noreturn(E_COMPILE_ERROR, "Constant expression contains invalid operations");
return FAILURE;
}

switch (ast->kind) {
case ZEND_AST_CALL: {
ZEND_ASSERT(ast->child[1]->kind == ZEND_AST_CALLABLE_CONVERT);
zend_ast_fcc *fcc_ast = (zend_ast_fcc*)ast->child[1];

zend_ast_list *args = zend_ast_get_list(fcc_ast->args);
ZEND_ASSERT(args->children > 0);
if (args->children != 1 || args->child[0]->attr != ZEND_PLACEHOLDER_VARIADIC) {
/* TODO: PFAs */
zend_error_noreturn(E_COMPILE_ERROR, "Constant expression contains invalid operations");
return FAILURE;
}

fptr = ZEND_MAP_PTR_GET(fcc_ast->fptr);

if (!fptr) {
Expand All @@ -1176,17 +1179,6 @@ static zend_result ZEND_FASTCALL zend_ast_evaluate_inner(
break;
}
case ZEND_AST_STATIC_CALL: {
ZEND_ASSERT(ast->child[2]->kind == ZEND_AST_CALLABLE_CONVERT);
zend_ast_fcc *fcc_ast = (zend_ast_fcc*)ast->child[2];

zend_ast_list *args = zend_ast_get_list(fcc_ast->args);
ZEND_ASSERT(args->children > 0);
if (args->children != 1 || args->child[0]->attr != ZEND_PLACEHOLDER_VARIADIC) {
/* TODO: PFAs */
zend_error_noreturn(E_COMPILE_ERROR, "Constant expression contains invalid operations");
return FAILURE;
}

zend_class_entry *ce = zend_ast_fetch_class(ast->child[0], scope);
if (!ce) {
return FAILURE;
Expand Down Expand Up @@ -3083,3 +3075,14 @@ zend_ast * ZEND_FASTCALL zend_ast_with_attributes(zend_ast *ast, zend_ast *attr)

return ast;
}

zend_ast * ZEND_FASTCALL zend_ast_call_get_args(zend_ast *ast)
{
if (ast->kind == ZEND_AST_CALL) {
return ast->child[1];
} else if (ast->kind == ZEND_AST_STATIC_CALL || ast->kind == ZEND_AST_METHOD_CALL) {
return ast->child[2];
}

return NULL;
}
2 changes: 2 additions & 0 deletions Zend/zend_ast.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,4 +440,6 @@ static zend_always_inline zend_ast *zend_ast_list_rtrim(zend_ast *ast) {

zend_ast * ZEND_FASTCALL zend_ast_with_attributes(zend_ast *ast, zend_ast *attr);

zend_ast * ZEND_FASTCALL zend_ast_call_get_args(zend_ast *ast);

#endif
Loading