mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Fix lexer/compiler interdependency
This commit is contained in:
parent
359f99fe48
commit
cdcf78f730
4 changed files with 14 additions and 12 deletions
|
@ -47,7 +47,7 @@ ZEND_API zend_ast *zend_ast_create_zval_ex(zval *zv, zend_ast_attr attr)
|
|||
|
||||
ZEND_API zend_ast *zend_ast_create_func_decl(
|
||||
zend_ast_kind kind, zend_bool returns_ref, zend_uint start_lineno, zend_uint end_lineno,
|
||||
zend_string *name, zend_ast *params, zend_ast *uses, zend_ast *stmt
|
||||
unsigned char *lex_pos, zend_string *name, zend_ast *params, zend_ast *uses, zend_ast *stmt
|
||||
) {
|
||||
zend_ast_func_decl *ast = emalloc(sizeof(zend_ast_func_decl));
|
||||
|
||||
|
@ -55,6 +55,7 @@ ZEND_API zend_ast *zend_ast_create_func_decl(
|
|||
ast->returns_ref = returns_ref;
|
||||
ast->start_lineno = start_lineno;
|
||||
ast->end_lineno = end_lineno;
|
||||
ast->lex_pos = lex_pos;
|
||||
ast->name = name;
|
||||
ast->params = params;
|
||||
ast->uses = uses;
|
||||
|
|
|
@ -128,6 +128,7 @@ typedef struct _zend_ast_func_decl {
|
|||
zend_bool returns_ref;
|
||||
zend_uint start_lineno;
|
||||
zend_uint end_lineno;
|
||||
unsigned char *lex_pos;
|
||||
zend_string *name;
|
||||
zend_ast *params;
|
||||
zend_ast *uses;
|
||||
|
@ -147,7 +148,7 @@ ZEND_API zend_ast *zend_ast_create(
|
|||
|
||||
ZEND_API zend_ast *zend_ast_create_func_decl(
|
||||
zend_ast_kind kind, zend_bool by_ref, zend_uint start_lineno, zend_uint end_lineno,
|
||||
zend_string *name, zend_ast *params, zend_ast *uses, zend_ast *stmt
|
||||
unsigned char *lex_pos, zend_string *name, zend_ast *params, zend_ast *uses, zend_ast *stmt
|
||||
);
|
||||
|
||||
ZEND_API zend_ast *zend_ast_create_dynamic(zend_ast_kind kind);
|
||||
|
|
|
@ -139,13 +139,13 @@ static void zend_destroy_property_info_internal(zval *zv) /* {{{ */
|
|||
}
|
||||
/* }}} */
|
||||
|
||||
static void build_runtime_defined_function_key(zval *result, const char *name, int name_length TSRMLS_DC) /* {{{ */
|
||||
static void build_runtime_defined_function_key(zval *result, zend_string *name, unsigned char *lex_pos TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
char char_pos_buf[32];
|
||||
uint char_pos_len;
|
||||
const char *filename;
|
||||
|
||||
char_pos_len = zend_sprintf(char_pos_buf, "%p", LANG_SCNG(yy_text));
|
||||
char_pos_len = zend_sprintf(char_pos_buf, "%p", lex_pos);
|
||||
if (CG(active_op_array)->filename) {
|
||||
filename = CG(active_op_array)->filename->val;
|
||||
} else {
|
||||
|
@ -153,11 +153,11 @@ static void build_runtime_defined_function_key(zval *result, const char *name, i
|
|||
}
|
||||
|
||||
/* NULL, name length, filename length, last accepting char position length */
|
||||
ZVAL_NEW_STR(result, STR_ALLOC(1+name_length+strlen(filename)+char_pos_len, 0));
|
||||
ZVAL_NEW_STR(result, STR_ALLOC(1 + name->len + strlen(filename) + char_pos_len, 0));
|
||||
|
||||
/* must be binary safe */
|
||||
Z_STRVAL_P(result)[0] = '\0';
|
||||
sprintf(Z_STRVAL_P(result)+1, "%s%s%s", name, filename, char_pos_buf);
|
||||
sprintf(Z_STRVAL_P(result)+1, "%s%s%s", name->val, filename, char_pos_buf);
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@ -1251,7 +1251,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
|
|||
|
||||
opline->opcode = ZEND_DECLARE_FUNCTION;
|
||||
opline->op1_type = IS_CONST;
|
||||
build_runtime_defined_function_key(&key, lcname->val, lcname->len TSRMLS_CC);
|
||||
build_runtime_defined_function_key(&key, lcname, LANG_SCNG(yy_text) TSRMLS_CC);
|
||||
opline->op1.constant = zend_add_literal(CG(active_op_array), &key TSRMLS_CC);
|
||||
opline->op2_type = IS_CONST;
|
||||
LITERAL_STR(opline->op2, STR_COPY(lcname));
|
||||
|
@ -3891,7 +3891,7 @@ void zend_do_begin_class_declaration(const znode *class_token, znode *class_name
|
|||
|
||||
opline = get_next_op(CG(active_op_array) TSRMLS_CC);
|
||||
opline->op1_type = IS_CONST;
|
||||
build_runtime_defined_function_key(&key, lcname->val, lcname->len TSRMLS_CC);
|
||||
build_runtime_defined_function_key(&key, lcname, LANG_SCNG(yy_text) TSRMLS_CC);
|
||||
opline->op1.constant = zend_add_literal(CG(active_op_array), &key TSRMLS_CC);
|
||||
|
||||
opline->op2_type = IS_CONST;
|
||||
|
@ -7063,7 +7063,7 @@ void zend_compile_func_decl(znode *result, zend_ast *ast TSRMLS_DC) {
|
|||
|
||||
{
|
||||
zval key;
|
||||
build_runtime_defined_function_key(&key, lcname->val, lcname->len TSRMLS_CC);
|
||||
build_runtime_defined_function_key(&key, lcname, fn->lex_pos TSRMLS_CC);
|
||||
|
||||
opline->op1_type = IS_CONST;
|
||||
opline->op1.constant = zend_add_literal(CG(active_op_array), &key TSRMLS_CC);
|
||||
|
|
|
@ -390,8 +390,8 @@ unset_variable:
|
|||
function_declaration_statement:
|
||||
function is_reference T_STRING '(' parameter_list ')' '{' inner_statement_list '}'
|
||||
{ $$.u.ast = zend_ast_create_func_decl(ZEND_AST_FUNC_DECL, $2.op_type,
|
||||
$1.u.op.opline_num, CG(zend_lineno), Z_STR($3.u.constant),
|
||||
$5.u.ast, NULL, $8.u.ast); }
|
||||
$1.u.op.opline_num, CG(zend_lineno), LANG_SCNG(yy_text),
|
||||
Z_STR($3.u.constant), $5.u.ast, NULL, $8.u.ast); }
|
||||
;
|
||||
|
||||
class_declaration_statement:
|
||||
|
@ -872,7 +872,7 @@ expr_without_variable:
|
|||
{ $$.u.ast = zend_ast_create_binary(ZEND_YIELD, $4.u.ast, $2.u.ast); }
|
||||
| function is_reference '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
|
||||
{ $$.u.ast = zend_ast_create_func_decl(ZEND_AST_CLOSURE, $2.op_type,
|
||||
$1.u.op.opline_num, CG(zend_lineno),
|
||||
$1.u.op.opline_num, CG(zend_lineno), LANG_SCNG(yy_text),
|
||||
STR_INIT("{closure}", sizeof("{closure}") - 1, 0),
|
||||
$4.u.ast, $6.u.ast, $8.u.ast); }
|
||||
| T_STATIC function is_reference { zend_do_begin_lambda_function_declaration(&$$, &$2, $3.op_type, 1 TSRMLS_CC); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue