Skip to content

Commit 46abda7

Browse files
committed
Move code to avoid forward decls
1 parent 862340b commit 46abda7

File tree

1 file changed

+49
-55
lines changed

1 file changed

+49
-55
lines changed

Zend/zend_compile.c

Lines changed: 49 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -3921,61 +3921,6 @@ static bool zend_compile_function_name(znode *name_node, zend_ast *name_ast) /*
39213921
}
39223922
/* }}} */
39233923

3924-
// FIXME: Move up implementation
3925-
3926-
static uint32_t zend_compile_frameless_icall_ex(znode *result, zend_ast_list *args, zend_function *fbc, const zend_frameless_function_info *frameless_function_info, uint32_t type);
3927-
static bool zend_args_contain_unpack_or_named(zend_ast_list *args);
3928-
static const zend_frameless_function_info *find_frameless_function_info(zend_ast_list *args, zend_function *fbc, uint32_t type);
3929-
3930-
static void zend_compile_ns_call(znode *result, znode *name_node, zend_ast *args_ast, uint32_t lineno, uint32_t type) /* {{{ */
3931-
{
3932-
int name_constants = zend_add_ns_func_name_literal(Z_STR(name_node->u.constant));
3933-
3934-
/* Find frameless function with same name */
3935-
zend_function *frameless_function = NULL;
3936-
if (args_ast->kind != ZEND_AST_CALLABLE_CONVERT
3937-
&& !zend_args_contain_unpack_or_named(zend_ast_get_list(args_ast))) {
3938-
zend_string *lc_func_name = Z_STR_P(CT_CONSTANT_EX(CG(active_op_array), name_constants + 2));
3939-
frameless_function = zend_hash_find_ptr(CG(function_table), lc_func_name);
3940-
}
3941-
3942-
uint32_t jmp_fl_opnum = 0;
3943-
const zend_frameless_function_info *frameless_function_info = NULL;
3944-
if (frameless_function) {
3945-
frameless_function_info = find_frameless_function_info(zend_ast_get_list(args_ast), frameless_function, type);
3946-
if (frameless_function_info) {
3947-
znode op1;
3948-
op1.op_type = IS_CONST;
3949-
ZVAL_COPY(&op1.u.constant, CT_CONSTANT_EX(CG(active_op_array), name_constants + 1));
3950-
jmp_fl_opnum = get_next_op_number();
3951-
zend_emit_op(NULL, ZEND_JMP_FRAMELESS, &op1, NULL);
3952-
}
3953-
}
3954-
3955-
zend_op *opline = get_next_op();
3956-
opline->opcode = ZEND_INIT_NS_FCALL_BY_NAME;
3957-
opline->op2_type = IS_CONST;
3958-
opline->op2.constant = name_constants;
3959-
opline->result.num = zend_alloc_cache_slot();
3960-
3961-
zend_compile_call_common(result, args_ast, NULL, lineno);
3962-
3963-
if (frameless_function_info) {
3964-
uint32_t jmp_end_opnum = zend_emit_jump(0);
3965-
uint32_t jmp_fl_target = get_next_op_number();
3966-
3967-
uint32_t flf_icall_opnum = zend_compile_frameless_icall_ex(NULL, zend_ast_get_list(args_ast), frameless_function, frameless_function_info, type);
3968-
3969-
zend_op *jmp_fl = &CG(active_op_array)->opcodes[jmp_fl_opnum];
3970-
jmp_fl->op2.opline_num = jmp_fl_target;
3971-
jmp_fl->extended_value = zend_alloc_cache_slot();
3972-
zend_op *flf_icall = &CG(active_op_array)->opcodes[flf_icall_opnum];
3973-
SET_NODE(flf_icall->result, result);
3974-
zend_update_jump_target_to_next(jmp_end_opnum);
3975-
}
3976-
}
3977-
/* }}} */
3978-
39793924
static void zend_compile_dynamic_call(znode *result, znode *name_node, zend_ast *args_ast, uint32_t lineno) /* {{{ */
39803925
{
39813926
if (name_node->op_type == IS_CONST && Z_TYPE(name_node->u.constant) == IS_STRING) {
@@ -4663,6 +4608,55 @@ static uint32_t zend_compile_frameless_icall(znode *result, zend_ast_list *args,
46634608
return zend_compile_frameless_icall_ex(result, args, fbc, frameless_function_info, type);
46644609
}
46654610

4611+
static void zend_compile_ns_call(znode *result, znode *name_node, zend_ast *args_ast, uint32_t lineno, uint32_t type) /* {{{ */
4612+
{
4613+
int name_constants = zend_add_ns_func_name_literal(Z_STR(name_node->u.constant));
4614+
4615+
/* Find frameless function with same name */
4616+
zend_function *frameless_function = NULL;
4617+
if (args_ast->kind != ZEND_AST_CALLABLE_CONVERT
4618+
&& !zend_args_contain_unpack_or_named(zend_ast_get_list(args_ast))) {
4619+
zend_string *lc_func_name = Z_STR_P(CT_CONSTANT_EX(CG(active_op_array), name_constants + 2));
4620+
frameless_function = zend_hash_find_ptr(CG(function_table), lc_func_name);
4621+
}
4622+
4623+
uint32_t jmp_fl_opnum = 0;
4624+
const zend_frameless_function_info *frameless_function_info = NULL;
4625+
if (frameless_function) {
4626+
frameless_function_info = find_frameless_function_info(zend_ast_get_list(args_ast), frameless_function, type);
4627+
if (frameless_function_info) {
4628+
znode op1;
4629+
op1.op_type = IS_CONST;
4630+
ZVAL_COPY(&op1.u.constant, CT_CONSTANT_EX(CG(active_op_array), name_constants + 1));
4631+
jmp_fl_opnum = get_next_op_number();
4632+
zend_emit_op(NULL, ZEND_JMP_FRAMELESS, &op1, NULL);
4633+
}
4634+
}
4635+
4636+
zend_op *opline = get_next_op();
4637+
opline->opcode = ZEND_INIT_NS_FCALL_BY_NAME;
4638+
opline->op2_type = IS_CONST;
4639+
opline->op2.constant = name_constants;
4640+
opline->result.num = zend_alloc_cache_slot();
4641+
4642+
zend_compile_call_common(result, args_ast, NULL, lineno);
4643+
4644+
if (frameless_function_info) {
4645+
uint32_t jmp_end_opnum = zend_emit_jump(0);
4646+
uint32_t jmp_fl_target = get_next_op_number();
4647+
4648+
uint32_t flf_icall_opnum = zend_compile_frameless_icall_ex(NULL, zend_ast_get_list(args_ast), frameless_function, frameless_function_info, type);
4649+
4650+
zend_op *jmp_fl = &CG(active_op_array)->opcodes[jmp_fl_opnum];
4651+
jmp_fl->op2.opline_num = jmp_fl_target;
4652+
jmp_fl->extended_value = zend_alloc_cache_slot();
4653+
zend_op *flf_icall = &CG(active_op_array)->opcodes[flf_icall_opnum];
4654+
SET_NODE(flf_icall->result, result);
4655+
zend_update_jump_target_to_next(jmp_end_opnum);
4656+
}
4657+
}
4658+
/* }}} */
4659+
46664660
static zend_result zend_try_compile_special_func_ex(znode *result, zend_string *lcname, zend_ast_list *args, zend_function *fbc, uint32_t type) /* {{{ */
46674661
{
46684662
if (zend_string_equals_literal(lcname, "strlen")) {

0 commit comments

Comments
 (0)