diff options
| author | Dmitry Stogov <dmitry@zend.com> | 2015-03-18 15:31:29 +0300 |
|---|---|---|
| committer | Dmitry Stogov <dmitry@zend.com> | 2015-03-18 15:33:56 +0300 |
| commit | 4e110954381e9f4f2ad0354702409b1b2f89cf94 (patch) | |
| tree | 196ca8aef094f58b56fed3c98c9f2672b6ed7aaf /Zend/zend_compile.c | |
| parent | 65b7f4860e7e8a67c1a4fa54ceb02f04228bd588 (diff) | |
| download | php-git-4e110954381e9f4f2ad0354702409b1b2f89cf94.tar.gz | |
Reimplemented special constant handling. Now __HALT_COMPILER_OFFSET__ is resolved at compile-time. __CLASS__ retrived using separate ZEND_FETCH_CLASS_NAME opcode.
Diffstat (limited to 'Zend/zend_compile.c')
| -rw-r--r-- | Zend/zend_compile.c | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index f2de2c74d8..962bb14b42 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -5975,6 +5975,22 @@ void zend_compile_const(znode *result, zend_ast *ast) /* {{{ */ return; } + if (zend_string_equals_literal(resolved_name, "__COMPILER_HALT_OFFSET__")) { + zend_ast *last = CG(ast); + + while (last->kind == ZEND_AST_STMT_LIST) { + zend_ast_list *list = zend_ast_get_list(last); + last = list->child[list->children-1]; + } + if (last->kind == ZEND_AST_HALT_COMPILER) { + result->op_type = IS_CONST; + ZVAL_LONG(&result->u.constant, + Z_LVAL_P(zend_ast_get_zval(last->child[0]))); + zend_string_release(resolved_name); + return; + } + } + opline = zend_emit_op_tmp(result, ZEND_FETCH_CONSTANT, NULL, NULL); opline->op2_type = IS_CONST; @@ -6161,12 +6177,7 @@ void zend_compile_magic_const(znode *result, zend_ast *ast) /* {{{ */ CG(active_class_entry) && (CG(active_class_entry)->ce_flags & ZEND_ACC_TRAIT) != 0); - { - zend_ast *const_ast = zend_ast_create(ZEND_AST_CONST, - zend_ast_create_zval_from_str(zend_string_init("__CLASS__", sizeof("__CLASS__") - 1, 0))); - zend_compile_const(result, const_ast); - zend_ast_destroy(const_ast); - } + zend_emit_op_tmp(result, ZEND_FETCH_CLASS_NAME, NULL, NULL); } /* }}} */ @@ -6298,8 +6309,8 @@ void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */ { zval const_zv; - ZVAL_STRING(&const_zv, "__CLASS__"); - Z_TYPE_INFO(const_zv) = IS_CONSTANT_EX; + Z_STR(const_zv) = zend_string_init("__CLASS__", sizeof("__CLASS__")-1, 0); + Z_TYPE_INFO(const_zv) = IS_CONSTANT_EX | (IS_CONSTANT_CLASS << Z_CONST_FLAGS_SHIFT); zend_ast_destroy(ast); *ast_ptr = zend_ast_create_zval(&const_zv); |
