@@ -460,7 +460,7 @@ void zend_del_literal(zend_op_array *op_array, int n) /* {{{ */
460460/* Common part of zend_add_literal and zend_append_individual_literal */
461461static inline void zend_insert_literal (zend_op_array * op_array , zval * zv , int literal_position ) /* {{{ */
462462{
463- if (Z_TYPE_P (zv ) == IS_STRING || Z_TYPE_P ( zv ) == IS_CONSTANT ) {
463+ if (Z_TYPE_P (zv ) == IS_STRING ) {
464464 zend_string_hash_val (Z_STR_P (zv ));
465465 Z_STR_P (zv ) = zend_new_interned_string (Z_STR_P (zv ));
466466 if (ZSTR_IS_INTERNED (Z_STR_P (zv ))) {
@@ -5518,8 +5518,9 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */
55185518 zend_bool allow_null ;
55195519 zend_bool has_null_default = default_ast
55205520 && (Z_TYPE (default_node .u .constant ) == IS_NULL
5521- || (Z_TYPE (default_node .u .constant ) == IS_CONSTANT
5522- && strcasecmp (Z_STRVAL (default_node .u .constant ), "NULL" ) == 0 ));
5521+ || (Z_TYPE (default_node .u .constant ) == IS_CONSTANT_AST
5522+ && Z_ASTVAL (default_node .u .constant )-> kind == ZEND_AST_CONSTANT
5523+ && strcasecmp (ZSTR_VAL (zend_ast_get_constant_name (Z_ASTVAL (default_node .u .constant ))), "NULL" ) == 0 ));
55235524 zend_bool is_explicitly_nullable = (type_ast -> attr & ZEND_TYPE_NULLABLE ) == ZEND_TYPE_NULLABLE ;
55245525
55255526 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) /* {{{ */
55365537 if (ZEND_TYPE_CODE (arg_info -> type ) == IS_ARRAY ) {
55375538 if (default_ast && !has_null_default
55385539 && Z_TYPE (default_node .u .constant ) != IS_ARRAY
5539- && ! Z_CONSTANT (default_node .u .constant )
5540+ && Z_TYPE (default_node .u .constant ) != IS_CONSTANT_AST
55405541 ) {
55415542 zend_error_noreturn (E_COMPILE_ERROR , "Default value for parameters "
55425543 "with array type can only be an array or NULL" );
55435544 }
55445545 } else if (ZEND_TYPE_CODE (arg_info -> type ) == IS_CALLABLE && default_ast ) {
5545- if (!has_null_default && ! Z_CONSTANT (default_node .u .constant )) {
5546+ if (!has_null_default && Z_TYPE (default_node .u .constant ) != IS_CONSTANT_AST ) {
55465547 zend_error_noreturn (E_COMPILE_ERROR , "Default value for parameters "
55475548 "with callable type can only be NULL" );
55485549 }
55495550 }
55505551 } else {
5551- if (default_ast && !has_null_default && ! Z_CONSTANT (default_node .u .constant )) {
5552+ if (default_ast && !has_null_default && Z_TYPE (default_node .u .constant ) != IS_CONSTANT_AST ) {
55525553 if (ZEND_TYPE_IS_CLASS (arg_info -> type )) {
55535554 zend_error_noreturn (E_COMPILE_ERROR , "Default value for parameters "
55545555 "with a class type can only be NULL" );
@@ -7916,6 +7917,7 @@ void zend_compile_const_expr_class_const(zend_ast **ast_ptr) /* {{{ */
79167917 zend_ast * const_ast = ast -> child [1 ];
79177918 zend_string * class_name ;
79187919 zend_string * const_name = zend_ast_get_str (const_ast );
7920+ zend_string * name ;
79197921 zval result ;
79207922 int fetch_type ;
79217923
@@ -7943,16 +7945,13 @@ void zend_compile_const_expr_class_const(zend_ast **ast_ptr) /* {{{ */
79437945 zend_string_addref (class_name );
79447946 }
79457947
7946- Z_STR ( result ) = zend_concat3 (
7948+ name = zend_concat3 (
79477949 ZSTR_VAL (class_name ), ZSTR_LEN (class_name ), "::" , 2 , ZSTR_VAL (const_name ), ZSTR_LEN (const_name ));
79487950
7949- Z_TYPE_INFO (result ) = IS_CONSTANT_EX ;
7950- Z_CONST_FLAGS (result ) = fetch_type ;
7951-
79527951 zend_ast_destroy (ast );
79537952 zend_string_release (class_name );
79547953
7955- * ast_ptr = zend_ast_create_zval ( & result );
7954+ * ast_ptr = zend_ast_create_constant ( name , fetch_type );
79567955}
79577956/* }}} */
79587957
@@ -7962,25 +7961,21 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr) /* {{{ */
79627961 zend_ast * name_ast = ast -> child [0 ];
79637962 zend_string * orig_name = zend_ast_get_str (name_ast );
79647963 zend_bool is_fully_qualified ;
7964+ zval result ;
7965+ zend_string * resolved_name ;
79657966
7966- zval result , resolved_name ;
7967- ZVAL_STR (& resolved_name , zend_resolve_const_name (
7968- orig_name , name_ast -> attr , & is_fully_qualified ));
7967+ resolved_name = zend_resolve_const_name (
7968+ orig_name , name_ast -> attr , & is_fully_qualified );
79697969
7970- if (zend_try_ct_eval_const (& result , Z_STR ( resolved_name ) , is_fully_qualified )) {
7971- zend_string_release (Z_STR ( resolved_name ) );
7970+ if (zend_try_ct_eval_const (& result , resolved_name , is_fully_qualified )) {
7971+ zend_string_release (resolved_name );
79727972 zend_ast_destroy (ast );
79737973 * ast_ptr = zend_ast_create_zval (& result );
79747974 return ;
79757975 }
79767976
7977- Z_TYPE_INFO (resolved_name ) = IS_CONSTANT_EX ;
7978- if (!is_fully_qualified ) {
7979- Z_CONST_FLAGS (resolved_name ) = IS_CONSTANT_UNQUALIFIED ;
7980- }
7981-
79827977 zend_ast_destroy (ast );
7983- * ast_ptr = zend_ast_create_zval ( & resolved_name );
7978+ * ast_ptr = zend_ast_create_constant ( resolved_name , ! is_fully_qualified ? IS_CONSTANT_UNQUALIFIED : 0 );
79847979}
79857980/* }}} */
79867981
@@ -7993,14 +7988,8 @@ void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */
79937988 CG (active_class_entry ) &&
79947989 (CG (active_class_entry )-> ce_flags & ZEND_ACC_TRAIT ) != 0 );
79957990
7996- {
7997- zval const_zv ;
7998- Z_STR (const_zv ) = zend_string_init ("__CLASS__" , sizeof ("__CLASS__" )- 1 , 0 );
7999- Z_TYPE_INFO (const_zv ) = IS_CONSTANT_EX | (IS_CONSTANT_CLASS << Z_CONST_FLAGS_SHIFT );
8000-
8001- zend_ast_destroy (ast );
8002- * ast_ptr = zend_ast_create_zval (& const_zv );
8003- }
7991+ zend_ast_destroy (ast );
7992+ * ast_ptr = zend_ast_create_ex (ZEND_AST_CONSTANT_CLASS , 0 );
80047993}
80057994/* }}} */
80067995
0 commit comments