mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Store lineno for zval ast nodes more efficiently
This commit is contained in:
parent
d0943edf49
commit
21eb6807c9
5 changed files with 20 additions and 6 deletions
|
@ -40,8 +40,8 @@ ZEND_API zend_ast *zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr)
|
|||
zend_ast_zval *ast = zend_arena_alloc(&CG(ast_arena), sizeof(zend_ast_zval));
|
||||
ast->kind = ZEND_AST_ZVAL;
|
||||
ast->attr = attr;
|
||||
ast->lineno = CG(zend_lineno);
|
||||
ZVAL_COPY_VALUE(&ast->val, zv);
|
||||
ast->val.u2.lineno = CG(zend_lineno);
|
||||
return (zend_ast *) ast;
|
||||
}
|
||||
|
||||
|
@ -83,8 +83,11 @@ static zend_ast *zend_ast_create_from_va_list(
|
|||
|
||||
for (i = 0; i < children; ++i) {
|
||||
ast->child[i] = va_arg(va, zend_ast *);
|
||||
if (ast->child[i] != NULL && ast->child[i]->lineno < ast->lineno) {
|
||||
ast->lineno = ast->child[i]->lineno;
|
||||
if (ast->child[i] != NULL) {
|
||||
zend_uint lineno = zend_ast_get_lineno(ast->child[i]);
|
||||
if (lineno < ast->lineno) {
|
||||
ast->lineno = lineno;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -341,7 +344,6 @@ ZEND_API zend_ast *zend_ast_copy(zend_ast *ast)
|
|||
zend_ast_zval *copy = emalloc(sizeof(zend_ast_zval));
|
||||
copy->kind = ZEND_AST_ZVAL;
|
||||
copy->attr = ast->attr;
|
||||
copy->lineno = ast->lineno;
|
||||
ZVAL_DUP(©->val, zend_ast_get_zval(ast));
|
||||
return (zend_ast *) copy;
|
||||
} else {
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
+----------------------------------------------------------------------+
|
||||
| Authors: Bob Weinand <bwoebi@php.net> |
|
||||
| Dmitry Stogov <dmitry@zend.com> |
|
||||
| Nikita Popov <nikic@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
@ -141,7 +142,6 @@ struct _zend_ast {
|
|||
typedef struct _zend_ast_zval {
|
||||
zend_ast_kind kind;
|
||||
zend_ast_attr attr;
|
||||
zend_uint lineno;
|
||||
zval val;
|
||||
} zend_ast_zval;
|
||||
|
||||
|
@ -189,6 +189,14 @@ static inline zval *zend_ast_get_zval(zend_ast *ast) {
|
|||
static inline zend_string *zend_ast_get_str(zend_ast *ast) {
|
||||
return Z_STR_P(zend_ast_get_zval(ast));
|
||||
}
|
||||
static inline zend_uint zend_ast_get_lineno(zend_ast *ast) {
|
||||
if (ast->kind == ZEND_AST_ZVAL) {
|
||||
zval *zv = zend_ast_get_zval(ast);
|
||||
return zv->u2.lineno;
|
||||
} else {
|
||||
return ast->lineno;
|
||||
}
|
||||
}
|
||||
|
||||
static inline zend_ast *zend_ast_create_zval(zval *zv) {
|
||||
return zend_ast_create_zval_ex(zv, 0);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
| Nikita Popov <nikic@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
@ -7453,7 +7454,8 @@ void zend_compile_stmt(zend_ast *ast TSRMLS_DC) {
|
|||
}
|
||||
|
||||
void zend_compile_expr(znode *result, zend_ast *ast TSRMLS_DC) {
|
||||
CG(zend_lineno) = ast->lineno;
|
||||
//CG(zend_lineno) = ast->lineno;
|
||||
CG(zend_lineno) = zend_ast_get_lineno(ast);
|
||||
|
||||
switch (ast->kind) {
|
||||
case ZEND_AST_ZVAL:
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
+----------------------------------------------------------------------+
|
||||
| Authors: Andi Gutmans <andi@zend.com> |
|
||||
| Zeev Suraski <zeev@zend.com> |
|
||||
| Nikita Popov <nikic@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ struct _zval_struct {
|
|||
zend_uint next; /* hash collision chain */
|
||||
zend_uint str_offset; /* string offset */
|
||||
zend_uint cache_slot; /* literal cache slot */
|
||||
zend_uint lineno; /* line number (for ast nodes) */
|
||||
} u2;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue