: Only used in op.c
pd |void |pad_undef |NN CV* cv
: Only used in op.c
-pd |PADOFFSET|pad_add_name |NN const char *name\
- |NULLOK HV* typestash|NULLOK HV* ourstash|bool clone|bool state
+Mpd |PADOFFSET|pad_add_name |NN const char *name|const STRLEN len\
+ |const U32 flags|NULLOK HV *typestash\
+ |NULLOK HV *ourstash
: Only used in op.c
pd |PADOFFSET|pad_add_anon |NN SV* sv|OPCODE op_type
: Only used in op.c
/* allocate a spare slot and store the name in that slot */
- off = pad_add_name(name,
+ off = pad_add_name(name, len,
+ PL_parser->in_my == KEY_state ? pad_add_STATE : 0,
PL_parser->in_my_stash,
(is_our
/* $_ is always in main::, even with our */
? (PL_curstash && !strEQ(name,"$_") ? PL_curstash : PL_defstash)
: NULL
- ),
- 0, /* not fake */
- PL_parser->in_my == KEY_state
+ )
);
/* anon sub prototypes contains state vars should always be cloned,
* otherwise the state var would be shared between anon subs */
*/
PADOFFSET
-Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool fake, bool state)
+Perl_pad_add_name(pTHX_ const char *name, const STRLEN len, const U32 flags,
+ HV *typestash, HV *ourstash)
{
dVAR;
const PADOFFSET offset = pad_alloc(OP_PADSV, SVs_PADMY);
- SV* const namesv
- = newSV_type((ourstash || typestash) ? SVt_PVMG : SVt_PVNV);
+ SV *namesv;
PERL_ARGS_ASSERT_PAD_ADD_NAME;
ASSERT_CURPAD_ACTIVE("pad_add_name");
+ if (flags & ~(pad_add_STATE|pad_add_FAKE))
+ Perl_croak(aTHX_ "panic: pad_add_name illegal flag bits 0x%" UVxf,
+ (UV)flags);
+
+ namesv = newSV_type((ourstash || typestash) ? SVt_PVMG : SVt_PVNV);
+
+ /* Until we're using the length for real, cross check that we're being told
+ the truth. */
+ PERL_UNUSED_ARG(len);
+ assert(strlen(name) == len);
+
sv_setpv(namesv, name);
if (typestash) {
SvOURSTASH_set(namesv, ourstash);
SvREFCNT_inc_simple_void_NN(ourstash);
}
- else if (state) {
+ else if (flags & pad_add_STATE) {
SvPAD_STATE_on(namesv);
}
av_store(PL_comppad_name, offset, namesv);
- if (fake) {
+ if (flags & pad_add_FAKE) {
SvFAKE_on(namesv);
DEBUG_Xv(PerlIO_printf(Perl_debug_log,
"Pad addname: %ld \"%s\" FAKE\n", (long)offset, name));
new_offset = pad_add_name(
SvPVX_const(*out_name_sv),
+ SvCUR(*out_name_sv),
+ /* state variable ? */
+ pad_add_FAKE | (SvPAD_STATE(*out_name_sv) ? pad_add_STATE : 0),
SvPAD_TYPED(*out_name_sv)
? SvSTASH(*out_name_sv) : NULL,
- SvOURSTASH(*out_name_sv),
- 1, /* fake */
- SvPAD_STATE(*out_name_sv) ? 1 : 0 /* state variable ? */
+ SvOURSTASH(*out_name_sv)
);
new_namesv = AvARRAY(PL_comppad_name)[new_offset];
#define PERL_ARGS_ASSERT_PAD_UNDEF \
assert(cv)
-PERL_CALLCONV PADOFFSET Perl_pad_add_name(pTHX_ const char *name, HV* typestash, HV* ourstash, bool clone, bool state)
+PERL_CALLCONV PADOFFSET Perl_pad_add_name(pTHX_ const char *name, const STRLEN len, const U32 flags, HV *typestash, HV *ourstash)
__attribute__nonnull__(pTHX_1);
#define PERL_ARGS_ASSERT_PAD_ADD_NAME \
assert(name)