cvs: ZendEngine2 / zend_compile.c zend_compile.h

From: Date: Fri, 25 Jul 2008 04:54:56 +0000
Subject: cvs: ZendEngine2 / zend_compile.c zend_compile.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-6938@lists.php.net to get a copy of this message
dmitry Fri Jul 25 04:54:56 2008 UTC Modified files: /ZendEngine2 zend_compile.c zend_compile.h Log: Substitute persistent constants by their values at compile time. (Matt) http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.c?r1=1.831&r2=1.832&diff_format=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.831 ZendEngine2/zend_compile.c:1.832 --- ZendEngine2/zend_compile.c:1.831 Thu Jul 24 19:50:22 2008 +++ ZendEngine2/zend_compile.c Fri Jul 25 04:54:56 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.831 2008/07/24 19:50:22 felipe Exp $ */ +/* $Id: zend_compile.c,v 1.832 2008/07/25 04:54:56 dmitry Exp $ */ #include <zend_language_parser.h> #include "zend.h" @@ -4009,6 +4009,13 @@ if (c->flags & CONST_CT_SUBST) { return c; } + if ((c->flags & CONST_PERSISTENT) && + !CG(current_namespace) && + !(CG(compiler_options) & ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION) && + Z_TYPE(c->value) != IS_CONSTANT && + Z_TYPE(c->value) != IS_CONSTANT_ARRAY) { + return c; + } return NULL; } /* }}} */ @@ -5546,12 +5553,14 @@ 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"); } - if (zend_get_ct_const(&name->u.constant TSRMLS_CC)) { + c = zend_get_ct_const(&name->u.constant TSRMLS_CC); + if (c && (c->flags & CONST_CT_SUBST)) { zend_error(E_COMPILE_ERROR, "Cannot redeclare constant '%R'", Z_TYPE(name->u.constant), Z_UNIVAL(name->u.constant)); } http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_compile.h?r1=1.383&r2=1.384&diff_format=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.383 ZendEngine2/zend_compile.h:1.384 --- ZendEngine2/zend_compile.h:1.383 Tue Jul 8 07:05:03 2008 +++ ZendEngine2/zend_compile.h Fri Jul 25 04:54:56 2008 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.383 2008/07/08 07:05:03 dmitry Exp $ */ +/* $Id: zend_compile.h,v 1.384 2008/07/25 04:54:56 dmitry Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -789,6 +789,9 @@ /* generate ZEND_DECLARE_INHERITED_CLASS_DELAYED opcode to delay early binding */ #define ZEND_COMPILE_DELAYED_BINDING (1<<4) +/* disable constant substitution at compile-time */ +#define ZEND_COMPILE_NO_CONSTANT_SUBSTITUTION (1<<5) + /* The default value for CG(compiler_options) */ #define ZEND_COMPILE_DEFAULT ZEND_COMPILE_HANDLE_OP_ARRAY

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