Skip to content

Commit 359acf6

Browse files
committed
feat: Address review feedback for GH-10497
Pass type parameter to zend_compile_const() instead of bool use_tmp Check BP_VAR_R/BP_VAR_IS for read mode Remove unnecessary wrapper function Return void instead of zend_op*
1 parent a73fc46 commit 359acf6

1 file changed

Lines changed: 7 additions & 13 deletions

File tree

Zend/zend_compile.c

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11309,7 +11309,7 @@ static void zend_compile_array(znode *result, zend_ast *ast) /* {{{ */
1130911309
}
1131011310
/* }}} */
1131111311

11312-
static zend_op *zend_compile_const_inner(znode *result, const zend_ast *ast, bool use_tmp) /* {{{ */
11312+
static void zend_compile_const(znode *result, const zend_ast *ast, uint32_t type) /* {{{ */
1131311313
{
1131411314
zend_ast *name_ast = ast->child[0];
1131511315

@@ -11333,17 +11333,17 @@ static zend_op *zend_compile_const_inner(znode *result, const zend_ast *ast, boo
1133311333
result->op_type = IS_CONST;
1133411334
ZVAL_LONG(&result->u.constant, Z_LVAL_P(zend_ast_get_zval(last->child[0])));
1133511335
zend_string_release_ex(resolved_name, 0);
11336-
return NULL;
11336+
return;
1133711337
}
1133811338
}
1133911339

1134011340
if (zend_try_ct_eval_const(&result->u.constant, resolved_name, is_fully_qualified)) {
1134111341
result->op_type = IS_CONST;
1134211342
zend_string_release_ex(resolved_name, 0);
11343-
return NULL;
11343+
return;
1134411344
}
1134511345

11346-
if (use_tmp) {
11346+
if (type == BP_VAR_R || type == BP_VAR_IS) {
1134711347
opline = zend_emit_op_tmp(result, ZEND_FETCH_CONSTANT, NULL, NULL);
1134811348
} else {
1134911349
opline = zend_emit_op(result, ZEND_FETCH_CONSTANT, NULL, NULL);
@@ -11360,13 +11360,6 @@ static zend_op *zend_compile_const_inner(znode *result, const zend_ast *ast, boo
1136011360
resolved_name, true);
1136111361
}
1136211362
opline->extended_value = zend_alloc_cache_slot();
11363-
return opline;
11364-
}
11365-
/* }}} */
11366-
11367-
static void zend_compile_const(znode *result, const zend_ast *ast) /* {{{ */
11368-
{
11369-
zend_compile_const_inner(result, ast, true);
1137011363
}
1137111364
/* }}} */
1137211365

@@ -12229,7 +12222,7 @@ static void zend_compile_expr_inner(znode *result, zend_ast *ast) /* {{{ */
1222912222
zend_compile_array(result, ast);
1223012223
return;
1223112224
case ZEND_AST_CONST:
12232-
zend_compile_const(result, ast);
12225+
zend_compile_const(result, ast, BP_VAR_R);
1223312226
return;
1223412227
case ZEND_AST_CLASS_CONST:
1223512228
zend_compile_class_const(result, ast);
@@ -12326,7 +12319,8 @@ static zend_op *zend_compile_var_inner(znode *result, zend_ast *ast, uint32_t ty
1232612319
zend_compile_assign(result, ast, false, type);
1232712320
return NULL;
1232812321
case ZEND_AST_CONST:
12329-
return zend_compile_const_inner(result, ast, false);
12322+
zend_compile_const(result, ast, type);
12323+
return NULL;
1233012324
default:
1233112325
if (type == BP_VAR_W || type == BP_VAR_RW || type == BP_VAR_UNSET) {
1233212326
zend_error_noreturn(E_COMPILE_ERROR,

0 commit comments

Comments
 (0)