mirror of
https://github.com/php/php-src.git
synced 2025-01-12 14:04:45 +08:00
Merge branch 'PHP-7.4'
This commit is contained in:
commit
6b7545c225
184
Zend/zend_ast.c
184
Zend/zend_ast.c
@ -45,75 +45,75 @@ static inline size_t zend_ast_list_size(uint32_t children) {
|
||||
return sizeof(zend_ast_list) - sizeof(zend_ast *) + sizeof(zend_ast *) * children;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(znode *node) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(zend_ast_loc *loc, znode *node) {
|
||||
zend_ast_znode *ast;
|
||||
|
||||
ast = zend_ast_alloc(sizeof(zend_ast_znode));
|
||||
ast->kind = ZEND_AST_ZNODE;
|
||||
ast->attr = 0;
|
||||
ast->lineno = CG(zend_lineno);
|
||||
ast->lineno = loc->start_line;
|
||||
ast->node = *node;
|
||||
return (zend_ast *) ast;
|
||||
}
|
||||
|
||||
static zend_always_inline zend_ast * zend_ast_create_zval_int(zval *zv, uint32_t attr, uint32_t lineno) {
|
||||
static zend_always_inline zend_ast * zend_ast_create_zval_int(
|
||||
zend_ast_loc *loc, zval *zv, uint32_t attr) {
|
||||
zend_ast_zval *ast;
|
||||
|
||||
ast = zend_ast_alloc(sizeof(zend_ast_zval));
|
||||
ast->kind = ZEND_AST_ZVAL;
|
||||
ast->attr = attr;
|
||||
ZVAL_COPY_VALUE(&ast->val, zv);
|
||||
Z_LINENO(ast->val) = lineno;
|
||||
Z_LINENO(ast->val) = loc->start_line;
|
||||
return (zend_ast *) ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(zval *zv, uint32_t lineno) {
|
||||
return zend_ast_create_zval_int(zv, 0, lineno);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(
|
||||
zend_ast_loc *loc, zval *zv, zend_ast_attr attr) {
|
||||
return zend_ast_create_zval_int(loc, zv, attr);
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr) {
|
||||
return zend_ast_create_zval_int(zv, attr, CG(zend_lineno));
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(zend_ast_loc *loc, zval *zv) {
|
||||
return zend_ast_create_zval_int(loc, zv, 0);
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(zval *zv) {
|
||||
return zend_ast_create_zval_int(zv, 0, CG(zend_lineno));
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str(zend_string *str) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str(zend_ast_loc *loc, zend_string *str) {
|
||||
zval zv;
|
||||
ZVAL_STR(&zv, str);
|
||||
return zend_ast_create_zval_int(&zv, 0, CG(zend_lineno));
|
||||
return zend_ast_create_zval_int(loc, &zv, 0);
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_long lval) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_ast_loc *loc, zend_long lval) {
|
||||
zval zv;
|
||||
ZVAL_LONG(&zv, lval);
|
||||
return zend_ast_create_zval_int(&zv, 0, CG(zend_lineno));
|
||||
return zend_ast_create_zval_int(loc, &zv, 0);
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(zend_string *name, zend_ast_attr attr) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(
|
||||
zend_ast_loc *loc, zend_string *name, zend_ast_attr attr) {
|
||||
zend_ast_zval *ast;
|
||||
|
||||
ast = zend_ast_alloc(sizeof(zend_ast_zval));
|
||||
ast->kind = ZEND_AST_CONSTANT;
|
||||
ast->attr = attr;
|
||||
ZVAL_STR(&ast->val, name);
|
||||
Z_LINENO(ast->val) = CG(zend_lineno);
|
||||
Z_LINENO(ast->val) = loc->start_line;
|
||||
return (zend_ast *) ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name(zend_ast *class_name, zend_ast *name) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name(
|
||||
zend_ast_loc *loc, zend_ast *class_name, zend_ast *name) {
|
||||
zend_string *name_str = zend_ast_get_str(name);
|
||||
if (zend_string_equals_literal_ci(name_str, "class")) {
|
||||
zend_string_release(name_str);
|
||||
return zend_ast_create(ZEND_AST_CLASS_NAME, class_name);
|
||||
return zend_ast_create(loc, ZEND_AST_CLASS_NAME, class_name);
|
||||
} else {
|
||||
return zend_ast_create(ZEND_AST_CLASS_CONST, class_name, name);
|
||||
return zend_ast_create(loc, ZEND_AST_CLASS_CONST, class_name, name);
|
||||
}
|
||||
}
|
||||
|
||||
ZEND_API zend_ast *zend_ast_create_decl(
|
||||
zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment,
|
||||
zend_ast_loc *loc, zend_ast_kind kind, uint32_t flags, zend_string *doc_comment,
|
||||
zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3
|
||||
) {
|
||||
zend_ast_decl *ast;
|
||||
@ -121,7 +121,7 @@ ZEND_API zend_ast *zend_ast_create_decl(
|
||||
ast = zend_ast_alloc(sizeof(zend_ast_decl));
|
||||
ast->kind = kind;
|
||||
ast->attr = 0;
|
||||
ast->start_lineno = start_lineno;
|
||||
ast->start_lineno = loc->start_line;
|
||||
ast->end_lineno = CG(zend_lineno);
|
||||
ast->flags = flags;
|
||||
ast->lex_pos = LANG_SCNG(yy_text);
|
||||
@ -136,41 +136,35 @@ ZEND_API zend_ast *zend_ast_create_decl(
|
||||
}
|
||||
|
||||
#if ZEND_AST_SPEC
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_0(zend_ast_kind kind) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_0(zend_ast_loc *loc, zend_ast_kind kind) {
|
||||
zend_ast *ast;
|
||||
|
||||
ZEND_ASSERT(kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 0);
|
||||
ast = zend_ast_alloc(zend_ast_size(0));
|
||||
ast->kind = kind;
|
||||
ast->attr = 0;
|
||||
ast->lineno = CG(zend_lineno);
|
||||
ast->lineno = loc->start_line;
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_1(zend_ast_kind kind, zend_ast *child) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_1(
|
||||
zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child) {
|
||||
zend_ast *ast;
|
||||
uint32_t lineno;
|
||||
|
||||
ZEND_ASSERT(kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 1);
|
||||
ast = zend_ast_alloc(zend_ast_size(1));
|
||||
ast->kind = kind;
|
||||
ast->attr = 0;
|
||||
ast->child[0] = child;
|
||||
if (child) {
|
||||
lineno = zend_ast_get_lineno(child);
|
||||
} else {
|
||||
lineno = CG(zend_lineno);
|
||||
}
|
||||
ast->lineno = lineno;
|
||||
ast->lineno = lineno;
|
||||
ast->lineno = loc->start_line;
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_2(
|
||||
zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child1, zend_ast *child2) {
|
||||
zend_ast *ast;
|
||||
uint32_t lineno;
|
||||
|
||||
ZEND_ASSERT(kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 2);
|
||||
ast = zend_ast_alloc(zend_ast_size(2));
|
||||
@ -178,21 +172,14 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_2(zend_ast_kind kind, zend_ast
|
||||
ast->attr = 0;
|
||||
ast->child[0] = child1;
|
||||
ast->child[1] = child2;
|
||||
if (child1) {
|
||||
lineno = zend_ast_get_lineno(child1);
|
||||
} else if (child2) {
|
||||
lineno = zend_ast_get_lineno(child2);
|
||||
} else {
|
||||
lineno = CG(zend_lineno);
|
||||
}
|
||||
ast->lineno = lineno;
|
||||
ast->lineno = loc->start_line;
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3(
|
||||
zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3) {
|
||||
zend_ast *ast;
|
||||
uint32_t lineno;
|
||||
|
||||
ZEND_ASSERT(kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 3);
|
||||
ast = zend_ast_alloc(zend_ast_size(3));
|
||||
@ -201,23 +188,14 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3(zend_ast_kind kind, zend_ast
|
||||
ast->child[0] = child1;
|
||||
ast->child[1] = child2;
|
||||
ast->child[2] = child3;
|
||||
if (child1) {
|
||||
lineno = zend_ast_get_lineno(child1);
|
||||
} else if (child2) {
|
||||
lineno = zend_ast_get_lineno(child2);
|
||||
} else if (child3) {
|
||||
lineno = zend_ast_get_lineno(child3);
|
||||
} else {
|
||||
lineno = CG(zend_lineno);
|
||||
}
|
||||
ast->lineno = lineno;
|
||||
ast->lineno = loc->start_line;
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4(
|
||||
zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4) {
|
||||
zend_ast *ast;
|
||||
uint32_t lineno;
|
||||
|
||||
ZEND_ASSERT(kind >> ZEND_AST_NUM_CHILDREN_SHIFT == 4);
|
||||
ast = zend_ast_alloc(zend_ast_size(4));
|
||||
@ -227,23 +205,12 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4(zend_ast_kind kind, zend_ast
|
||||
ast->child[1] = child2;
|
||||
ast->child[2] = child3;
|
||||
ast->child[3] = child4;
|
||||
if (child1) {
|
||||
lineno = zend_ast_get_lineno(child1);
|
||||
} else if (child2) {
|
||||
lineno = zend_ast_get_lineno(child2);
|
||||
} else if (child3) {
|
||||
lineno = zend_ast_get_lineno(child3);
|
||||
} else if (child4) {
|
||||
lineno = zend_ast_get_lineno(child4);
|
||||
} else {
|
||||
lineno = CG(zend_lineno);
|
||||
}
|
||||
ast->lineno = lineno;
|
||||
ast->lineno = loc->start_line;
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_0(zend_ast_kind kind) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_0(zend_ast_loc *loc, zend_ast_kind kind) {
|
||||
zend_ast *ast;
|
||||
zend_ast_list *list;
|
||||
|
||||
@ -251,16 +218,16 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_0(zend_ast_kind kind) {
|
||||
list = (zend_ast_list *) ast;
|
||||
list->kind = kind;
|
||||
list->attr = 0;
|
||||
list->lineno = CG(zend_lineno);
|
||||
list->lineno = loc->start_line;
|
||||
list->children = 0;
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_1(zend_ast_kind kind, zend_ast *child) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_1(
|
||||
zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child) {
|
||||
zend_ast *ast;
|
||||
zend_ast_list *list;
|
||||
uint32_t lineno;
|
||||
|
||||
ast = zend_ast_alloc(zend_ast_list_size(4));
|
||||
list = (zend_ast_list *) ast;
|
||||
@ -268,23 +235,15 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_1(zend_ast_kind kind, zen
|
||||
list->attr = 0;
|
||||
list->children = 1;
|
||||
list->child[0] = child;
|
||||
if (child) {
|
||||
lineno = zend_ast_get_lineno(child);
|
||||
if (lineno > CG(zend_lineno)) {
|
||||
lineno = CG(zend_lineno);
|
||||
}
|
||||
} else {
|
||||
lineno = CG(zend_lineno);
|
||||
}
|
||||
list->lineno = lineno;
|
||||
list->lineno = loc->start_line;
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2) {
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_2(
|
||||
zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child1, zend_ast *child2) {
|
||||
zend_ast *ast;
|
||||
zend_ast_list *list;
|
||||
uint32_t lineno;
|
||||
|
||||
ast = zend_ast_alloc(zend_ast_list_size(4));
|
||||
list = (zend_ast_list *) ast;
|
||||
@ -293,74 +252,49 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_2(zend_ast_kind kind, zen
|
||||
list->children = 2;
|
||||
list->child[0] = child1;
|
||||
list->child[1] = child2;
|
||||
if (child1) {
|
||||
lineno = zend_ast_get_lineno(child1);
|
||||
if (lineno > CG(zend_lineno)) {
|
||||
lineno = CG(zend_lineno);
|
||||
}
|
||||
} else if (child2) {
|
||||
lineno = zend_ast_get_lineno(child2);
|
||||
if (lineno > CG(zend_lineno)) {
|
||||
lineno = CG(zend_lineno);
|
||||
}
|
||||
} else {
|
||||
list->children = 0;
|
||||
lineno = CG(zend_lineno);
|
||||
}
|
||||
list->lineno = lineno;
|
||||
list->lineno = loc->start_line;
|
||||
|
||||
return ast;
|
||||
}
|
||||
#else
|
||||
static zend_ast *zend_ast_create_from_va_list(zend_ast_kind kind, zend_ast_attr attr, va_list va) {
|
||||
static zend_ast *zend_ast_create_from_va_list(
|
||||
zend_ast_loc *loc, zend_ast_kind kind, zend_ast_attr attr, va_list va) {
|
||||
uint32_t i, children = kind >> ZEND_AST_NUM_CHILDREN_SHIFT;
|
||||
zend_ast *ast;
|
||||
|
||||
ast = zend_ast_alloc(zend_ast_size(children));
|
||||
ast->kind = kind;
|
||||
ast->attr = attr;
|
||||
ast->lineno = (uint32_t) -1;
|
||||
|
||||
for (i = 0; i < children; ++i) {
|
||||
ast->child[i] = va_arg(va, zend_ast *);
|
||||
if (ast->child[i] != NULL) {
|
||||
uint32_t lineno = zend_ast_get_lineno(ast->child[i]);
|
||||
if (lineno < ast->lineno) {
|
||||
ast->lineno = lineno;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ast->lineno == UINT_MAX) {
|
||||
ast->lineno = CG(zend_lineno);
|
||||
}
|
||||
ast->lineno = loc->start_line;
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast *zend_ast_create_ex(zend_ast_kind kind, zend_ast_attr attr, ...) {
|
||||
ZEND_API zend_ast *zend_ast_create_ex(
|
||||
zend_ast_loc *loc, zend_ast_kind kind, zend_ast_attr attr, ...) {
|
||||
va_list va;
|
||||
zend_ast *ast;
|
||||
|
||||
va_start(va, attr);
|
||||
ast = zend_ast_create_from_va_list(kind, attr, va);
|
||||
ast = zend_ast_create_from_va_list(loc, kind, attr, va);
|
||||
va_end(va);
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast *zend_ast_create(zend_ast_kind kind, ...) {
|
||||
ZEND_API zend_ast *zend_ast_create(zend_ast_loc *loc, zend_ast_kind kind, ...) {
|
||||
va_list va;
|
||||
zend_ast *ast;
|
||||
|
||||
va_start(va, kind);
|
||||
ast = zend_ast_create_from_va_list(kind, 0, va);
|
||||
ast = zend_ast_create_from_va_list(loc, kind, 0, va);
|
||||
va_end(va);
|
||||
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...) {
|
||||
ZEND_API zend_ast *zend_ast_create_list(
|
||||
zend_ast_loc *loc, uint32_t init_children, zend_ast_kind kind, ...) {
|
||||
zend_ast *ast;
|
||||
zend_ast_list *list;
|
||||
|
||||
@ -368,7 +302,7 @@ ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind ki
|
||||
list = (zend_ast_list *) ast;
|
||||
list->kind = kind;
|
||||
list->attr = 0;
|
||||
list->lineno = CG(zend_lineno);
|
||||
list->lineno = loc->start_line;
|
||||
list->children = 0;
|
||||
|
||||
{
|
||||
@ -378,12 +312,6 @@ ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind ki
|
||||
for (i = 0; i < init_children; ++i) {
|
||||
zend_ast *child = va_arg(va, zend_ast *);
|
||||
ast = zend_ast_list_add(ast, child);
|
||||
if (child != NULL) {
|
||||
uint32_t lineno = zend_ast_get_lineno(child);
|
||||
if (lineno < ast->lineno) {
|
||||
ast->lineno = lineno;
|
||||
}
|
||||
}
|
||||
}
|
||||
va_end(va);
|
||||
}
|
||||
|
@ -196,78 +196,84 @@ typedef struct _zend_ast_decl {
|
||||
typedef void (*zend_ast_process_t)(zend_ast *ast);
|
||||
extern ZEND_API zend_ast_process_t zend_ast_process;
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_with_lineno(zval *zv, uint32_t lineno);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(zval *zv);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str(zend_string *str);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_long lval);
|
||||
typedef struct _zend_ast_loc {
|
||||
uint32_t start_line;
|
||||
} zend_ast_loc;
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(zend_string *name, zend_ast_attr attr);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name(zend_ast *class_name, zend_ast *name);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_ex(zend_ast_loc *loc, zval *zv, zend_ast_attr attr);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval(zend_ast_loc *loc, zval *zv);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_str(zend_ast_loc *loc, zend_string *str);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_ast_loc *loc, zend_long lval);
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(zend_ast_loc *loc, zend_string *name, zend_ast_attr attr);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name(zend_ast_loc *loc, zend_ast *class_name, zend_ast *name);
|
||||
|
||||
struct _znode;
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(zend_ast_loc *loc, struct _znode *node);
|
||||
|
||||
#if ZEND_AST_SPEC
|
||||
# define ZEND_AST_SPEC_CALL(name, ...) \
|
||||
ZEND_EXPAND_VA(ZEND_AST_SPEC_CALL_(name, __VA_ARGS__, _4, _3, _2, _1, _0)(__VA_ARGS__))
|
||||
# define ZEND_AST_SPEC_CALL_(name, _, _4, _3, _2, _1, suffix, ...) \
|
||||
# define ZEND_AST_SPEC_CALL_(name, _loc, _kind, _4, _3, _2, _1, suffix, ...) \
|
||||
name ## suffix
|
||||
# define ZEND_AST_SPEC_CALL_EX(name, ...) \
|
||||
ZEND_EXPAND_VA(ZEND_AST_SPEC_CALL_EX_(name, __VA_ARGS__, _4, _3, _2, _1, _0)(__VA_ARGS__))
|
||||
# define ZEND_AST_SPEC_CALL_EX_(name, _, _5, _4, _3, _2, _1, suffix, ...) \
|
||||
# define ZEND_AST_SPEC_CALL_EX_(name, _loc, _kind, _attr, _4, _3, _2, _1, suffix, ...) \
|
||||
name ## suffix
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_0(zend_ast_kind kind);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_1(zend_ast_kind kind, zend_ast *child);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4(zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_0(zend_ast_loc *loc, zend_ast_kind kind);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_1(zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_2(zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child1, zend_ast *child2);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_3(zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_4(zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4);
|
||||
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_0(zend_ast_kind kind, zend_ast_attr attr) {
|
||||
zend_ast *ast = zend_ast_create_0(kind);
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_0(zend_ast_loc *loc, zend_ast_kind kind, zend_ast_attr attr) {
|
||||
zend_ast *ast = zend_ast_create_0(loc, kind);
|
||||
ast->attr = attr;
|
||||
return ast;
|
||||
}
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_1(zend_ast_kind kind, zend_ast_attr attr, zend_ast *child) {
|
||||
zend_ast *ast = zend_ast_create_1(kind, child);
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_1(zend_ast_loc *loc, zend_ast_kind kind, zend_ast_attr attr, zend_ast *child) {
|
||||
zend_ast *ast = zend_ast_create_1(loc, kind, child);
|
||||
ast->attr = attr;
|
||||
return ast;
|
||||
}
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_2(zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2) {
|
||||
zend_ast *ast = zend_ast_create_2(kind, child1, child2);
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_2(zend_ast_loc *loc, zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2) {
|
||||
zend_ast *ast = zend_ast_create_2(loc, kind, child1, child2);
|
||||
ast->attr = attr;
|
||||
return ast;
|
||||
}
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_3(zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2, zend_ast *child3) {
|
||||
zend_ast *ast = zend_ast_create_3(kind, child1, child2, child3);
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_3(zend_ast_loc *loc, zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2, zend_ast *child3) {
|
||||
zend_ast *ast = zend_ast_create_3(loc, kind, child1, child2, child3);
|
||||
ast->attr = attr;
|
||||
return ast;
|
||||
}
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_4(zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4) {
|
||||
zend_ast *ast = zend_ast_create_4(kind, child1, child2, child3, child4);
|
||||
static zend_always_inline zend_ast * zend_ast_create_ex_4(zend_ast_loc *loc, zend_ast_kind kind, zend_ast_attr attr, zend_ast *child1, zend_ast *child2, zend_ast *child3, zend_ast *child4) {
|
||||
zend_ast *ast = zend_ast_create_4(loc, kind, child1, child2, child3, child4);
|
||||
ast->attr = attr;
|
||||
return ast;
|
||||
}
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_0(zend_ast_kind kind);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_1(zend_ast_kind kind, zend_ast *child);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_2(zend_ast_kind kind, zend_ast *child1, zend_ast *child2);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_0(zend_ast_loc *loc, zend_ast_kind kind);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_1(zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child);
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_list_2(zend_ast_loc *loc, zend_ast_kind kind, zend_ast *child1, zend_ast *child2);
|
||||
|
||||
# define zend_ast_create(...) \
|
||||
ZEND_AST_SPEC_CALL(zend_ast_create, __VA_ARGS__)
|
||||
# define zend_ast_create_ex(...) \
|
||||
ZEND_AST_SPEC_CALL_EX(zend_ast_create_ex, __VA_ARGS__)
|
||||
# define zend_ast_create_list(init_children, ...) \
|
||||
ZEND_AST_SPEC_CALL(zend_ast_create_list, __VA_ARGS__)
|
||||
# define zend_ast_create_list(loc, init_children, ...) \
|
||||
ZEND_AST_SPEC_CALL(zend_ast_create_list, loc, __VA_ARGS__)
|
||||
|
||||
#else
|
||||
ZEND_API zend_ast *zend_ast_create(zend_ast_kind kind, ...);
|
||||
ZEND_API zend_ast *zend_ast_create_ex(zend_ast_kind kind, zend_ast_attr attr, ...);
|
||||
ZEND_API zend_ast *zend_ast_create_list(uint32_t init_children, zend_ast_kind kind, ...);
|
||||
ZEND_API zend_ast *zend_ast_create(zend_ast_loc *loc, zend_ast_kind kind, ...);
|
||||
ZEND_API zend_ast *zend_ast_create_ex(zend_ast_loc *loc, zend_ast_kind kind, zend_ast_attr attr, ...);
|
||||
ZEND_API zend_ast *zend_ast_create_list(zend_ast_loc *loc, uint32_t init_children, zend_ast_kind kind, ...);
|
||||
#endif
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_list_add(zend_ast *list, zend_ast *op);
|
||||
|
||||
ZEND_API zend_ast *zend_ast_create_decl(
|
||||
zend_ast_kind kind, uint32_t flags, uint32_t start_lineno, zend_string *doc_comment,
|
||||
zend_ast_loc *loc, zend_ast_kind kind, uint32_t flags, zend_string *doc_comment,
|
||||
zend_string *name, zend_ast *child0, zend_ast *child1, zend_ast *child2, zend_ast *child3
|
||||
);
|
||||
|
||||
@ -318,14 +324,20 @@ static zend_always_inline uint32_t zend_ast_get_lineno(zend_ast *ast) {
|
||||
}
|
||||
}
|
||||
|
||||
static zend_always_inline zend_ast *zend_ast_create_binary_op(uint32_t opcode, zend_ast *op0, zend_ast *op1) {
|
||||
return zend_ast_create_ex(ZEND_AST_BINARY_OP, opcode, op0, op1);
|
||||
static inline zend_ast_loc zend_ast_get_loc(zend_ast *ast) {
|
||||
zend_ast_loc loc;
|
||||
loc.start_line = zend_ast_get_lineno(ast);
|
||||
return loc;
|
||||
}
|
||||
static zend_always_inline zend_ast *zend_ast_create_assign_op(uint32_t opcode, zend_ast *op0, zend_ast *op1) {
|
||||
return zend_ast_create_ex(ZEND_AST_ASSIGN_OP, opcode, op0, op1);
|
||||
|
||||
static zend_always_inline zend_ast *zend_ast_create_binary_op(zend_ast_loc *loc, uint32_t opcode, zend_ast *op0, zend_ast *op1) {
|
||||
return zend_ast_create_ex(loc, ZEND_AST_BINARY_OP, opcode, op0, op1);
|
||||
}
|
||||
static zend_always_inline zend_ast *zend_ast_create_cast(uint32_t type, zend_ast *op0) {
|
||||
return zend_ast_create_ex(ZEND_AST_CAST, type, op0);
|
||||
static zend_always_inline zend_ast *zend_ast_create_assign_op(zend_ast_loc *loc, uint32_t opcode, zend_ast *op0, zend_ast *op1) {
|
||||
return zend_ast_create_ex(loc, ZEND_AST_ASSIGN_OP, opcode, op0, op1);
|
||||
}
|
||||
static zend_always_inline zend_ast *zend_ast_create_cast(zend_ast_loc *loc, uint32_t type, zend_ast *op0) {
|
||||
return zend_ast_create_ex(loc, ZEND_AST_CAST, type, op0);
|
||||
}
|
||||
static zend_always_inline zend_ast *zend_ast_list_rtrim(zend_ast *ast) {
|
||||
zend_ast_list *list = zend_ast_get_list(ast);
|
||||
|
@ -1503,16 +1503,10 @@ ZEND_API void zend_activate_auto_globals(void) /* {{{ */
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
int ZEND_FASTCALL zendlex(zend_parser_stack_elem *elem) /* {{{ */
|
||||
int ZEND_FASTCALL zendlex(zend_parser_stack_elem *elem, zend_ast_loc *loc) /* {{{ */
|
||||
{
|
||||
zval zv;
|
||||
|
||||
if (CG(increment_lineno)) {
|
||||
CG(zend_lineno)++;
|
||||
CG(increment_lineno) = 0;
|
||||
}
|
||||
|
||||
return lex_scan(&zv, elem);
|
||||
return lex_scan(&zv, elem, loc);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -2312,8 +2306,9 @@ void zend_compile_assign(znode *result, zend_ast *ast);
|
||||
static inline void zend_emit_assign_znode(zend_ast *var_ast, znode *value_node) /* {{{ */
|
||||
{
|
||||
znode dummy_node;
|
||||
zend_ast *assign_ast = zend_ast_create(ZEND_AST_ASSIGN, var_ast,
|
||||
zend_ast_create_znode(value_node));
|
||||
zend_ast_loc loc = zend_ast_get_loc(var_ast);
|
||||
zend_ast *assign_ast = zend_ast_create(&loc, ZEND_AST_ASSIGN, var_ast,
|
||||
zend_ast_create_znode(&loc, value_node));
|
||||
zend_compile_assign(&dummy_node, assign_ast);
|
||||
zend_do_free(&dummy_node);
|
||||
}
|
||||
@ -2820,8 +2815,9 @@ void zend_compile_assign_ref(znode *result, zend_ast *ast) /* {{{ */
|
||||
|
||||
static inline void zend_emit_assign_ref_znode(zend_ast *var_ast, znode *value_node) /* {{{ */
|
||||
{
|
||||
zend_ast *assign_ast = zend_ast_create(ZEND_AST_ASSIGN_REF, var_ast,
|
||||
zend_ast_create_znode(value_node));
|
||||
zend_ast_loc loc = zend_ast_get_loc(var_ast);
|
||||
zend_ast *assign_ast = zend_ast_create(&loc, ZEND_AST_ASSIGN_REF, var_ast,
|
||||
zend_ast_create_znode(&loc, value_node));
|
||||
zend_compile_assign_ref(NULL, assign_ast);
|
||||
}
|
||||
/* }}} */
|
||||
@ -3414,9 +3410,10 @@ static void zend_compile_assert(znode *result, zend_ast_list *args, zend_string
|
||||
(args->child[0]->kind != ZEND_AST_ZVAL ||
|
||||
Z_TYPE_P(zend_ast_get_zval(args->child[0])) != IS_STRING)) {
|
||||
/* add "assert(condition) as assertion message */
|
||||
zend_ast_loc loc = zend_ast_get_loc(args->child[0]);
|
||||
zend_ast_list_add((zend_ast*)args,
|
||||
zend_ast_create_zval_from_str(
|
||||
zend_ast_export("assert(", args->child[0], ")")));
|
||||
&loc, zend_ast_export("assert(", args->child[0], ")")));
|
||||
}
|
||||
|
||||
zend_compile_call_common(result, (zend_ast*)args, fbc);
|
||||
@ -4016,8 +4013,9 @@ void zend_compile_global_var(zend_ast *ast) /* {{{ */
|
||||
zend_string_addref(Z_STR(name_node.u.constant));
|
||||
}
|
||||
|
||||
zend_ast_loc loc = zend_ast_get_loc(var_ast);
|
||||
zend_emit_assign_ref_znode(
|
||||
zend_ast_create(ZEND_AST_VAR, zend_ast_create_znode(&name_node)),
|
||||
zend_ast_create(&loc, ZEND_AST_VAR, zend_ast_create_znode(&loc, &name_node)),
|
||||
&result
|
||||
);
|
||||
}
|
||||
@ -6424,7 +6422,9 @@ void zend_compile_group_use(zend_ast *ast) /* {{{ */
|
||||
zend_string *compound_ns = zend_concat_names(ZSTR_VAL(ns), ZSTR_LEN(ns), ZSTR_VAL(name), ZSTR_LEN(name));
|
||||
zend_string_release_ex(name, 0);
|
||||
ZVAL_STR(name_zval, compound_ns);
|
||||
inline_use = zend_ast_create_list(1, ZEND_AST_USE, use);
|
||||
|
||||
zend_ast_loc loc = zend_ast_get_loc(ast);
|
||||
inline_use = zend_ast_create_list(&loc, 1, ZEND_AST_USE, use);
|
||||
inline_use->attr = ast->attr ? ast->attr : use->attr;
|
||||
zend_compile_use(inline_use);
|
||||
}
|
||||
@ -7423,7 +7423,8 @@ void zend_compile_isset_or_empty(znode *result, zend_ast *ast) /* {{{ */
|
||||
if (!zend_is_variable(var_ast)) {
|
||||
if (ast->kind == ZEND_AST_EMPTY) {
|
||||
/* empty(expr) can be transformed to !expr */
|
||||
zend_ast *not_ast = zend_ast_create_ex(ZEND_AST_UNARY_OP, ZEND_BOOL_NOT, var_ast);
|
||||
zend_ast_loc loc = zend_ast_get_loc(ast);
|
||||
zend_ast *not_ast = zend_ast_create_ex(&loc, ZEND_AST_UNARY_OP, ZEND_BOOL_NOT, var_ast);
|
||||
zend_compile_expr(result, not_ast);
|
||||
return;
|
||||
} else {
|
||||
@ -7493,9 +7494,10 @@ void zend_compile_shell_exec(znode *result, zend_ast *ast) /* {{{ */
|
||||
zend_ast *name_ast, *args_ast, *call_ast;
|
||||
|
||||
ZVAL_STRING(&fn_name, "shell_exec");
|
||||
name_ast = zend_ast_create_zval(&fn_name);
|
||||
args_ast = zend_ast_create_list(1, ZEND_AST_ARG_LIST, expr_ast);
|
||||
call_ast = zend_ast_create(ZEND_AST_CALL, name_ast, args_ast);
|
||||
zend_ast_loc loc = zend_ast_get_loc(ast);
|
||||
name_ast = zend_ast_create_zval(&loc, &fn_name);
|
||||
args_ast = zend_ast_create_list(&loc, 1, ZEND_AST_ARG_LIST, expr_ast);
|
||||
call_ast = zend_ast_create(&loc, ZEND_AST_CALL, name_ast, args_ast);
|
||||
|
||||
zend_compile_expr(result, call_ast);
|
||||
|
||||
@ -7893,7 +7895,8 @@ void zend_compile_const_expr_class_const(zend_ast **ast_ptr) /* {{{ */
|
||||
zend_ast_destroy(ast);
|
||||
zend_string_release_ex(class_name, 0);
|
||||
|
||||
*ast_ptr = zend_ast_create_constant(name, fetch_type | ZEND_FETCH_CLASS_EXCEPTION);
|
||||
zend_ast_loc loc = zend_ast_get_loc(ast);
|
||||
*ast_ptr = zend_ast_create_constant(&loc, name, fetch_type | ZEND_FETCH_CLASS_EXCEPTION);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -7928,6 +7931,7 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr) /* {{{ */
|
||||
zend_bool is_fully_qualified;
|
||||
zval result;
|
||||
zend_string *resolved_name;
|
||||
zend_ast_loc loc = zend_ast_get_loc(ast);
|
||||
|
||||
resolved_name = zend_resolve_const_name(
|
||||
orig_name, name_ast->attr, &is_fully_qualified);
|
||||
@ -7935,12 +7939,12 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr) /* {{{ */
|
||||
if (zend_try_ct_eval_const(&result, resolved_name, is_fully_qualified)) {
|
||||
zend_string_release_ex(resolved_name, 0);
|
||||
zend_ast_destroy(ast);
|
||||
*ast_ptr = zend_ast_create_zval(&result);
|
||||
*ast_ptr = zend_ast_create_zval(&loc, &result);
|
||||
return;
|
||||
}
|
||||
|
||||
zend_ast_destroy(ast);
|
||||
*ast_ptr = zend_ast_create_constant(resolved_name,
|
||||
*ast_ptr = zend_ast_create_constant(&loc, resolved_name,
|
||||
!is_fully_qualified && FC(current_namespace) ? IS_CONSTANT_UNQUALIFIED_IN_NAMESPACE : 0);
|
||||
}
|
||||
/* }}} */
|
||||
@ -7948,12 +7952,13 @@ void zend_compile_const_expr_const(zend_ast **ast_ptr) /* {{{ */
|
||||
void zend_compile_const_expr_magic_const(zend_ast **ast_ptr) /* {{{ */
|
||||
{
|
||||
zend_ast *ast = *ast_ptr;
|
||||
zend_ast_loc loc = zend_ast_get_loc(ast);
|
||||
|
||||
/* Other cases already resolved by constant folding */
|
||||
ZEND_ASSERT(ast->attr == T_CLASS_C);
|
||||
|
||||
zend_ast_destroy(ast);
|
||||
*ast_ptr = zend_ast_create(ZEND_AST_CONSTANT_CLASS);
|
||||
*ast_ptr = zend_ast_create(&loc, ZEND_AST_CONSTANT_CLASS);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@ -8599,7 +8604,8 @@ void zend_eval_const_expr(zend_ast **ast_ptr) /* {{{ */
|
||||
return;
|
||||
}
|
||||
|
||||
zend_ast_loc loc = zend_ast_get_loc(ast);
|
||||
zend_ast_destroy(ast);
|
||||
*ast_ptr = zend_ast_create_zval(&result);
|
||||
*ast_ptr = zend_ast_create_zval(&loc, &result);
|
||||
}
|
||||
/* }}} */
|
||||
|
@ -94,8 +94,6 @@ typedef struct _zend_ast_znode {
|
||||
znode node;
|
||||
} zend_ast_znode;
|
||||
|
||||
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_znode(znode *node);
|
||||
|
||||
static zend_always_inline znode *zend_ast_get_znode(zend_ast *ast) {
|
||||
return &((zend_ast_znode *) ast)->node;
|
||||
}
|
||||
@ -728,7 +726,7 @@ void zend_file_context_end(zend_file_context *prev_context);
|
||||
extern ZEND_API zend_op_array *(*zend_compile_file)(zend_file_handle *file_handle, int type);
|
||||
extern ZEND_API zend_op_array *(*zend_compile_string)(zval *source_string, char *filename);
|
||||
|
||||
ZEND_API int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem);
|
||||
ZEND_API int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem, zend_ast_loc *loc);
|
||||
void startup_scanner(void);
|
||||
void shutdown_scanner(void);
|
||||
|
||||
@ -841,7 +839,7 @@ ZEND_API zend_bool zend_is_auto_global_str(char *name, size_t len);
|
||||
ZEND_API size_t zend_dirname(char *path, size_t len);
|
||||
ZEND_API void zend_set_function_arg_flags(zend_function *func);
|
||||
|
||||
int ZEND_FASTCALL zendlex(zend_parser_stack_elem *elem);
|
||||
int ZEND_FASTCALL zendlex(zend_parser_stack_elem *elem, zend_ast_loc *loc);
|
||||
|
||||
void zend_assert_valid_class_name(const zend_string *const_name);
|
||||
|
||||
|
@ -94,7 +94,6 @@ struct _zend_compiler_globals {
|
||||
struct _zend_ini_parser_param *ini_parser_param;
|
||||
|
||||
uint32_t start_lineno;
|
||||
zend_bool increment_lineno;
|
||||
|
||||
zend_string *doc_comment;
|
||||
uint32_t extra_fn_flags;
|
||||
|
@ -85,13 +85,14 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
|
||||
{
|
||||
zval token;
|
||||
int token_type;
|
||||
zend_ast_loc loc;
|
||||
char *last_color = syntax_highlighter_ini->highlight_html;
|
||||
char *next_color;
|
||||
|
||||
zend_printf("<code>");
|
||||
zend_printf("<span style=\"color: %s\">\n", last_color);
|
||||
/* highlight stuff coming back from zendlex() */
|
||||
while ((token_type=lex_scan(&token, NULL))) {
|
||||
while ((token_type = lex_scan(&token, NULL, &loc))) {
|
||||
switch (token_type) {
|
||||
case T_INLINE_HTML:
|
||||
next_color = syntax_highlighter_ini->highlight_html;
|
||||
@ -174,10 +175,11 @@ ZEND_API void zend_highlight(zend_syntax_highlighter_ini *syntax_highlighter_ini
|
||||
ZEND_API void zend_strip(void)
|
||||
{
|
||||
zval token;
|
||||
zend_ast_loc loc;
|
||||
int token_type;
|
||||
int prev_space = 0;
|
||||
|
||||
while ((token_type=lex_scan(&token, NULL))) {
|
||||
while ((token_type = lex_scan(&token, NULL, &loc))) {
|
||||
switch (token_type) {
|
||||
case T_WHITESPACE:
|
||||
if (!prev_space) {
|
||||
@ -193,7 +195,7 @@ ZEND_API void zend_strip(void)
|
||||
case T_END_HEREDOC:
|
||||
zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
/* read the following character, either newline or ; */
|
||||
if (lex_scan(&token, NULL) != T_WHITESPACE) {
|
||||
if (lex_scan(&token, NULL, &loc) != T_WHITESPACE) {
|
||||
zend_write((char*)LANG_SCNG(yy_text), LANG_SCNG(yy_leng));
|
||||
}
|
||||
zend_write("\n", sizeof("\n") - 1);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -567,7 +567,6 @@ ZEND_API int open_file_for_scanning(zend_file_handle *file_handle)
|
||||
}
|
||||
|
||||
RESET_DOC_COMMENT();
|
||||
CG(increment_lineno) = 0;
|
||||
return SUCCESS;
|
||||
}
|
||||
END_EXTERN_C()
|
||||
@ -720,7 +719,6 @@ ZEND_API int zend_prepare_string_for_scanning(zval *str, char *filename)
|
||||
zend_set_compiled_filename(new_compiled_filename);
|
||||
zend_string_release_ex(new_compiled_filename, 0);
|
||||
CG(zend_lineno) = 1;
|
||||
CG(increment_lineno) = 0;
|
||||
RESET_DOC_COMMENT();
|
||||
return SUCCESS;
|
||||
}
|
||||
@ -1233,7 +1231,7 @@ static void copy_heredoc_label_stack(void *void_heredoc_label)
|
||||
goto skip_token; \
|
||||
} while (0)
|
||||
|
||||
int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem)
|
||||
int ZEND_FASTCALL lex_scan(zval *zendlval, zend_parser_stack_elem *elem, zend_ast_loc *loc)
|
||||
{
|
||||
int token;
|
||||
int offset;
|
||||
@ -2126,7 +2124,7 @@ inline_char_handler:
|
||||
<ST_IN_SCRIPTING>"?>"{NEWLINE}? {
|
||||
BEGIN(INITIAL);
|
||||
if (yytext[yyleng-1] != '>') {
|
||||
CG(increment_lineno) = 1;
|
||||
CG(zend_lineno)++;
|
||||
}
|
||||
if (PARSER_MODE()) {
|
||||
RETURN_TOKEN(';'); /* implicit ';' at php-end tag */
|
||||
@ -2363,9 +2361,10 @@ skip_escape_conversion:
|
||||
while (heredoc_nesting_level) {
|
||||
zval zv;
|
||||
int retval;
|
||||
zend_ast_loc loc;
|
||||
|
||||
ZVAL_UNDEF(&zv);
|
||||
retval = lex_scan(&zv, NULL);
|
||||
retval = lex_scan(&zv, NULL, &loc);
|
||||
zval_ptr_dtor_nogc(&zv);
|
||||
|
||||
if (EG(exception)) {
|
||||
@ -2403,7 +2402,6 @@ skip_escape_conversion:
|
||||
|
||||
zend_restore_lexical_state(¤t_state);
|
||||
SCNG(heredoc_scan_ahead) = 0;
|
||||
CG(increment_lineno) = 0;
|
||||
}
|
||||
|
||||
RETURN_TOKEN(T_START_HEREDOC);
|
||||
@ -2603,8 +2601,6 @@ double_quotes_scan_done:
|
||||
newline = 1;
|
||||
}
|
||||
|
||||
CG(increment_lineno) = 1; /* For newline before label */
|
||||
|
||||
if (SCNG(heredoc_scan_ahead)) {
|
||||
SCNG(heredoc_indentation) = indentation;
|
||||
SCNG(heredoc_indentation_uses_spaces) = (spacing == HEREDOC_USING_SPACES);
|
||||
@ -2665,6 +2661,9 @@ heredoc_scan_done:
|
||||
HANDLE_NEWLINES(yytext, yyleng - newline);
|
||||
}
|
||||
|
||||
if (newline) {
|
||||
CG(zend_lineno)++;
|
||||
}
|
||||
RETURN_TOKEN_WITH_VAL(T_ENCAPSED_AND_WHITESPACE);
|
||||
}
|
||||
|
||||
@ -2724,8 +2723,6 @@ heredoc_scan_done:
|
||||
newline = 1;
|
||||
}
|
||||
|
||||
CG(increment_lineno) = 1; /* For newline before label */
|
||||
|
||||
YYCURSOR -= indentation;
|
||||
heredoc_label->indentation = indentation;
|
||||
|
||||
@ -2753,6 +2750,9 @@ nowdoc_scan_done:
|
||||
}
|
||||
|
||||
HANDLE_NEWLINES(yytext, yyleng - newline);
|
||||
if (newline) {
|
||||
CG(zend_lineno)++;
|
||||
}
|
||||
RETURN_TOKEN_WITH_VAL(T_ENCAPSED_AND_WHITESPACE);
|
||||
}
|
||||
|
||||
@ -2774,13 +2774,15 @@ emit_token_with_str:
|
||||
emit_token_with_val:
|
||||
if (PARSER_MODE()) {
|
||||
ZEND_ASSERT(Z_TYPE_P(zendlval) != IS_UNDEF);
|
||||
elem->ast = zend_ast_create_zval_with_lineno(zendlval, start_line);
|
||||
loc->start_line = start_line;
|
||||
elem->ast = zend_ast_create_zval(loc, zendlval);
|
||||
}
|
||||
|
||||
emit_token:
|
||||
if (SCNG(on_event)) {
|
||||
SCNG(on_event)(ON_TOKEN, token, start_line, SCNG(on_event_context));
|
||||
}
|
||||
loc->start_line = start_line;
|
||||
return token;
|
||||
|
||||
return_whitespace:
|
||||
@ -2792,6 +2794,7 @@ return_whitespace:
|
||||
start_line = CG(zend_lineno);
|
||||
goto restart;
|
||||
} else {
|
||||
loc->start_line = start_line;
|
||||
return T_WHITESPACE;
|
||||
}
|
||||
|
||||
|
@ -127,8 +127,8 @@ static zend_bool tokenize(zval *return_value, zend_string *source)
|
||||
zval source_zval;
|
||||
zend_lex_state original_lex_state;
|
||||
zval token;
|
||||
zend_ast_loc loc;
|
||||
int token_type;
|
||||
int token_line = 1;
|
||||
int need_tokens = -1; /* for __halt_compiler lexing. -1 = disabled */
|
||||
|
||||
ZVAL_STR_COPY(&source_zval, source);
|
||||
@ -142,8 +142,8 @@ static zend_bool tokenize(zval *return_value, zend_string *source)
|
||||
LANG_SCNG(yy_state) = yycINITIAL;
|
||||
array_init(return_value);
|
||||
|
||||
while ((token_type = lex_scan(&token, NULL))) {
|
||||
add_token(return_value, token_type, zendtext, zendleng, token_line);
|
||||
while ((token_type = lex_scan(&token, NULL, &loc))) {
|
||||
add_token(return_value, token_type, zendtext, zendleng, loc.start_line);
|
||||
|
||||
if (Z_TYPE(token) != IS_UNDEF) {
|
||||
zval_ptr_dtor_nogc(&token);
|
||||
@ -159,20 +159,13 @@ static zend_bool tokenize(zval *return_value, zend_string *source)
|
||||
/* fetch the rest into a T_INLINE_HTML */
|
||||
if (zendcursor != zendlimit) {
|
||||
add_token(return_value, T_INLINE_HTML,
|
||||
zendcursor, zendlimit - zendcursor, token_line);
|
||||
zendcursor, zendlimit - zendcursor, loc.start_line);
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else if (token_type == T_HALT_COMPILER) {
|
||||
need_tokens = 3;
|
||||
}
|
||||
|
||||
if (CG(increment_lineno)) {
|
||||
CG(zend_lineno)++;
|
||||
CG(increment_lineno) = 0;
|
||||
}
|
||||
|
||||
token_line = CG(zend_lineno);
|
||||
}
|
||||
|
||||
zval_ptr_dtor_str(&source_zval);
|
||||
|
Loading…
Reference in New Issue
Block a user