com php-src: Handle const expr __CLASS__ in trait : Zend/zend_compile.c
| From: | Nikita Popov | Date: | Mon, 21 Jul 2014 16:21:13 +0000 |
| Subject: | com php-src: Handle const expr __CLASS__ in trait : Zend/zend_compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-80939@lists.php.net to get a copy of this message | ||
Commit: f8ce5e6efc427fddb7f38a2288667825bb5fe9d2
Author: Nikita Popov <nikic@php.net> Mon, 21 Jul 2014 18:21:13 +0200
Parents: 61a6083e99c4f0d836f9488985a35e63a735d703
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=f8ce5e6efc427fddb7f38a2288667825bb5fe9d2
Log:
Handle const expr __CLASS__ in trait
Changed paths:
M Zend/zend_compile.c
Diff:
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 5139a11..a1ad07f 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -7553,6 +7553,23 @@ void zend_compile_const_expr_resolve_class_name(zend_ast **ast_ptr TSRMLS_DC)
{
*ast_ptr = zend_ast_create_zval(&result);
}
+void zend_compile_const_expr_magic_const(zend_ast **ast_ptr TSRMLS_DC) {
+ zend_ast *ast = *ast_ptr;
+ zend_class_entry *ce = CG(active_class_entry);
+
+ /* Other cases already resolved by constant folding */
+ ZEND_ASSERT(ast->attr == T_CLASS_C && ce && ZEND_CE_IS_TRAIT(ce));
+
+ {
+ zval const_zv;
+ ZVAL_STRING(&const_zv, "__CLASS__");
+ Z_TYPE_INFO(const_zv) = IS_CONSTANT_EX;
+
+ zend_ast_destroy(ast);
+ *ast_ptr = zend_ast_create_zval(&const_zv);
+ }
+}
+
void zend_compile_const_expr(zend_ast **ast_ptr TSRMLS_DC) {
zend_ast *ast = *ast_ptr;
if (ast == NULL || ast->kind == ZEND_AST_ZVAL) {
@@ -7580,6 +7597,9 @@ void zend_compile_const_expr(zend_ast **ast_ptr TSRMLS_DC) {
case ZEND_AST_RESOLVE_CLASS_NAME:
zend_compile_const_expr_resolve_class_name(ast_ptr TSRMLS_CC);
break;
+ case ZEND_AST_MAGIC_CONST:
+ zend_compile_const_expr_magic_const(ast_ptr TSRMLS_CC);
+ break;
}
}