From: Nikita Popov Date: Sat, 12 Jul 2014 12:03:42 +0000 (+0200) Subject: Store (bad) estimate of lineno with ast X-Git-Tag: POST_AST_MERGE^2~151 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8577f58e525b285e816691668ea714b5b1fc78bc;p=php Store (bad) estimate of lineno with ast Currently not used yet --- diff --git a/Zend/zend_ast.c b/Zend/zend_ast.c index c07d435529..a1ebf7727d 100644 --- a/Zend/zend_ast.c +++ b/Zend/zend_ast.c @@ -25,18 +25,22 @@ ZEND_API zend_ast *zend_ast_create_znode(znode *node) { + TSRMLS_FETCH(); zend_ast_znode *ast = emalloc(sizeof(zend_ast_znode)); ast->kind = ZEND_AST_ZNODE; ast->attr = 0; + ast->lineno = CG(zend_lineno); ast->node = *node; return (zend_ast *) ast; } ZEND_API zend_ast *zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr) { + TSRMLS_FETCH(); zend_ast_zval *ast = emalloc(sizeof(zend_ast_zval)); ast->kind = ZEND_AST_ZVAL; ast->attr = attr; + ast->lineno = CG(zend_lineno); ZVAL_COPY_VALUE(&ast->val, zv); return (zend_ast *) ast; } @@ -44,11 +48,13 @@ ZEND_API zend_ast *zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr) static zend_ast *zend_ast_create_from_va_list( zend_uint children, zend_ast_kind kind, zend_ast_attr attr, va_list va ) { + TSRMLS_FETCH(); zend_uint i; zend_ast *ast = emalloc(sizeof(zend_ast) + (children - 1) * sizeof(zend_ast *)); ast->kind = kind; ast->attr = attr; + ast->lineno = CG(zend_lineno); ast->children = children; for (i = 0; i < children; ++i) { @@ -87,9 +93,11 @@ ZEND_API zend_ast *zend_ast_create( ZEND_API zend_ast *zend_ast_create_dynamic(zend_ast_kind kind) { /* use 4 children as default */ + TSRMLS_FETCH(); zend_ast *ast = emalloc(sizeof(zend_ast) + sizeof(zend_ast *) * 3); ast->kind = kind; ast->attr = 0; + ast->lineno = CG(zend_lineno); ast->children = 0; return ast; } diff --git a/Zend/zend_ast.h b/Zend/zend_ast.h index 410fce578a..59d383a64e 100644 --- a/Zend/zend_ast.h +++ b/Zend/zend_ast.h @@ -100,6 +100,7 @@ typedef unsigned short zend_ast_attr; struct _zend_ast { zend_ast_kind kind; /* Type of the node (either opcode or ZEND_AST_* constant) */ zend_ast_attr attr; /* Additional attribute, use depending on node type */ + zend_uint lineno; /* Line number */ zend_uint children; /* Number of children */ zend_ast *child[1]; /* Array of children (using struct hack) */ }; @@ -107,6 +108,7 @@ struct _zend_ast { typedef struct _zend_ast_zval { zend_ast_kind kind; zend_ast_attr attr; + zend_uint lineno; zval val; } zend_ast_zval; diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c index ccddfd616c..7e36b97018 100644 --- a/Zend/zend_compile.c +++ b/Zend/zend_compile.c @@ -8251,6 +8251,9 @@ void zend_compile_stmt(zend_ast *ast TSRMLS_DC) { return; } + // TODO.AST + //CG(zend_lineno) = ast->lineno; + switch (ast->kind) { case ZEND_AST_STMT_LIST: zend_compile_stmt_list(ast TSRMLS_CC); diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h index c7d3e06a83..268a793ec5 100644 --- a/Zend/zend_compile.h +++ b/Zend/zend_compile.h @@ -91,6 +91,7 @@ typedef struct _znode { /* used only during compilation */ typedef struct _zend_ast_znode { zend_ast_kind kind; zend_ast_attr attr; + zend_uint lineno; znode node; } zend_ast_znode; ZEND_API zend_ast *zend_ast_create_znode(znode *node);