diff options
author | Dmitry Stogov <dmitry@zend.com> | 2017-10-10 10:11:05 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2017-10-10 10:11:05 +0300 |
commit | ef5ea48741a1d227a10a6654c1a8cc2f02dd414f (patch) | |
tree | b00f4e9dd2ea42355c860a0ea57a0d9f4b926091 /Zend/zend_compile.c | |
parent | 08c0998b1ff1fa1a105eda1540a90ddb8ee4b16a (diff) | |
download | php-git-ef5ea48741a1d227a10a6654c1a8cc2f02dd414f.tar.gz |
Always use IS_CONSTANT_AST (IS_CONSTANT is removed).
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r-- | Zend/zend_compile.c | 49 |
1 files changed, 19 insertions, 30 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 2f73afcf9e..8d353b8c0a 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -460,7 +460,7 @@ void zend_del_literal(zend_op_array *op_array, int n) /* {{{ */ /* Common part of zend_add_literal and zend_append_individual_literal */ static inline void zend_insert_literal(zend_op_array *op_array, zval *zv, int literal_position) /* {{{ */ { - if (Z_TYPE_P(zv) == IS_STRING || Z_TYPE_P(zv) == IS_CONSTANT) { + if (Z_TYPE_P(zv) == IS_STRING) { zend_string_hash_val(Z_STR_P(zv)); Z_STR_P(zv) = zend_new_interned_string(Z_STR_P(zv)); if (ZSTR_IS_INTERNED(Z_STR_P(zv))) { @@ -5518,8 +5518,9 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ zend_bool allow_null; zend_bool has_null_default = default_ast && (Z_TYPE(default_node.u.constant) == IS_NULL - || (Z_TYPE(default_node.u.constant) == IS_CONSTANT - && strcasecmp(Z_STRVAL(default_node.u.constant), "NULL") == 0)); + || (Z_TYPE(default_node.u.constant) == IS_CONSTANT_AST + && Z_ASTVAL(default_node.u.constant)->kind == ZEND_AST_CONSTANT + && strcasecmp(ZSTR_VAL(zend_ast_get_constant_name(Z_ASTVAL(default_node.u.constant))), "NULL") == 0)); zend_bool is_explicitly_nullable = (type_ast->attr & ZEND_TYPE_NULLABLE) == ZEND_TYPE_NULLABLE; op_array->fn_flags |= ZEND_ACC_HAS_TYPE_HINTS; @@ -5536,19 +5537,19 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */ if (ZEND_TYPE_CODE(arg_info->type) == IS_ARRAY) { if (default_ast && !has_null_default && Z_TYPE(default_node.u.constant) != IS_ARRAY - && !Z_CONSTANT(default_node.u.constant) + && Z_TYPE(default_node.u.constant) != IS_CONSTANT_AST ) { zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters " "with array type can only be an array or NULL"); } } else if (ZEND_TYPE_CODE(arg_info->type) == IS_CALLABLE && default_ast) { - if (!has_null_default && !Z_CONSTANT(default_node.u.constant)) { + if (!has_null_default && Z_TYPE(default_node.u.constant) != IS_CONSTANT_AST) { zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters " "with callable type can only be NULL"); } } } else { - if (default_ast && !has_null_default && !Z_CONSTANT(default_node.u.constant)) { + if (default_ast && !has_null_default && Z_TYPE(default_node.u.constant) != IS_CONSTANT_AST) { if (ZEND_TYPE_IS_CLASS(arg_info->type)) { zend_error_noreturn(E_COMPILE_ERROR, "Default value for parameters " "with a class type can only be NULL"); @@ -7916,6 +7917,7 @@ void zend_compile_const_expr_class_const(zend_ast **ast_ptr) /* {{{ */ zend_ast *const_ast = ast->child[1]; zend_string *class_name; zend_string *const_name = zend_ast_get_str(const_ast); + zend_string *name; zval result; int fetch_type; @@ -7943,16 +7945,13 @@ void zend_compile_const_expr_class_const(zend_ast **ast_ptr) /* {{{ */ zend_string_addref(class_name); } - Z_STR(result) = zend_concat3( + name = zend_concat3( ZSTR_VAL(class_name), ZSTR_LEN(class_name), "::", 2, ZSTR_VAL(const_name), ZSTR_LEN(const_name)); - Z_TYPE_INFO(result) = IS_CONSTANT_EX; - Z_CONST_FLAGS(result) = fetch_type; - zend_ast_destroy(ast); zend_string_release(class_name); - *ast_ptr = zend_ast_create_zval(&result); + *ast_ptr = zend_ast_create_constant(name, fetch_type); } /* }}} */ @@ -7962,25 +7961,21 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr) /* {{{ */ zend_ast *name_ast = ast->child[0]; zend_string *orig_name = zend_ast_get_str(name_ast); zend_bool is_fully_qualified; + zval result; + zend_string *resolved_name; - zval result, resolved_name; - ZVAL_STR(&resolved_name, zend_resolve_const_name( - orig_name, name_ast->attr, &is_fully_qualified)); + resolved_name = zend_resolve_const_name( + orig_name, name_ast->attr, &is_fully_qualified); - if (zend_try_ct_eval_const(&result, Z_STR(resolved_name), is_fully_qualified)) { - zend_string_release(Z_STR(resolved_name)); + if (zend_try_ct_eval_const(&result, resolved_name, is_fully_qualified)) { + zend_string_release(resolved_name); zend_ast_destroy(ast); *ast_ptr = zend_ast_create_zval(&result); return; } - Z_TYPE_INFO(resolved_name) = IS_CONSTANT_EX; - if (!is_fully_qualified) { - Z_CONST_FLAGS(resolved_name) = IS_CONSTANT_UNQUALIFIED; - } - zend_ast_destroy(ast); - *ast_ptr = zend_ast_create_zval(&resolved_name); + *ast_ptr = zend_ast_create_constant(resolved_name, !is_fully_qualified ? IS_CONSTANT_UNQUALIFIED : 0); } /* }}} */ @@ -7993,14 +7988,8 @@ void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */ CG(active_class_entry) && (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) != 0); - { - zval const_zv; - Z_STR(const_zv) = zend_string_init("__CLASS__", sizeof("__CLASS__")-1, 0); - Z_TYPE_INFO(const_zv) = IS_CONSTANT_EX | (IS_CONSTANT_CLASS << Z_CONST_FLAGS_SHIFT); - - zend_ast_destroy(ast); - *ast_ptr = zend_ast_create_zval(&const_zv); - } + zend_ast_destroy(ast); + *ast_ptr = zend_ast_create_ex(ZEND_AST_CONSTANT_CLASS, 0); } /* }}} */ |