cvs: ZendEngine2(PHP_5_3) / zend_compile.c

From: Date: Thu, 31 Jul 2008 14:27:43 +0000
Subject: cvs: ZendEngine2(PHP_5_3) / zend_compile.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6979@lists.php.net to get a copy of this message
dmitry Thu Jul 31 14:27:43 2008 UTC Modified files: (Branch: PHP_5_3) /ZendEngine2 zend_compile.c Log: Fixed constant substitution in constant expression context http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.647.2.27.2.41.2.79&r2=1.647.2.27.2.41.2.80&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.79 ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.80 --- ZendEngine2/zend_compile.c:1.647.2.27.2.41.2.79 Mon Jul 28 14:12:19 2008 +++ ZendEngine2/zend_compile.c Thu Jul 31 14:27:43 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.79 2008/07/28 14:12:19 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.647.2.27.2.41.2.80 2008/07/31 14:27:43 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -3759,7 +3759,7 @@ *result = CG(active_op_array)->opcodes[new_token->u.opline_num].result; } -static zend_constant* zend_get_ct_const(zval *const_name TSRMLS_DC) /* {{{ */ +static zend_constant* zend_get_ct_const(zval *const_name, int mode TSRMLS_DC) /* {{{ */ { zend_constant *c = NULL; @@ -3778,7 +3778,8 @@ if (c->flags & CONST_CT_SUBST) { return c; } - if ((c->flags & CONST_PERSISTENT) && + if (mode == ZEND_RT && + (c->flags & CONST_PERSISTENT) && !CG(current_namespace) && !(CG(compiler_options) & ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION) && Z_TYPE(c->value) != IS_CONSTANT && @@ -3789,9 +3790,9 @@ } /* }}} */ -static int zend_constant_ct_subst(znode *result, zval *const_name TSRMLS_DC) /* {{{ */ +static int zend_constant_ct_subst(znode *result, zval *const_name, int mode TSRMLS_DC) /* {{{ */ { - zend_constant *c = zend_get_ct_const(const_name TSRMLS_CC); + zend_constant *c = zend_get_ct_const(const_name, mode TSRMLS_CC); if (c) { zval_dtor(const_name); @@ -3834,7 +3835,7 @@ zend_do_build_full_name(NULL, constant_container, constant_name TSRMLS_CC); *result = *constant_container; result->u.constant.type = IS_CONSTANT | fetch_type; - } else if (fetch_type || !zend_constant_ct_subst(result, &constant_name->u.constant TSRMLS_CC)) { + } else if (fetch_type || !zend_constant_ct_subst(result, &constant_name->u.constant, ZEND_CT TSRMLS_CC)) { if (check_namespace && CG(current_namespace)) { /* We assume we use constant from the current namespace if it is not prefixed. */ @@ -3851,7 +3852,7 @@ break; case ZEND_RT: if (constant_container || - !zend_constant_ct_subst(result, &constant_name->u.constant TSRMLS_CC)) { + !zend_constant_ct_subst(result, &constant_name->u.constant, ZEND_RT TSRMLS_CC)) { zend_op *opline; if (constant_container) { @@ -5152,14 +5153,12 @@ void zend_do_declare_constant(znode *name, znode *value TSRMLS_DC) /* {{{ */ { zend_op *opline; - zend_constant *c; if(Z_TYPE(value->u.constant) == IS_CONSTANT_ARRAY) { zend_error(E_COMPILE_ERROR, "Arrays are not allowed as constants"); } - c = zend_get_ct_const(&name->u.constant TSRMLS_CC); - if (c && (c->flags & CONST_CT_SUBST)) { + if (zend_get_ct_const(&name->u.constant, ZEND_CT TSRMLS_CC)) { zend_error(E_COMPILE_ERROR, "Cannot redeclare constant '%s'", Z_STRVAL(name->u.constant)); }

« previous php.zend-engine.cvs (#6979) next »