Skip to content

Commit

Permalink
Declare the XSUB function for builtin::indexed via embed.fnc so that …
Browse files Browse the repository at this point in the history
…op.c can take its address
  • Loading branch information
leonerd committed Oct 27, 2024
1 parent e5bece6 commit 2f2b892
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
7 changes: 5 additions & 2 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,12 @@ static OP *ck_builtin_func1(pTHX_ OP *entersubop, GV *namegv, SV *ckobj)
}
}

XS(XS_builtin_indexed)
/* This does not use the XS() macro so that op.c can see its prototype */
void
Perl_XS_builtin_indexed(pTHX_ CV *cv)
{
dXSARGS;
PERL_ARGS_ASSERT_XS_BUILTIN_INDEXED;

switch(GIMME_V) {
case G_VOID:
Expand Down Expand Up @@ -638,7 +641,7 @@ static const struct BuiltinFuncDescriptor builtins[] = {
{ "load_module", NO_BUNDLE, &XS_builtin_load_module, &ck_builtin_func1, 0, true },

/* list functions */
{ "indexed", SHORTVER(5,39), &XS_builtin_indexed, &ck_builtin_funcN, 0, false },
{ "indexed", SHORTVER(5,39), &Perl_XS_builtin_indexed, &ck_builtin_funcN, 0, false },
{ "export_lexically", NO_BUNDLE, &XS_builtin_export_lexically, NULL, 0, true },

{ NULL, 0, NULL, NULL, 0, false }
Expand Down
2 changes: 2 additions & 0 deletions embed.fnc
Original file line number Diff line number Diff line change
Expand Up @@ -4087,6 +4087,8 @@ p |void |finish_export_lexical
p |void |import_builtin_bundle \
|U16 ver
p |void |prepare_export_lexical
p |void |XS_builtin_indexed \
|NN CV *cv
#endif
#if defined(PERL_IN_CLASS_C) || defined(PERL_IN_OP_C) || \
defined(PERL_IN_PAD_C) || defined(PERL_IN_PERLY_C) || \
Expand Down
1 change: 1 addition & 0 deletions embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,7 @@
# define get_aux_mg(a) S_get_aux_mg(aTHX_ a)
# endif
# if defined(PERL_IN_BUILTIN_C) || defined(PERL_IN_OP_C)
# define XS_builtin_indexed(a) Perl_XS_builtin_indexed(aTHX_ a)
# define finish_export_lexical() Perl_finish_export_lexical(aTHX)
# define import_builtin_bundle(a) Perl_import_builtin_bundle(aTHX_ a)
# define prepare_export_lexical() Perl_prepare_export_lexical(aTHX)
Expand Down
5 changes: 1 addition & 4 deletions op.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,6 @@ recursive, but it's recursive on basic blocks, not on tree nodes.

static const char array_passed_to_stat[] = "Array passed to stat will be coerced to a scalar";

/* UGH!! */
EXTERN_C void XS_builtin_indexed(pTHX_ CV *);

/* remove any leading "empty" ops from the op_next chain whose first
* node's address is stored in op_p. Store the updated address of the
* first node in op_p.
Expand Down Expand Up @@ -9825,7 +9822,7 @@ Perl_newFOROP(pTHX_ I32 flags, OP *sv, OP *expr, OP *block, OP *cont)
if(firstarg == lastarg)
firstarg = NULL;

if (op_is_cv_xsub(lastarg, &XS_builtin_indexed) && /* a call to builtin::indexed */
if (op_is_cv_xsub(lastarg, &Perl_XS_builtin_indexed) && /* a call to builtin::indexed */
firstarg && OpSIBLING(firstarg) == lastarg && /* with one arg */
(firstarg->op_type == OP_RV2AV || firstarg->op_type == OP_PADAV) /* ... which is an array */
) {
Expand Down
6 changes: 6 additions & 0 deletions proto.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2f2b892

Please sign in to comment.