Skip to content

Commit f029cc1

Browse files
committed
Print placeholder value when printing ZEND_AST_OP_ARRAY
1 parent dd80c75 commit f029cc1

File tree

7 files changed

+8
-19
lines changed

7 files changed

+8
-19
lines changed

Zend/tests/closure_const_expr/attributes_ast_printing_runtime.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ foreach ($r->getAttributes() as $attribute) {
1717
--EXPECT--
1818
Attribute [ Attr ] {
1919
- Arguments [1] {
20-
Argument #0 [ static function ($foo) {
21-
echo $foo;
22-
} ]
20+
Argument #0 [ Closure({closure:foo():3}) ]
2321
}
2422
}

Zend/zend_ast.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,14 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(zend_string *name, ze
100100
return (zend_ast *) ast;
101101
}
102102

103-
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_op_array(zend_op_array *op_array, zend_string *original_ast) {
103+
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_op_array(zend_op_array *op_array) {
104104
zend_ast_op_array *ast;
105105

106106
ast = zend_ast_alloc(sizeof(zend_ast_op_array));
107107
ast->kind = ZEND_AST_OP_ARRAY;
108108
ast->attr = 0;
109109
ast->lineno = CG(zend_lineno);
110110
ast->op_array = op_array;
111-
ast->original_ast = original_ast;
112111

113112
return (zend_ast *) ast;
114113
}
@@ -1159,7 +1158,6 @@ static void* ZEND_FASTCALL zend_ast_tree_copy(zend_ast *ast, void *buf)
11591158
new->attr = old->attr;
11601159
new->lineno = old->lineno;
11611160
new->op_array = old->op_array;
1162-
new->original_ast = zend_string_copy(old->original_ast);
11631161
buf = (void*)((char*)buf + sizeof(zend_ast_op_array));
11641162
} else if (zend_ast_is_decl(ast)) {
11651163
/* Not implemented. */
@@ -1228,7 +1226,7 @@ ZEND_API void ZEND_FASTCALL zend_ast_destroy(zend_ast *ast)
12281226
} else if (EXPECTED(ast->kind == ZEND_AST_CONSTANT)) {
12291227
zend_string_release_ex(zend_ast_get_constant_name(ast), 0);
12301228
} else if (EXPECTED(ast->kind == ZEND_AST_OP_ARRAY)) {
1231-
zend_string_release_ex(zend_ast_get_op_array(ast)->original_ast, 0);
1229+
/* Nothing to do. */
12321230
} else if (EXPECTED(zend_ast_is_decl(ast))) {
12331231
zend_ast_decl *decl = (zend_ast_decl *) ast;
12341232

@@ -1888,7 +1886,9 @@ static ZEND_COLD void zend_ast_export_ex(smart_str *str, zend_ast *ast, int prio
18881886
break;
18891887
}
18901888
case ZEND_AST_OP_ARRAY:
1891-
smart_str_append(str, zend_ast_get_op_array(ast)->original_ast);
1889+
smart_str_appends(str, "Closure(");
1890+
smart_str_append(str, zend_ast_get_op_array(ast)->op_array->function_name);
1891+
smart_str_appends(str, ")");
18921892
break;
18931893
case ZEND_AST_CONSTANT_CLASS:
18941894
smart_str_appendl(str, "__CLASS__", sizeof("__CLASS__")-1);

Zend/zend_ast.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,6 @@ typedef struct _zend_ast_op_array {
214214
zend_ast_attr attr;
215215
uint32_t lineno;
216216
zend_op_array *op_array;
217-
zend_string *original_ast;
218217
} zend_ast_op_array;
219218

220219
/* Separate structure for function and class declaration, as they need extra information. */
@@ -241,7 +240,7 @@ ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_zval_from_long(zend_long lval)
241240
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_constant(zend_string *name, zend_ast_attr attr);
242241
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_class_const_or_name(zend_ast *class_name, zend_ast *name);
243242

244-
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_op_array(zend_op_array *op_array, zend_string *original_ast);
243+
ZEND_API zend_ast * ZEND_FASTCALL zend_ast_create_op_array(zend_op_array *op_array);
245244

246245
#if ZEND_AST_SPEC
247246
# define ZEND_AST_SPEC_CALL(name, ...) \

Zend/zend_compile.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11222,10 +11222,8 @@ static void zend_compile_const_expr_closure(zend_ast **ast_ptr)
1122211222
znode node;
1122311223
zend_op_array *op = zend_compile_func_decl(&node, (zend_ast*)closure_ast, FUNC_DECL_LEVEL_CONSTEXPR);
1122411224

11225-
zend_string *original_ast = zend_ast_export("", *ast_ptr, "");
1122611225
zend_ast_destroy(*ast_ptr);
11227-
*ast_ptr = zend_ast_create_op_array(op, original_ast);
11228-
11226+
*ast_ptr = zend_ast_create_op_array(op);
1122911227
}
1123011228

1123111229
static void zend_compile_const_expr_args(zend_ast **ast_ptr)

ext/opcache/zend_file_cache.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,6 @@ static void zend_file_cache_serialize_ast(zend_ast *ast,
366366
} else if (ast->kind == ZEND_AST_OP_ARRAY) {
367367
/* The op_array itself will be serialized as part of the dynamic_func_defs. */
368368
SERIALIZE_PTR(zend_ast_get_op_array(ast)->op_array);
369-
370-
SERIALIZE_STR(zend_ast_get_op_array(ast)->original_ast);
371369
} else if (zend_ast_is_decl(ast)) {
372370
/* Not implemented. */
373371
ZEND_UNREACHABLE();
@@ -1253,8 +1251,6 @@ static void zend_file_cache_unserialize_ast(zend_ast *ast,
12531251
} else if (ast->kind == ZEND_AST_OP_ARRAY) {
12541252
/* The op_array itself will be unserialized as part of the dynamic_func_defs. */
12551253
UNSERIALIZE_PTR(zend_ast_get_op_array(ast)->op_array);
1256-
1257-
UNSERIALIZE_STR(zend_ast_get_op_array(ast)->original_ast);
12581254
} else if (zend_ast_is_decl(ast)) {
12591255
/* Not implemented. */
12601256
ZEND_UNREACHABLE();

ext/opcache/zend_persist.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ static zend_ast *zend_persist_ast(zend_ast *ast)
194194
ZVAL_PTR(&z, copy->op_array);
195195
zend_persist_op_array(&z);
196196
copy->op_array = Z_PTR(z);
197-
zend_accel_store_interned_string(copy->original_ast);
198197
node = (zend_ast *) copy;
199198
} else if (zend_ast_is_decl(ast)) {
200199
/* Not implemented. */

ext/opcache/zend_persist_calc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ static void zend_persist_ast_calc(zend_ast *ast)
9191
zval z;
9292
ZVAL_PTR(&z, zend_ast_get_op_array(ast)->op_array);
9393
zend_persist_op_array_calc(&z);
94-
ADD_INTERNED_STRING(zend_ast_get_op_array(ast)->original_ast);
9594
} else if (zend_ast_is_decl(ast)) {
9695
/* Not implemented. */
9796
ZEND_UNREACHABLE();

0 commit comments

Comments
 (0)