diff options
| author | Bob Weinand <bobwei9@hotmail.com> | 2016-04-21 02:50:14 +0200 |
|---|---|---|
| committer | Bob Weinand <bobwei9@hotmail.com> | 2016-04-21 02:50:14 +0200 |
| commit | ecf6392243b90e6c8f5597076b11b4959bac9dc1 (patch) | |
| tree | 33432c6f5c9abf21f19b1018e76970ff12d221c1 /Zend/zend_compile.c | |
| parent | 36202ef0569db9039c683cf8b2245ca54cd6da46 (diff) | |
| parent | 5053fc078d2ae8ac57f1d3ff84eb31a4b2e05108 (diff) | |
| download | php-git-ecf6392243b90e6c8f5597076b11b4959bac9dc1.tar.gz | |
Merge remote-tracking branch 'origin/PHP-7.0'
Diffstat (limited to 'Zend/zend_compile.c')
| -rw-r--r-- | Zend/zend_compile.c | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index 842fa64563..af2d2e95cb 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -7448,14 +7448,16 @@ void zend_const_expr_to_zval(zval *result, zend_ast *ast) /* {{{ */ zend_compile_const_expr(&ast); if (ast->kind == ZEND_AST_ZVAL) { ZVAL_COPY_VALUE(result, zend_ast_get_zval(ast)); - - /* Kill this branch of the original AST, as it was already destroyed. - * It would be nice to find a better solution to this problem in the - * future. */ - orig_ast->kind = 0; } else { ZVAL_NEW_AST(result, zend_ast_copy(ast)); + /* destroy the ast here, it might have been replaced */ + zend_ast_destroy(ast); } + + /* Kill this branch of the original AST, as it was already destroyed. + * It would be nice to find a better solution to this problem in the + * future. */ + orig_ast->kind = 0; } /* }}} */ @@ -7866,6 +7868,26 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */ return; } break; + case ZEND_AST_COALESCE: + zend_eval_const_expr(&ast->child[0]); + + if (ast->child[0]->kind != ZEND_AST_ZVAL) { + /* ensure everything was compile-time evaluated at least once */ + zend_eval_const_expr(&ast->child[1]); + return; + } + + if (Z_TYPE_P(zend_ast_get_zval(ast->child[0])) == IS_NULL) { + zend_eval_const_expr(&ast->child[1]); + *ast_ptr = ast->child[1]; + ast->child[1] = NULL; + zend_ast_destroy(ast); + } else { + *ast_ptr = ast->child[0]; + ast->child[0] = NULL; + zend_ast_destroy(ast); + } + return; case ZEND_AST_CONDITIONAL: { zend_ast **child, *child_ast; |
