diff options
| author | Bob Weinand <bobwei9@hotmail.com> | 2016-04-21 01:26:48 +0200 |
|---|---|---|
| committer | Bob Weinand <bobwei9@hotmail.com> | 2016-04-21 01:26:48 +0200 |
| commit | 36202ef0569db9039c683cf8b2245ca54cd6da46 (patch) | |
| tree | 0030fbceb9fccf28c776a90faa03ec477d0f3e35 /Zend/zend_ast.c | |
| parent | dc3ab58c14cb58e33b8a0c5c7a181846eb8b4ff3 (diff) | |
| parent | 672a99597cce8b3ff133a8fddd44c1a9fc0158e5 (diff) | |
| download | php-git-36202ef0569db9039c683cf8b2245ca54cd6da46.tar.gz | |
Merge remote-tracking branch 'origin/PHP-7.0'
Diffstat (limited to 'Zend/zend_ast.c')
| -rw-r--r-- | Zend/zend_ast.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index cfcd636269..4d3678f0b6 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -337,6 +337,30 @@ ZEND_API int zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *sc zval_dtor(&op1); } break; + case ZEND_AST_COALESCE: + if (ast->child[0]->kind == ZEND_AST_DIM) { + ast->child[0]->attr = ZEND_DIM_IS; + } + + if (UNEXPECTED(zend_ast_evaluate(&op1, ast->child[0], scope) != SUCCESS)) { + ret = FAILURE; + break; + } + if (Z_TYPE(op1) > IS_NULL) { + *result = op1; + } else { + if (ast->child[1]->kind == ZEND_AST_DIM) { + ast->child[1]->attr = ZEND_DIM_IS; + } + + if (UNEXPECTED(zend_ast_evaluate(result, ast->child[1], scope) != SUCCESS)) { + zval_dtor(&op1); + ret = FAILURE; + break; + } + zval_dtor(&op1); + } + break; case ZEND_AST_UNARY_PLUS: if (UNEXPECTED(zend_ast_evaluate(&op2, ast->child[0], scope) != SUCCESS)) { ret = FAILURE; @@ -385,6 +409,14 @@ ZEND_API int zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *sc } break; case ZEND_AST_DIM: + if (ast->child[1] == NULL) { + zend_error_noreturn(E_COMPILE_ERROR, "Cannot use [] for reading"); + } + + if (ast->attr == ZEND_DIM_IS && ast->child[0]->kind == ZEND_AST_DIM) { + ast->child[0]->attr = ZEND_DIM_IS; + } + if (UNEXPECTED(zend_ast_evaluate(&op1, ast->child[0], scope) != SUCCESS)) { ret = FAILURE; } else if (UNEXPECTED(zend_ast_evaluate(&op2, ast->child[1], scope) != SUCCESS)) { @@ -393,7 +425,12 @@ ZEND_API int zend_ast_evaluate(zval *result, zend_ast *ast, zend_class_entry *sc } else { zval tmp; - zend_fetch_dimension_by_zval(&tmp, &op1, &op2); + if (ast->attr == ZEND_DIM_IS) { + zend_fetch_dimension_by_zval_is(&tmp, &op1, &op2, IS_CONST); + } else { + zend_fetch_dimension_by_zval(&tmp, &op1, &op2); + } + if (UNEXPECTED(Z_ISREF(tmp))) { ZVAL_DUP(result, Z_REFVAL(tmp)); } else { |
