mirror of
https://github.com/php/php-src.git
synced 2024-11-28 20:34:29 +08:00
zend_compile.c: zend_is_variable(). Removed unnecessary checks. Naming according to internal logic.
This commit is contained in:
parent
9be6b16983
commit
3a0fc00424
@ -2081,9 +2081,7 @@ void zend_emit_final_return(int return_one) /* {{{ */
|
|||||||
static inline zend_bool zend_is_variable(zend_ast *ast) /* {{{ */
|
static inline zend_bool zend_is_variable(zend_ast *ast) /* {{{ */
|
||||||
{
|
{
|
||||||
return ast->kind == ZEND_AST_VAR || ast->kind == ZEND_AST_DIM
|
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_PROP || ast->kind == ZEND_AST_STATIC_PROP;
|
||||||
|| ast->kind == ZEND_AST_CALL || ast->kind == ZEND_AST_METHOD_CALL
|
|
||||||
|| ast->kind == ZEND_AST_STATIC_CALL;
|
|
||||||
}
|
}
|
||||||
/* }}} */
|
/* }}} */
|
||||||
|
|
||||||
@ -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) /* {{{ */
|
static inline zend_bool zend_is_unticked_stmt(zend_ast *ast) /* {{{ */
|
||||||
{
|
{
|
||||||
return ast->kind == ZEND_AST_STMT_LIST || ast->kind == ZEND_AST_LABEL
|
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];
|
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;
|
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];
|
var_ast = var_ast->child[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2741,7 +2745,7 @@ void zend_compile_assign(znode *result, zend_ast *ast) /* {{{ */
|
|||||||
return;
|
return;
|
||||||
case ZEND_AST_ARRAY:
|
case ZEND_AST_ARRAY:
|
||||||
if (zend_propagate_list_refs(var_ast)) {
|
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,
|
zend_error_noreturn(E_COMPILE_ERROR,
|
||||||
"Cannot assign reference to non referencable value");
|
"Cannot assign reference to non referencable value");
|
||||||
}
|
}
|
||||||
@ -2938,7 +2942,7 @@ uint32_t zend_compile_args(zend_ast *ast, zend_function *fbc) /* {{{ */
|
|||||||
}
|
}
|
||||||
|
|
||||||
arg_count++;
|
arg_count++;
|
||||||
if (zend_is_variable(arg)) {
|
if (zend_is_variable_or_call(arg)) {
|
||||||
if (zend_is_call(arg)) {
|
if (zend_is_call(arg)) {
|
||||||
zend_compile_var(&arg_node, arg, BP_VAR_R, 0);
|
zend_compile_var(&arg_node, arg, BP_VAR_R, 0);
|
||||||
if (arg_node.op_type & (IS_CONST|IS_TMP_VAR)) {
|
if (arg_node.op_type & (IS_CONST|IS_TMP_VAR)) {
|
||||||
@ -4228,7 +4232,7 @@ void zend_compile_return(zend_ast *ast) /* {{{ */
|
|||||||
if (!expr_ast) {
|
if (!expr_ast) {
|
||||||
expr_node.op_type = IS_CONST;
|
expr_node.op_type = IS_CONST;
|
||||||
ZVAL_NULL(&expr_node.u.constant);
|
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);
|
zend_compile_var(&expr_node, expr_ast, BP_VAR_W, 1);
|
||||||
} else {
|
} else {
|
||||||
zend_compile_expr(&expr_node, expr_ast);
|
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 *key_ast = ast->child[2];
|
||||||
zend_ast *stmt_ast = ast->child[3];
|
zend_ast *stmt_ast = ast->child[3];
|
||||||
zend_bool by_ref = value_ast->kind == ZEND_AST_REF;
|
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_bool is_variable = zend_is_variable(expr_ast) && zend_can_write_to_variable(expr_ast);
|
||||||
&& zend_can_write_to_variable(expr_ast);
|
|
||||||
|
|
||||||
znode expr_node, reset_node, value_node, key_node;
|
znode expr_node, reset_node, value_node, key_node;
|
||||||
zend_op *opline;
|
zend_op *opline;
|
||||||
@ -7409,7 +7412,7 @@ void zend_compile_yield(znode *result, zend_ast *ast) /* {{{ */
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (value_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);
|
zend_compile_var(&value_node, value_ast, BP_VAR_W, 1);
|
||||||
} else {
|
} else {
|
||||||
zend_compile_expr(&value_node, value_ast);
|
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);
|
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) {
|
if (ast->kind == ZEND_AST_EMPTY) {
|
||||||
/* empty(expr) can be transformed to !expr */
|
/* empty(expr) can be transformed to !expr */
|
||||||
zend_ast *not_ast = zend_ast_create_ex(ZEND_AST_UNARY_OP, ZEND_BOOL_NOT, var_ast);
|
zend_ast *not_ast = zend_ast_create_ex(ZEND_AST_UNARY_OP, ZEND_BOOL_NOT, var_ast);
|
||||||
|
Loading…
Reference in New Issue
Block a user