mirror of
https://github.com/php/php-src.git
synced 2024-11-24 10:24:11 +08:00
Merge branch 'master' of git.php.net:php-src
* 'master' of git.php.net:php-src: Drop unused result argument Fix ct binding for cuf/cufa functions Fix detection of write to built-in function for references Test use of string names with \ prefix Add zend_add_literal_string Drop dead code
This commit is contained in:
commit
e8612b72ee
10
Zend/tests/builtin_in_write_context_error1.phpt
Normal file
10
Zend/tests/builtin_in_write_context_error1.phpt
Normal file
@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Cannot use built-in functions in write context (assignment)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
strlen("foo")[0] = 1;
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot use result of built-in function in write context in %s on line %d
|
10
Zend/tests/builtin_in_write_context_error2.phpt
Normal file
10
Zend/tests/builtin_in_write_context_error2.phpt
Normal file
@ -0,0 +1,10 @@
|
||||
--TEST--
|
||||
Cannot use built-in functions in write context (reference)
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$ref =& strlen("foo");
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: Cannot use result of built-in function in write context in %s on line %d
|
@ -34,6 +34,7 @@ $obj = new Test;
|
||||
['Test', 'id']()()('var_dump')(11);
|
||||
'id'()('id')('var_dump')(12);
|
||||
('i' . 'd')()('var_dump')(13);
|
||||
'\id'('var_dump')(14);
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
@ -51,3 +52,4 @@ int(10)
|
||||
int(11)
|
||||
int(12)
|
||||
int(13)
|
||||
int(14)
|
||||
|
@ -19,6 +19,7 @@ var_dump($A_str::$b);
|
||||
var_dump($A_obj::$b);
|
||||
var_dump(('A' . '')::$b);
|
||||
var_dump('A'::$b);
|
||||
var_dump('\A'::$b);
|
||||
var_dump('A'[0]::$b);
|
||||
var_dump(A::$$b_str);
|
||||
var_dump(A::$$c_str[1]);
|
||||
@ -33,5 +34,6 @@ int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(0)
|
||||
int(1)
|
||||
int(0)
|
||||
|
@ -319,82 +319,57 @@ int zend_add_literal(zend_op_array *op_array, zval *zv TSRMLS_DC) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_add_func_name_literal(zend_op_array *op_array, zval *zv TSRMLS_DC) /* {{{ */
|
||||
static inline int zend_add_literal_string(zend_op_array *op_array, zend_string **str TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int ret;
|
||||
zend_string *lc_name;
|
||||
zval c;
|
||||
|
||||
if (op_array->last_literal > 0 &&
|
||||
&op_array->literals[op_array->last_literal - 1] == zv &&
|
||||
Z_CACHE_SLOT(op_array->literals[op_array->last_literal - 1]) == -1) {
|
||||
/* we already have function name as last literal (do nothing) */
|
||||
ret = op_array->last_literal - 1;
|
||||
} else {
|
||||
ret = zend_add_literal(op_array, zv TSRMLS_CC);
|
||||
}
|
||||
|
||||
lc_name = zend_string_alloc(Z_STRLEN_P(zv), 0);
|
||||
zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRLEN_P(zv));
|
||||
ZVAL_NEW_STR(&c, lc_name);
|
||||
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
|
||||
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_add_ns_func_name_literal(zend_op_array *op_array, zval *zv TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int ret;
|
||||
zend_string *lc_name;
|
||||
const char *ns_separator;
|
||||
int lc_len;
|
||||
zval c;
|
||||
|
||||
if (op_array->last_literal > 0 &&
|
||||
&op_array->literals[op_array->last_literal - 1] == zv &&
|
||||
Z_CACHE_SLOT(op_array->literals[op_array->last_literal - 1]) == -1) {
|
||||
/* we already have function name as last literal (do nothing) */
|
||||
ret = op_array->last_literal - 1;
|
||||
} else {
|
||||
ret = zend_add_literal(op_array, zv TSRMLS_CC);
|
||||
}
|
||||
|
||||
lc_name = zend_string_alloc(Z_STRLEN_P(zv), 0);
|
||||
zend_str_tolower_copy(lc_name->val, Z_STRVAL_P(zv), Z_STRLEN_P(zv));
|
||||
ZVAL_NEW_STR(&c, lc_name);
|
||||
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
|
||||
|
||||
ns_separator = (const char*)zend_memrchr(Z_STRVAL_P(zv), '\\', Z_STRLEN_P(zv));
|
||||
|
||||
if (ns_separator != NULL) {
|
||||
ns_separator += 1;
|
||||
lc_len = Z_STRLEN_P(zv) - (ns_separator - Z_STRVAL_P(zv));
|
||||
lc_name = zend_string_alloc(lc_len, 0);
|
||||
zend_str_tolower_copy(lc_name->val, ns_separator, lc_len);
|
||||
ZVAL_NEW_STR(&c, lc_name);
|
||||
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_add_class_name_literal(zend_op_array *op_array, zend_string *name TSRMLS_DC) /* {{{ */ {
|
||||
int ret;
|
||||
zend_string *lc_name;
|
||||
|
||||
zval zv;
|
||||
ZVAL_STR(&zv, name);
|
||||
|
||||
ZVAL_STR(&zv, *str);
|
||||
ret = zend_add_literal(op_array, &zv TSRMLS_CC);
|
||||
name = Z_STR(zv); /* Load new name string in case it was interned */
|
||||
*str = Z_STR(zv);
|
||||
return ret;
|
||||
}
|
||||
|
||||
lc_name = zend_string_alloc(name->len, 0);
|
||||
static int zend_add_func_name_literal(zend_op_array *op_array, zend_string *name TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int ret = zend_add_literal_string(op_array, &name TSRMLS_CC);
|
||||
|
||||
zend_string *lc_name = zend_string_alloc(name->len, 0);
|
||||
zend_str_tolower_copy(lc_name->val, name->val, name->len);
|
||||
zend_add_literal_string(op_array, &lc_name TSRMLS_CC);
|
||||
|
||||
ZVAL_NEW_STR(&zv, lc_name);
|
||||
zend_add_literal(CG(active_op_array), &zv TSRMLS_CC);
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_add_ns_func_name_literal(zend_op_array *op_array, zend_string *name TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
const char *ns_separator;
|
||||
|
||||
int ret = zend_add_literal_string(op_array, &name TSRMLS_CC);
|
||||
|
||||
zend_string *lc_name = zend_string_alloc(name->len, 0);
|
||||
zend_str_tolower_copy(lc_name->val, name->val, name->len);
|
||||
zend_add_literal_string(op_array, &lc_name TSRMLS_CC);
|
||||
|
||||
ns_separator = zend_memrchr(name->val, '\\', name->len);
|
||||
if (ns_separator != NULL) {
|
||||
size_t len = name->len - (ns_separator - name->val + 1);
|
||||
lc_name = zend_string_alloc(len, 0);
|
||||
zend_str_tolower_copy(lc_name->val, ns_separator + 1, len);
|
||||
zend_add_literal_string(op_array, &lc_name TSRMLS_CC);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_add_class_name_literal(zend_op_array *op_array, zend_string *name TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int ret = zend_add_literal_string(op_array, &name TSRMLS_CC);
|
||||
|
||||
zend_string *lc_name = zend_string_alloc(name->len, 0);
|
||||
zend_str_tolower_copy(lc_name->val, name->val, name->len);
|
||||
zend_add_literal_string(op_array, &lc_name TSRMLS_CC);
|
||||
|
||||
zend_alloc_cache_slot(ret TSRMLS_CC);
|
||||
|
||||
@ -402,72 +377,44 @@ static int zend_add_class_name_literal(zend_op_array *op_array, zend_string *nam
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_add_const_name_literal(zend_op_array *op_array, zval *zv, int unqualified TSRMLS_DC) /* {{{ */
|
||||
static int zend_add_const_name_literal(zend_op_array *op_array, zend_string *name, zend_bool unqualified TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
int ret;
|
||||
char *name;
|
||||
zend_string *tmp_name;
|
||||
const char *ns_separator;
|
||||
int name_len, ns_len;
|
||||
zval c;
|
||||
|
||||
if (op_array->last_literal > 0 &&
|
||||
&op_array->literals[op_array->last_literal - 1] == zv &&
|
||||
Z_CACHE_SLOT(op_array->literals[op_array->last_literal - 1]) == -1) {
|
||||
/* we already have function name as last literal (do nothing) */
|
||||
ret = op_array->last_literal - 1;
|
||||
} else {
|
||||
ret = zend_add_literal(op_array, zv TSRMLS_CC);
|
||||
}
|
||||
int ret = zend_add_literal_string(op_array, &name TSRMLS_CC);
|
||||
|
||||
/* skip leading '\\' */
|
||||
if (Z_STRVAL_P(zv)[0] == '\\') {
|
||||
name_len = Z_STRLEN_P(zv) - 1;
|
||||
name = Z_STRVAL_P(zv) + 1;
|
||||
} else {
|
||||
name_len = Z_STRLEN_P(zv);
|
||||
name = Z_STRVAL_P(zv);
|
||||
}
|
||||
ns_separator = zend_memrchr(name, '\\', name_len);
|
||||
if (ns_separator) {
|
||||
ns_len = ns_separator - name;
|
||||
} else {
|
||||
ns_len = 0;
|
||||
}
|
||||
size_t ns_len = 0, after_ns_len = name->len;
|
||||
const char *after_ns = zend_memrchr(name->val, '\\', name->len);
|
||||
if (after_ns) {
|
||||
after_ns += 1;
|
||||
ns_len = after_ns - name->val - 1;
|
||||
after_ns_len = name->len - ns_len - 1;
|
||||
|
||||
if (ns_len) {
|
||||
/* lowercased namespace name & original constant name */
|
||||
tmp_name = zend_string_init(name, name_len, 0);
|
||||
tmp_name = zend_string_init(name->val, name->len, 0);
|
||||
zend_str_tolower(tmp_name->val, ns_len);
|
||||
ZVAL_NEW_STR(&c, tmp_name);
|
||||
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
|
||||
zend_add_literal_string(op_array, &tmp_name TSRMLS_CC);
|
||||
|
||||
/* lowercased namespace name & lowercased constant name */
|
||||
tmp_name = zend_string_alloc(name_len, 0);
|
||||
zend_str_tolower_copy(tmp_name->val, name, name_len);
|
||||
ZVAL_NEW_STR(&c, tmp_name);
|
||||
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
|
||||
}
|
||||
tmp_name = zend_string_alloc(name->len, 0);
|
||||
zend_str_tolower_copy(tmp_name->val, name->val, name->len);
|
||||
zend_add_literal_string(op_array, &tmp_name TSRMLS_CC);
|
||||
|
||||
if (ns_len) {
|
||||
if (!unqualified) {
|
||||
return ret;
|
||||
}
|
||||
ns_len++;
|
||||
name += ns_len;
|
||||
name_len -= ns_len;
|
||||
} else {
|
||||
after_ns = name->val;
|
||||
}
|
||||
|
||||
/* original constant name */
|
||||
tmp_name = zend_string_init(name, name_len, 0);
|
||||
ZVAL_NEW_STR(&c, tmp_name);
|
||||
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
|
||||
/* original unqualified constant name */
|
||||
tmp_name = zend_string_init(after_ns, after_ns_len, 0);
|
||||
zend_add_literal_string(op_array, &tmp_name TSRMLS_CC);
|
||||
|
||||
/* lowercased constant name */
|
||||
tmp_name = zend_string_alloc(name_len, 0);
|
||||
zend_str_tolower_copy(tmp_name->val, name, name_len);
|
||||
ZVAL_NEW_STR(&c, tmp_name);
|
||||
zend_add_literal(CG(active_op_array), &c TSRMLS_CC);
|
||||
/* lowercased unqualified constant name */
|
||||
tmp_name = zend_string_alloc(after_ns_len, 0);
|
||||
zend_str_tolower_copy(tmp_name->val, after_ns, after_ns_len);
|
||||
zend_add_literal_string(op_array, &tmp_name TSRMLS_CC);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -1226,14 +1173,12 @@ static zend_constant *zend_get_ct_const(zend_string *name, int all_internal_cons
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_constant_ct_subst(znode *result, zval *const_name, int all_internal_constants_substitution TSRMLS_DC) /* {{{ */
|
||||
static int zend_constant_ct_subst(zval *result, zend_string *name, int all_internal_constants_substitution TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_constant *c = zend_get_ct_const(Z_STR_P(const_name),
|
||||
all_internal_constants_substitution TSRMLS_CC);
|
||||
zend_constant *c = zend_get_ct_const(name, all_internal_constants_substitution TSRMLS_CC);
|
||||
|
||||
if (c) {
|
||||
result->op_type = IS_CONST;
|
||||
ZVAL_DUP(&result->u.constant, &c->value);
|
||||
ZVAL_DUP(result, &c->value);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -1389,9 +1334,6 @@ again:
|
||||
if (LANG_SCNG(yy_text)[LANG_SCNG(yy_leng)-1] != '>') {
|
||||
CG(increment_lineno) = 1;
|
||||
}
|
||||
if (CG(has_bracketed_namespaces) && !CG(in_namespace)) {
|
||||
goto again;
|
||||
}
|
||||
retval = ';'; /* implicit ; */
|
||||
break;
|
||||
case T_OPEN_TAG_WITH_ECHO:
|
||||
@ -2380,6 +2322,10 @@ void zend_compile_assign_ref(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
|
||||
zend_compile_var(&target_node, target_ast, BP_VAR_W TSRMLS_CC);
|
||||
zend_compile_var(&source_node, source_ast, BP_VAR_REF TSRMLS_CC);
|
||||
|
||||
if (source_node.op_type != IS_VAR && zend_is_call(source_ast)) {
|
||||
zend_error_noreturn(E_COMPILE_ERROR, "Cannot use result of built-in function in write context");
|
||||
}
|
||||
|
||||
opline = zend_emit_op(result, ZEND_ASSIGN_REF, &target_node, &source_node TSRMLS_CC);
|
||||
if (!result) {
|
||||
opline->result_type |= EXT_TYPE_UNUSED;
|
||||
@ -2593,7 +2539,7 @@ void zend_compile_ns_call(znode *result, znode *name_node, zend_ast *args_ast TS
|
||||
SET_UNUSED(opline->op1);
|
||||
opline->op2_type = IS_CONST;
|
||||
opline->op2.constant = zend_add_ns_func_name_literal(
|
||||
CG(active_op_array), &name_node->u.constant TSRMLS_CC);
|
||||
CG(active_op_array), Z_STR(name_node->u.constant) TSRMLS_CC);
|
||||
zend_alloc_cache_slot(opline->op2.constant TSRMLS_CC);
|
||||
|
||||
zend_compile_call_common(result, args_ast, NULL TSRMLS_CC);
|
||||
@ -2607,8 +2553,8 @@ void zend_compile_dynamic_call(znode *result, znode *name_node, zend_ast *args_a
|
||||
SET_UNUSED(opline->op1);
|
||||
if (name_node->op_type == IS_CONST && Z_TYPE(name_node->u.constant) == IS_STRING) {
|
||||
opline->op2_type = IS_CONST;
|
||||
opline->op2.constant
|
||||
= zend_add_func_name_literal(CG(active_op_array), &name_node->u.constant TSRMLS_CC);
|
||||
opline->op2.constant = zend_add_func_name_literal(CG(active_op_array),
|
||||
Z_STR(name_node->u.constant) TSRMLS_CC);
|
||||
zend_alloc_cache_slot(opline->op2.constant TSRMLS_CC);
|
||||
} else {
|
||||
SET_NODE(opline->op2, name_node);
|
||||
@ -2694,13 +2640,13 @@ int zend_compile_func_defined(znode *result, zend_ast_list *args TSRMLS_DC) /* {
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static int zend_try_compile_ct_bound_init_user_func(znode *result, zend_ast *name_ast, uint32_t num_args TSRMLS_DC) /* {{{ */
|
||||
static int zend_try_compile_ct_bound_init_user_func(zend_ast *name_ast, uint32_t num_args TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_string *name, *lcname;
|
||||
zend_function *fbc;
|
||||
zend_op *opline;
|
||||
|
||||
if (name_ast->kind != ZEND_AST_CONST || Z_TYPE_P(zend_ast_get_zval(name_ast)) != IS_STRING) {
|
||||
if (name_ast->kind != ZEND_AST_ZVAL || Z_TYPE_P(zend_ast_get_zval(name_ast)) != IS_STRING) {
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
@ -2717,20 +2663,22 @@ static int zend_try_compile_ct_bound_init_user_func(znode *result, zend_ast *nam
|
||||
}
|
||||
|
||||
opline = zend_emit_op(NULL, ZEND_INIT_FCALL, NULL, NULL TSRMLS_CC);
|
||||
opline->extended_value = num_args;
|
||||
|
||||
opline->op2_type = IS_CONST;
|
||||
LITERAL_STR(opline->op2, lcname);
|
||||
opline->extended_value = num_args;
|
||||
zend_alloc_cache_slot(opline->op2.constant TSRMLS_CC);
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
static void zend_compile_init_user_func(znode *result, zend_ast *name_ast, uint32_t num_args, zend_string *orig_func_name TSRMLS_DC) /* {{{ */
|
||||
static void zend_compile_init_user_func(zend_ast *name_ast, uint32_t num_args, zend_string *orig_func_name TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_op *opline;
|
||||
znode name_node;
|
||||
|
||||
if (zend_try_compile_ct_bound_init_user_func(result, name_ast, num_args TSRMLS_CC) == SUCCESS) {
|
||||
if (zend_try_compile_ct_bound_init_user_func(name_ast, num_args TSRMLS_CC) == SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2752,7 +2700,7 @@ int zend_compile_func_cufa(znode *result, zend_ast_list *args, zend_string *lcna
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
zend_compile_init_user_func(NULL, args->child[0], 1, lcname TSRMLS_CC);
|
||||
zend_compile_init_user_func(args->child[0], 1, lcname TSRMLS_CC);
|
||||
zend_compile_expr(&arg_node, args->child[1] TSRMLS_CC);
|
||||
zend_emit_op(NULL, ZEND_SEND_ARRAY, &arg_node, NULL TSRMLS_CC);
|
||||
zend_emit_op(result, ZEND_DO_FCALL, NULL, NULL TSRMLS_CC);
|
||||
@ -2770,7 +2718,7 @@ int zend_compile_func_cuf(znode *result, zend_ast_list *args, zend_string *lcnam
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
zend_compile_init_user_func(NULL, args->child[0], args->children - 1, lcname TSRMLS_CC);
|
||||
zend_compile_init_user_func(args->child[0], args->children - 1, lcname TSRMLS_CC);
|
||||
for (i = 1; i < args->children; ++i) {
|
||||
zend_ast *arg_ast = args->child[i];
|
||||
znode arg_node;
|
||||
@ -2920,8 +2868,8 @@ void zend_compile_method_call(znode *result, zend_ast *ast, uint32_t type TSRMLS
|
||||
}
|
||||
|
||||
opline->op2_type = IS_CONST;
|
||||
opline->op2.constant =
|
||||
zend_add_func_name_literal(CG(active_op_array), &method_node.u.constant TSRMLS_CC);
|
||||
opline->op2.constant = zend_add_func_name_literal(CG(active_op_array),
|
||||
Z_STR(method_node.u.constant) TSRMLS_CC);
|
||||
zend_alloc_polymorphic_cache_slot(opline->op2.constant TSRMLS_CC);
|
||||
} else {
|
||||
SET_NODE(opline->op2, &method_node);
|
||||
@ -2975,8 +2923,8 @@ void zend_compile_static_call(znode *result, zend_ast *ast, uint32_t type TSRMLS
|
||||
|
||||
if (method_node.op_type == IS_CONST) {
|
||||
opline->op2_type = IS_CONST;
|
||||
opline->op2.constant =
|
||||
zend_add_func_name_literal(CG(active_op_array), &method_node.u.constant TSRMLS_CC);
|
||||
opline->op2.constant = zend_add_func_name_literal(CG(active_op_array),
|
||||
Z_STR(method_node.u.constant) TSRMLS_CC);
|
||||
if (opline->op1_type == IS_CONST) {
|
||||
zend_alloc_cache_slot(opline->op2.constant TSRMLS_CC);
|
||||
} else {
|
||||
@ -5645,17 +5593,17 @@ void zend_compile_array(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
|
||||
void zend_compile_const(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_ast *name_ast = ast->child[0];
|
||||
zend_string *orig_name = zend_ast_get_str(name_ast);
|
||||
zend_bool is_fully_qualified;
|
||||
|
||||
zval resolved_name;
|
||||
zend_op *opline;
|
||||
|
||||
ZVAL_STR(&resolved_name, zend_resolve_const_name(
|
||||
orig_name, name_ast->attr, &is_fully_qualified TSRMLS_CC));
|
||||
zend_bool is_fully_qualified;
|
||||
zend_string *orig_name = zend_ast_get_str(name_ast);
|
||||
zend_string *resolved_name = zend_resolve_const_name(
|
||||
orig_name, name_ast->attr, &is_fully_qualified TSRMLS_CC);
|
||||
|
||||
if (zend_constant_ct_subst(result, &resolved_name, 1 TSRMLS_CC)) {
|
||||
zval_dtor(&resolved_name);
|
||||
if (zend_constant_ct_subst(&result->u.constant, resolved_name, 1 TSRMLS_CC)) {
|
||||
result->op_type = IS_CONST;
|
||||
zend_string_release(resolved_name);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -5664,16 +5612,16 @@ void zend_compile_const(znode *result, zend_ast *ast TSRMLS_DC) /* {{{ */
|
||||
|
||||
if (is_fully_qualified) {
|
||||
opline->op2.constant = zend_add_const_name_literal(
|
||||
CG(active_op_array), &resolved_name, 0 TSRMLS_CC);
|
||||
CG(active_op_array), resolved_name, 0 TSRMLS_CC);
|
||||
} else {
|
||||
opline->extended_value = IS_CONSTANT_UNQUALIFIED;
|
||||
if (CG(current_namespace)) {
|
||||
opline->extended_value |= IS_CONSTANT_IN_NAMESPACE;
|
||||
opline->op2.constant = zend_add_const_name_literal(
|
||||
CG(active_op_array), &resolved_name, 1 TSRMLS_CC);
|
||||
CG(active_op_array), resolved_name, 1 TSRMLS_CC);
|
||||
} else {
|
||||
opline->op2.constant = zend_add_const_name_literal(
|
||||
CG(active_op_array), &resolved_name, 0 TSRMLS_CC);
|
||||
CG(active_op_array), resolved_name, 0 TSRMLS_CC);
|
||||
}
|
||||
}
|
||||
zend_alloc_cache_slot(opline->op2.constant TSRMLS_CC);
|
||||
@ -5885,20 +5833,19 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_ast *ast = *ast_ptr;
|
||||
zend_ast *name_ast = ast->child[0];
|
||||
zval *orig_name = zend_ast_get_zval(name_ast);
|
||||
zend_string *orig_name = zend_ast_get_str(name_ast);
|
||||
zend_bool is_fully_qualified;
|
||||
|
||||
znode result;
|
||||
zval resolved_name;
|
||||
zval result, resolved_name;
|
||||
|
||||
if (zend_constant_ct_subst(&result, orig_name, 0 TSRMLS_CC)) {
|
||||
zend_ast_destroy(ast);
|
||||
*ast_ptr = zend_ast_create_zval(&result.u.constant);
|
||||
*ast_ptr = zend_ast_create_zval(&result);
|
||||
return;
|
||||
}
|
||||
|
||||
ZVAL_STR(&resolved_name, zend_resolve_const_name(
|
||||
Z_STR_P(orig_name), name_ast->attr, &is_fully_qualified TSRMLS_CC));
|
||||
orig_name, name_ast->attr, &is_fully_qualified TSRMLS_CC));
|
||||
|
||||
Z_TYPE_INFO(resolved_name) = IS_CONSTANT_EX;
|
||||
if (!is_fully_qualified) {
|
||||
@ -6380,16 +6327,11 @@ void zend_eval_const_expr(zend_ast **ast_ptr TSRMLS_DC) /* {{{ */
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case ZEND_AST_CONST: {
|
||||
znode result_node;
|
||||
|
||||
if (!zend_constant_ct_subst(&result_node, zend_ast_get_zval(ast->child[0]), 0 TSRMLS_CC)) {
|
||||
case ZEND_AST_CONST:
|
||||
if (!zend_constant_ct_subst(&result, zend_ast_get_str(ast->child[0]), 0 TSRMLS_CC)) {
|
||||
return;
|
||||
}
|
||||
zend_ast_destroy(ast);
|
||||
*ast_ptr = zend_ast_create_zval(&result_node.u.constant);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user