zend_compile.c: zend_is_variable(). Removed unnecessary checks. Naming according to internal logic.

This commit is contained in:
rjhdby 2019-01-26 14:10:03 +03:00 committed by Joe Watkins
parent 9be6b16983
commit 3a0fc00424
No known key found for this signature in database
GPG Key ID: F9BA0ADA31CBD89E

View File

@ -2081,9 +2081,7 @@ void zend_emit_final_return(int return_one) /* {{{ */
static inline zend_bool zend_is_variable(zend_ast *ast) /* {{{ */
{
return ast->kind == ZEND_AST_VAR || ast->kind == ZEND_AST_DIM
|| ast->kind == ZEND_AST_PROP || ast->kind == ZEND_AST_STATIC_PROP
|| ast->kind == ZEND_AST_CALL || ast->kind == ZEND_AST_METHOD_CALL
|| ast->kind == ZEND_AST_STATIC_CALL;
|| ast->kind == ZEND_AST_PROP || ast->kind == ZEND_AST_STATIC_PROP;
}
/* }}} */
@ -2095,6 +2093,12 @@ static inline zend_bool zend_is_call(zend_ast *ast) /* {{{ */
}
/* }}} */
static inline zend_bool zend_is_variable_or_call(zend_ast *ast) /* {{{ */
{
return zend_is_variable(ast) || zend_is_call(ast);
}
/* }}} */
static inline zend_bool zend_is_unticked_stmt(zend_ast *ast) /* {{{ */
{
return ast->kind == ZEND_AST_STMT_LIST || ast->kind == ZEND_AST_LABEL
@ -2109,7 +2113,7 @@ static inline zend_bool zend_can_write_to_variable(zend_ast *ast) /* {{{ */
ast = ast->child[0];
}
return zend_is_variable(ast);
return zend_is_variable_or_call(ast);
}
/* }}} */
@ -2607,7 +2611,7 @@ zend_bool zend_is_assign_to_self(zend_ast *var_ast, zend_ast *expr_ast) /* {{{ *
return 0;
}
while (zend_is_variable(var_ast) && var_ast->kind != ZEND_AST_VAR) {
while (zend_is_variable_or_call(var_ast)) {
var_ast = var_ast->child[0];
}
@ -2741,7 +2745,7 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
return;
case ZEND_AST_ARRAY:
if (zend_propagate_list_refs(var_ast)) {
if (!zend_is_variable(expr_ast)) {
if (!zend_is_variable_or_call(expr_ast)) {
zend_error_noreturn(E_COMPILE_ERROR,
"Cannot assign reference to non referencable value");
}
@ -2938,7 +2942,7 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */
}
arg_count++;
if (zend_is_variable(arg)) {
if (zend_is_variable_or_call(arg)) {
if (zend_is_call(arg)) {
zend_compile_var(&arg_node, arg, BP_VAR_R, 0);
if (arg_node.op_type & (IS_CONST|IS_TMP_VAR)) {
@ -4228,7 +4232,7 @@ void zend_compile_return(zend_ast *ast) /* {{{ */
if (!expr_ast) {
expr_node.op_type = IS_CONST;
ZVAL_NULL(&expr_node.u.constant);
} else if (by_ref && zend_is_variable(expr_ast) && !zend_is_call(expr_ast)) {
} else if (by_ref && zend_is_variable(expr_ast)) {
zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1);
} else {
zend_compile_expr(&expr_node, expr_ast);
@ -4562,8 +4566,7 @@ void zend_compile_foreach(zend_ast *ast) /* {{{ */
zend_ast *key_ast = ast->child[2];
zend_ast *stmt_ast = ast->child[3];
zend_bool by_ref = value_ast->kind == ZEND_AST_REF;
zend_bool is_variable = zend_is_variable(expr_ast) && !zend_is_call(expr_ast)
&& zend_can_write_to_variable(expr_ast);
zend_bool is_variable = zend_is_variable(expr_ast) && zend_can_write_to_variable(expr_ast);
znode expr_node, reset_node, value_node, key_node;
zend_op *opline;
@ -7409,7 +7412,7 @@ void zend_compile_yield(znode *result, zend_ast *ast) /* {{{ */
}
if (value_ast) {
if (returns_by_ref && zend_is_variable(value_ast) && !zend_is_call(value_ast)) {
if (returns_by_ref && zend_is_variable(value_ast)) {
zend_compile_var(&value_node, value_ast, BP_VAR_W, 1);
} else {
zend_compile_expr(&value_node, value_ast);
@ -7499,7 +7502,7 @@ void zend_compile_isset_or_empty(znode *result, zend_ast *ast) /* {{{ */
ZEND_ASSERT(ast->kind == ZEND_AST_ISSET || ast->kind == ZEND_AST_EMPTY);
if (!zend_is_variable(var_ast) || zend_is_call(var_ast)) {
if (!zend_is_variable(var_ast)) {
if (ast->kind == ZEND_AST_EMPTY) {
/* empty(expr) can be transformed to !expr */
zend_ast *not_ast = zend_ast_create_ex(ZEND_AST_UNARY_OP, ZEND_BOOL_NOT, var_ast);