cvs: ZendEngine2 / zend_compile.c

From: Date: Thu, 31 Jul 2008 14:27:55 +0000
Subject: cvs: ZendEngine2 / zend_compile.c
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6980@lists.php.net to get a copy of this message
dmitry Thu Jul 31 14:27:55 2008 UTC Modified files: /ZendEngine2 zend_compile.c Log: Fixed constant substitution in constant expression context http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.834&r2=1.835&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.834 ZendEngine2/zend_compile.c:1.835 --- ZendEngine2/zend_compile.c:1.834 Mon Jul 28 14:13:12 2008 +++ ZendEngine2/zend_compile.c Thu Jul 31 14:27:55 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.834 2008/07/28 14:13:12 dmitry Exp $ */ +/* $Id: zend_compile.c,v 1.835 2008/07/31 14:27:55 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -3963,7 +3963,7 @@ } /* }}} */ -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; @@ -3983,7 +3983,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 && @@ -3994,9 +3995,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); @@ -4039,7 +4040,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. */ @@ -4056,7 +4057,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) { @@ -5527,14 +5528,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 '%R'", Z_TYPE(name->u.constant), Z_UNIVAL(name->u.constant)); }

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