mirror of
https://github.com/php/php-src.git
synced 2024-09-21 09:57:23 +00:00
Move adjust_for_fetch_type directly after emission
And drop the distinction between compile_X and compile_X_common. This avoids WTF moments like compile_simple_var_no_cv completely ignoring the BP_VAR type passed to it...
This commit is contained in:
parent
d9da166649
commit
9fbb019848
@ -2610,6 +2610,7 @@ static zend_op *zend_compile_simple_var_no_cv(znode *result, zend_ast *ast, uint
|
||||
opline->extended_value = ZEND_FETCH_LOCAL;
|
||||
}
|
||||
|
||||
zend_adjust_for_fetch_type(opline, type);
|
||||
return opline;
|
||||
}
|
||||
/* }}} */
|
||||
@ -2630,8 +2631,7 @@ static void zend_compile_simple_var(znode *result, zend_ast *ast, uint32_t type,
|
||||
if (is_this_fetch(ast)) {
|
||||
zend_emit_op(result, ZEND_FETCH_THIS, NULL, NULL);
|
||||
} else if (zend_try_compile_cv(result, ast) == FAILURE) {
|
||||
zend_op *opline = zend_compile_simple_var_no_cv(result, ast, type, delayed);
|
||||
zend_adjust_for_fetch_type(opline, type);
|
||||
zend_compile_simple_var_no_cv(result, ast, type, delayed);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
@ -2672,6 +2672,7 @@ static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t
|
||||
{
|
||||
zend_ast *var_ast = ast->child[0];
|
||||
zend_ast *dim_ast = ast->child[1];
|
||||
zend_op *opline;
|
||||
|
||||
znode var_node, dim_node;
|
||||
|
||||
@ -2691,11 +2692,13 @@ static zend_op *zend_delayed_compile_dim(znode *result, zend_ast *ast, uint32_t
|
||||
zend_handle_numeric_op(&dim_node);
|
||||
}
|
||||
|
||||
return zend_delayed_emit_op(result, ZEND_FETCH_DIM_R, &var_node, &dim_node);
|
||||
opline = zend_delayed_emit_op(result, ZEND_FETCH_DIM_R, &var_node, &dim_node);
|
||||
zend_adjust_for_fetch_type(opline, type);
|
||||
return opline;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static inline zend_op *zend_compile_dim_common(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
|
||||
static zend_op *zend_compile_dim(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
|
||||
{
|
||||
uint32_t offset = zend_delayed_compile_begin();
|
||||
zend_delayed_compile_dim(result, ast, type);
|
||||
@ -2703,13 +2706,6 @@ static inline zend_op *zend_compile_dim_common(znode *result, zend_ast *ast, uin
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void zend_compile_dim(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
|
||||
{
|
||||
zend_op *opline = zend_compile_dim_common(result, ast, type);
|
||||
zend_adjust_for_fetch_type(opline, type);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
|
||||
{
|
||||
zend_ast *obj_ast = ast->child[0];
|
||||
@ -2732,11 +2728,12 @@ static zend_op *zend_delayed_compile_prop(znode *result, zend_ast *ast, uint32_t
|
||||
zend_alloc_polymorphic_cache_slot(opline->op2.constant);
|
||||
}
|
||||
|
||||
zend_adjust_for_fetch_type(opline, type);
|
||||
return opline;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static zend_op *zend_compile_prop_common(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
|
||||
static zend_op *zend_compile_prop(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
|
||||
{
|
||||
uint32_t offset = zend_delayed_compile_begin();
|
||||
zend_delayed_compile_prop(result, ast, type);
|
||||
@ -2744,14 +2741,7 @@ static zend_op *zend_compile_prop_common(znode *result, zend_ast *ast, uint32_t
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void zend_compile_prop(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
|
||||
{
|
||||
zend_op *opline = zend_compile_prop_common(result, ast, type);
|
||||
zend_adjust_for_fetch_type(opline, type);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
zend_op *zend_compile_static_prop_common(znode *result, zend_ast *ast, uint32_t type, int delayed) /* {{{ */
|
||||
zend_op *zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t type, int delayed) /* {{{ */
|
||||
{
|
||||
zend_ast *class_ast = ast->child[0];
|
||||
zend_ast *prop_ast = ast->child[1];
|
||||
@ -2780,14 +2770,8 @@ zend_op *zend_compile_static_prop_common(znode *result, zend_ast *ast, uint32_t
|
||||
SET_NODE(opline->op2, &class_node);
|
||||
}
|
||||
|
||||
return opline;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
void zend_compile_static_prop(znode *result, zend_ast *ast, uint32_t type, int delayed) /* {{{ */
|
||||
{
|
||||
zend_op *opline = zend_compile_static_prop_common(result, ast, type, delayed);
|
||||
zend_adjust_for_fetch_type(opline, type);
|
||||
return opline;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -4306,15 +4290,15 @@ void zend_compile_unset(zend_ast *ast) /* {{{ */
|
||||
}
|
||||
return;
|
||||
case ZEND_AST_DIM:
|
||||
opline = zend_compile_dim_common(NULL, var_ast, BP_VAR_UNSET);
|
||||
opline = zend_compile_dim(NULL, var_ast, BP_VAR_UNSET);
|
||||
opline->opcode = ZEND_UNSET_DIM;
|
||||
return;
|
||||
case ZEND_AST_PROP:
|
||||
opline = zend_compile_prop_common(NULL, var_ast, BP_VAR_UNSET);
|
||||
opline = zend_compile_prop(NULL, var_ast, BP_VAR_UNSET);
|
||||
opline->opcode = ZEND_UNSET_OBJ;
|
||||
return;
|
||||
case ZEND_AST_STATIC_PROP:
|
||||
opline = zend_compile_static_prop_common(NULL, var_ast, BP_VAR_UNSET, 0);
|
||||
opline = zend_compile_static_prop(NULL, var_ast, BP_VAR_UNSET, 0);
|
||||
opline->opcode = ZEND_UNSET_STATIC_PROP;
|
||||
return;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
@ -7194,7 +7178,7 @@ void zend_compile_post_incdec(znode *result, zend_ast *ast) /* {{{ */
|
||||
zend_ensure_writable_variable(var_ast);
|
||||
|
||||
if (var_ast->kind == ZEND_AST_PROP) {
|
||||
zend_op *opline = zend_compile_prop_common(NULL, var_ast, BP_VAR_RW);
|
||||
zend_op *opline = zend_compile_prop(NULL, var_ast, BP_VAR_RW);
|
||||
opline->opcode = ast->kind == ZEND_AST_POST_INC ? ZEND_POST_INC_OBJ : ZEND_POST_DEC_OBJ;
|
||||
zend_make_tmp_result(result, opline);
|
||||
} else {
|
||||
@ -7214,7 +7198,7 @@ void zend_compile_pre_incdec(znode *result, zend_ast *ast) /* {{{ */
|
||||
zend_ensure_writable_variable(var_ast);
|
||||
|
||||
if (var_ast->kind == ZEND_AST_PROP) {
|
||||
zend_op *opline = zend_compile_prop_common(result, var_ast, BP_VAR_RW);
|
||||
zend_op *opline = zend_compile_prop(result, var_ast, BP_VAR_RW);
|
||||
opline->opcode = ast->kind == ZEND_AST_PRE_INC ? ZEND_PRE_INC_OBJ : ZEND_PRE_DEC_OBJ;
|
||||
} else {
|
||||
znode var_node;
|
||||
@ -7490,15 +7474,15 @@ void zend_compile_isset_or_empty(znode *result, zend_ast *ast) /* {{{ */
|
||||
}
|
||||
break;
|
||||
case ZEND_AST_DIM:
|
||||
opline = zend_compile_dim_common(result, var_ast, BP_VAR_IS);
|
||||
opline = zend_compile_dim(result, var_ast, BP_VAR_IS);
|
||||
opline->opcode = ZEND_ISSET_ISEMPTY_DIM_OBJ;
|
||||
break;
|
||||
case ZEND_AST_PROP:
|
||||
opline = zend_compile_prop_common(result, var_ast, BP_VAR_IS);
|
||||
opline = zend_compile_prop(result, var_ast, BP_VAR_IS);
|
||||
opline->opcode = ZEND_ISSET_ISEMPTY_PROP_OBJ;
|
||||
break;
|
||||
case ZEND_AST_STATIC_PROP:
|
||||
opline = zend_compile_static_prop_common(result, var_ast, BP_VAR_IS, 0);
|
||||
opline = zend_compile_static_prop(result, var_ast, BP_VAR_IS, 0);
|
||||
opline->opcode = ZEND_ISSET_ISEMPTY_STATIC_PROP;
|
||||
break;
|
||||
EMPTY_SWITCH_DEFAULT_CASE()
|
||||
@ -8363,18 +8347,15 @@ void zend_compile_var(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
|
||||
|
||||
void zend_delayed_compile_var(znode *result, zend_ast *ast, uint32_t type) /* {{{ */
|
||||
{
|
||||
zend_op *opline;
|
||||
switch (ast->kind) {
|
||||
case ZEND_AST_VAR:
|
||||
zend_compile_simple_var(result, ast, type, 1);
|
||||
return;
|
||||
case ZEND_AST_DIM:
|
||||
opline = zend_delayed_compile_dim(result, ast, type);
|
||||
zend_adjust_for_fetch_type(opline, type);
|
||||
zend_delayed_compile_dim(result, ast, type);
|
||||
return;
|
||||
case ZEND_AST_PROP:
|
||||
opline = zend_delayed_compile_prop(result, ast, type);
|
||||
zend_adjust_for_fetch_type(opline, type);
|
||||
zend_delayed_compile_prop(result, ast, type);
|
||||
return;
|
||||
case ZEND_AST_STATIC_PROP:
|
||||
zend_compile_static_prop(result, ast, type, 1);
|
||||
|
Loading…
Reference in New Issue
Block a user