Skip to content

Commit d8f4b45

Browse files
committed
Revert "Dummy"
This reverts commit 0b9ec68.
1 parent 0b9ec68 commit d8f4b45

File tree

1 file changed

+20
-22
lines changed

1 file changed

+20
-22
lines changed

Zend/zend_compile.c

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8138,9 +8138,10 @@ static uint32_t zend_add_dynamic_func_def(zend_op_array *def) {
81388138
return def_offset;
81398139
}
81408140

8141-
static zend_string *zend_begin_func_decl(zend_op_array *op_array, zend_ast_decl *decl) /* {{{ */
8141+
static zend_string *zend_begin_func_decl(znode *result, zend_op_array *op_array, zend_ast_decl *decl, bool toplevel) /* {{{ */
81428142
{
81438143
zend_string *unqualified_name, *name, *lcname;
8144+
zend_op *opline;
81448145

81458146
if (op_array->fn_flags & ZEND_ACC_CLOSURE) {
81468147
zend_string *filename = op_array->filename;
@@ -8207,7 +8208,19 @@ static zend_string *zend_begin_func_decl(zend_op_array *op_array, zend_ast_decl
82078208
}
82088209

82098210
zend_register_seen_symbol(lcname, ZEND_SYMBOL_FUNCTION);
8210-
8211+
if (!toplevel) {
8212+
uint32_t func_ref = zend_add_dynamic_func_def(op_array);
8213+
if (op_array->fn_flags & ZEND_ACC_CLOSURE) {
8214+
opline = zend_emit_op_tmp(result, ZEND_DECLARE_LAMBDA_FUNCTION, NULL, NULL);
8215+
opline->op2.num = func_ref;
8216+
} else {
8217+
opline = get_next_op();
8218+
opline->opcode = ZEND_DECLARE_FUNCTION;
8219+
opline->op1_type = IS_CONST;
8220+
LITERAL_STR(opline->op1, zend_string_copy(lcname));
8221+
opline->op2.num = func_ref;
8222+
}
8223+
}
82118224
return lcname;
82128225
}
82138226
/* }}} */
@@ -8256,29 +8269,10 @@ static zend_op_array *zend_compile_func_decl_ex(
82568269
op_array->scope = ce;
82578270
op_array->function_name = zend_string_copy(decl->name);
82588271
} else if (is_method) {
8259-
ZEND_ASSERT(!toplevel);
82608272
bool has_body = stmt_ast != NULL;
82618273
lcname = zend_begin_method_decl(op_array, decl->name, has_body);
82628274
} else {
8263-
lcname = zend_begin_func_decl(op_array, decl);
8264-
if (toplevel) {
8265-
op_array->fn_flags |= ZEND_ACC_TOP_LEVEL;
8266-
} else {
8267-
zend_op *opline;
8268-
8269-
uint32_t func_ref = zend_add_dynamic_func_def(op_array);
8270-
if (op_array->fn_flags & ZEND_ACC_CLOSURE) {
8271-
opline = zend_emit_op_tmp(result, ZEND_DECLARE_LAMBDA_FUNCTION, NULL, NULL);
8272-
opline->op2.num = func_ref;
8273-
} else {
8274-
opline = get_next_op();
8275-
opline->opcode = ZEND_DECLARE_FUNCTION;
8276-
opline->op1_type = IS_CONST;
8277-
LITERAL_STR(opline->op1, zend_string_copy(lcname));
8278-
opline->op2.num = func_ref;
8279-
}
8280-
}
8281-
8275+
lcname = zend_begin_func_decl(result, op_array, decl, toplevel);
82828276
if (decl->kind == ZEND_AST_ARROW_FUNC) {
82838277
find_implicit_binds(&info, params_ast, stmt_ast);
82848278
compile_implicit_lexical_binds(&info, result, op_array);
@@ -8326,6 +8320,10 @@ static zend_op_array *zend_compile_func_decl_ex(
83268320
CG(active_class_entry) = NULL;
83278321
}
83288322

8323+
if (toplevel) {
8324+
op_array->fn_flags |= ZEND_ACC_TOP_LEVEL;
8325+
}
8326+
83298327
zend_oparray_context_begin(&orig_oparray_context, op_array);
83308328
CG(context).active_property_info = property_info;
83318329
CG(context).active_property_hook_kind = hook_kind;

0 commit comments

Comments
 (0)