diff options
author | Dmitry Stogov <dmitry@php.net> | 2008-07-25 04:54:08 +0000 |
---|---|---|
committer | Dmitry Stogov <dmitry@php.net> | 2008-07-25 04:54:08 +0000 |
commit | ed2d3e4c7ede51ba6102afd50301ab3c06280d3a (patch) | |
tree | e88b9eb22cbbfcb9103c534c9dc7635fc7c91da1 /Zend/zend_compile.c | |
parent | bb35ab45bb7a3f8eb9f6120cf80f8a9ae95ef3f7 (diff) | |
download | php-git-ed2d3e4c7ede51ba6102afd50301ab3c06280d3a.tar.gz |
Substitute persistent constants by their values at compile time. (Matt)
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r-- | Zend/zend_compile.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 48e5eb967a..afd0d851a7 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -3804,6 +3804,13 @@ static zend_constant* zend_get_ct_const(zval *const_name TSRMLS_DC) /* {{{ */ 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; } /* }}} */ @@ -5171,12 +5178,14 @@ void zend_do_use(znode *ns_name, znode *new_name, int is_global TSRMLS_DC) /* {{ 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 '%s'", Z_STRVAL(name->u.constant)); } |