1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 16:08:35 +02:00

Unify unpack checking in compile_special_func()

Instead of handling this separately for each specialized function,
do one check directly in zend_compile_special_func().
This commit is contained in:
Nikita Popov
2018-08-22 11:38:28 +02:00
parent 406b57ed01
commit 850b53df0e
+13 -9
View File
@@ -3380,7 +3380,7 @@ void zend_compile_dynamic_call(znode *result, znode *name_node, zend_ast *args_a
}
/* }}} */
static zend_bool zend_args_contain_unpack(zend_ast_list *args) /* {{{ */
static inline zend_bool zend_args_contain_unpack(zend_ast_list *args) /* {{{ */
{
uint32_t i;
for (i = 0; i < args->children; ++i) {
@@ -3397,7 +3397,7 @@ int zend_compile_func_strlen(znode *result, zend_ast_list *args) /* {{{ */
znode arg_node;
if ((CG(compiler_options) & ZEND_COMPILE_NO_BUILTIN_STRLEN)
|| args->children != 1 || args->child[0]->kind == ZEND_AST_UNPACK
|| args->children != 1
) {
return FAILURE;
}
@@ -3419,7 +3419,7 @@ int zend_compile_func_typecheck(znode *result, zend_ast_list *args, uint32_t typ
znode arg_node;
zend_op *opline;
if (args->children != 1 || args->child[0]->kind == ZEND_AST_UNPACK) {
if (args->children != 1) {
return FAILURE;
}
@@ -3439,7 +3439,7 @@ int zend_compile_func_cast(znode *result, zend_ast_list *args, uint32_t type) /*
znode arg_node;
zend_op *opline;
if (args->children != 1 || args->child[0]->kind == ZEND_AST_UNPACK) {
if (args->children != 1) {
return FAILURE;
}
@@ -3579,7 +3579,7 @@ int zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcna
{
znode arg_node;
if (args->children != 2 || zend_args_contain_unpack(args)) {
if (args->children != 2) {
return FAILURE;
}
@@ -3628,7 +3628,7 @@ int zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcnam
{
uint32_t i;
if (args->children < 1 || zend_args_contain_unpack(args)) {
if (args->children < 1) {
return FAILURE;
}
@@ -3787,7 +3787,7 @@ int zend_compile_func_count(znode *result, zend_ast_list *args) /* {{{ */
{
znode arg_node;
if (args->children != 1 || args->child[0]->kind == ZEND_AST_UNPACK) {
if (args->children != 1) {
return FAILURE;
}
@@ -3804,7 +3804,7 @@ int zend_compile_func_get_class(znode *result, zend_ast_list *args) /* {{{ */
} else {
znode arg_node;
if (args->children != 1 || args->child[0]->kind == ZEND_AST_UNPACK) {
if (args->children != 1) {
return FAILURE;
}
@@ -3830,7 +3830,7 @@ int zend_compile_func_gettype(znode *result, zend_ast_list *args) /* {{{ */
{
znode arg_node;
if (args->children != 1 || args->child[0]->kind == ZEND_AST_UNPACK) {
if (args->children != 1) {
return FAILURE;
}
@@ -3909,6 +3909,10 @@ int zend_try_compile_special_func(znode *result, zend_string *lcname, zend_ast_l
return FAILURE;
}
if (zend_args_contain_unpack(args)) {
return FAILURE;
}
if (zend_string_equals_literal(lcname, "strlen")) {
return zend_compile_func_strlen(result, args);
} else if (zend_string_equals_literal(lcname, "is_null")) {