#define XSINTERFACE_FUNC_SET(cv,f) \
CvXSUBANY(cv).any_dxptr = (void (*) (pTHX_ void*))(f)
-#define dUNDERBAR I32 padoff_du = pad_findmy("$_")
+#define dUNDERBAR I32 padoff_du = Perl_find_rundefsvoffset()
#define UNDERBAR ((padoff_du == NOT_IN_PAD \
|| PAD_COMPNAME_FLAGS(padoff_du) & SVpad_OUR) \
? DEFSV : PAD_SVl(padoff_du))
pd |PADOFFSET|pad_alloc |I32 optype|U32 tmptype
p |PADOFFSET|allocmy |char* name
pd |PADOFFSET|pad_findmy |char* name
+Ap |PADOFFSET|find_rundefsvoffset |
p |OP* |oopsAV |OP* o
p |OP* |oopsHV |OP* o
pd |void |pad_leavemy
#ifdef PERL_CORE
#define pad_findmy Perl_pad_findmy
#endif
+#define find_rundefsvoffset Perl_find_rundefsvoffset
#ifdef PERL_CORE
#define oopsAV Perl_oopsAV
#endif
#ifdef PERL_CORE
#define pad_findmy(a) Perl_pad_findmy(aTHX_ a)
#endif
+#define find_rundefsvoffset() Perl_find_rundefsvoffset(aTHX)
#ifdef PERL_CORE
#define oopsAV(a) Perl_oopsAV(aTHX_ a)
#endif
Perl_vcmp
Perl_ninstr
Perl_op_free
+Perl_find_rundefsvoffset
Perl_pad_sv
Perl_reentrant_size
Perl_reentrant_init
return NOT_IN_PAD;
}
+/*
+ * Returns the offset of a lexical $_, if there is one, at run time.
+ * Used by the UNDERBAR XS macro.
+ */
+
+PADOFFSET
+Perl_find_rundefsvoffset()
+{
+ SV *out_sv;
+ int out_flags;
+ return pad_findlex("$_", find_runcv(NULL), PL_curcop->cop_seq, 1,
+ Null(SV**), &out_sv, &out_flags);
+}
/*
=for apidoc pad_findlex
register I32 tmp;
dTARGET;
STRLEN len;
+ I32 padoff_du;
SvUTF8_off(TARG); /* decontaminate */
if (SP - MARK > 1)
do_join(TARG, &PL_sv_no, MARK, SP);
else
- sv_setsv(TARG, (SP > MARK) ? *SP : DEFSV);
+ sv_setsv(TARG, (SP > MARK)
+ ? *SP
+ : (padoff_du = Perl_find_rundefsvoffset(),
+ (padoff_du == NOT_IN_PAD || PAD_COMPNAME_FLAGS(padoff_du) & SVpad_OUR)
+ ? DEFSV : PAD_SVl(padoff_du)));
up = SvPV_force(TARG, len);
if (len > 1) {
if (DO_UTF8(TARG)) { /* first reverse each character */
PERL_CALLCONV PADOFFSET Perl_pad_alloc(pTHX_ I32 optype, U32 tmptype);
PERL_CALLCONV PADOFFSET Perl_allocmy(pTHX_ char* name);
PERL_CALLCONV PADOFFSET Perl_pad_findmy(pTHX_ char* name);
+PERL_CALLCONV PADOFFSET Perl_find_rundefsvoffset(pTHX);
PERL_CALLCONV OP* Perl_oopsAV(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_oopsHV(pTHX_ OP* o);
PERL_CALLCONV void Perl_pad_leavemy(pTHX);
{
my $_ = "abc";
my $x = reverse;
- ok( $x eq "cba", 'reverse without arguments picks up $_ # TODO' );
+ ok( $x eq "cba", 'reverse without arguments picks up $_' );
}
{