This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
regcomp.h: Restrict scope of symbols to core
[perl5.git] / pad.h
CommitLineData
dd2155a4
DM
1/* pad.h
2 *
2eee27d7
SS
3 * Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008,
4 * 2009, 2010, 2011 by Larry Wall and others
dd2155a4
DM
5 *
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
8 *
9 * This file defines the types and macros associated with the API for
10 * manipulating scratchpads, which are used by perl to store lexical
11 * variables, op targets and constants.
12 */
13
cc76b5cc 14/*
70b05c7c 15=for apidoc_section Pad Data Structures
cc76b5cc 16*/
dd2155a4
DM
17
18
dd2155a4
DM
19/* offsets within a pad */
20
d081a355 21typedef SSize_t PADOFFSET; /* signed so that -1 is a valid value */
dd2155a4 22#define NOT_IN_PAD ((PADOFFSET) -1)
809abb02 23
9b7476d7
FC
24/* B.xs expects the first members of these two structs to line up
25 (xpadl_max with xpadnl_fill).
26 */
7261499d
FC
27
28struct padlist {
29 SSize_t xpadl_max; /* max index for which array has space */
30dc90f1
DD
30 union {
31 PAD ** xpadlarr_alloc; /* Pointer to beginning of array of AVs.
32 index 0 is a padnamelist * */
33 struct {
34 PADNAMELIST * padnl;
35 PAD * pad_1; /* this slice of PAD * array always alloced */
36 PAD * pad_2; /* maybe unalloced */
37 } * xpadlarr_dbg; /* for use with a C debugger only */
38 } xpadl_arr;
b4db5868
FC
39 U32 xpadl_id; /* Semi-unique ID, shared between clones */
40 U32 xpadl_outid; /* ID of outer pad */
7261499d
FC
41};
42
9b7476d7
FC
43struct padnamelist {
44 SSize_t xpadnl_fill; /* max index in use */
45 PADNAME ** xpadnl_alloc; /* pointer to beginning of array */
46 SSize_t xpadnl_max; /* max index for which array has space */
47 PADOFFSET xpadnl_max_named; /* highest index with len > 0 */
48 U32 xpadnl_refcnt;
49};
50
66230865
FC
51/* PERL_PADNAME_MINIMAL uses less memory, but on some platforms
52 PERL_PADNAME_ALIGNED may be faster, so platform-specific hints can
53 define one or the other. */
54#if defined(PERL_PADNAME_MINIMAL) && defined (PERL_PADNAME_ALIGNED)
55# error PERL_PADNAME_MINIMAL and PERL_PADNAME_ALIGNED are exclusive
56#endif
57
58#if !defined(PERL_PADNAME_MINIMAL) && !defined(PERL_PADNAME_ALIGNED)
3d6de2cd 59# define PERL_PADNAME_MINIMAL
66230865
FC
60#endif
61
62#define _PADNAME_BASE \
63 char * xpadn_pv; \
64 HV * xpadn_ourstash; \
65 union { \
66 HV * xpadn_typestash; \
67 CV * xpadn_protocv; \
68 } xpadn_type_u; \
69 U32 xpadn_low; \
70 U32 xpadn_high; \
71 U32 xpadn_refcnt; \
72 int xpadn_gen; \
73 U8 xpadn_len; \
74 U8 xpadn_flags
75
0f94cb1f 76struct padname {
66230865 77 _PADNAME_BASE;
0f94cb1f
FC
78};
79
80struct padname_with_str {
66230865
FC
81#ifdef PERL_PADNAME_MINIMAL
82 _PADNAME_BASE;
83#else
0f94cb1f 84 struct padname xpadn_padname;
66230865 85#endif
0f94cb1f
FC
86 char xpadn_str[1];
87};
88
66230865
FC
89#undef _PADNAME_BASE
90
0f94cb1f
FC
91#define PADNAME_FROM_PV(s) \
92 ((PADNAME *)((s) - STRUCT_OFFSET(struct padname_with_str, xpadn_str)))
93
7261499d 94
2df5bdd7
DM
95/* a value that PL_cop_seqmax is guaranteed never to be,
96 * flagging that a lexical is being introduced, or has not yet left scope
97 */
98#define PERL_PADSEQ_INTRO U32_MAX
953c8b80
FC
99#define COP_SEQMAX_INC \
100 (PL_cop_seqmax++, \
101 (void)(PL_cop_seqmax == PERL_PADSEQ_INTRO && PL_cop_seqmax++))
2df5bdd7
DM
102
103
7948fc08 104/* B.xs needs these for the benefit of B::Deparse */
809abb02 105/* Low range end is exclusive (valid from the cop seq after this one) */
809abb02 106/* High range end is inclusive (valid up to this cop seq) */
809abb02 107
0f94cb1f
FC
108#define COP_SEQ_RANGE_LOW(pn) (pn)->xpadn_low
109#define COP_SEQ_RANGE_HIGH(pn) (pn)->xpadn_high
110#define PARENT_PAD_INDEX(pn) (pn)->xpadn_low
111#define PARENT_FAKELEX_FLAGS(pn) (pn)->xpadn_high
dd2155a4 112
6c5e080d 113/* Flags set in the SvIVX field of FAKE namesvs */
7948fc08 114
6c5e080d
NC
115#define PAD_FAKELEX_ANON 1 /* the lex is declared in an ANON, or ... */
116#define PAD_FAKELEX_MULTI 2 /* the lex can be instantiated multiple times */
117
dd2155a4
DM
118/* flags for the pad_new() function */
119
c7c737cb
DM
120#define padnew_CLONE 1 /* this pad is for a cloned CV */
121#define padnew_SAVE 2 /* save old globals */
122#define padnew_SAVESUB 4 /* also save extra stuff for start of sub */
dd2155a4
DM
123
124/* values for the pad_tidy() function */
125
126typedef enum {
127 padtidy_SUB, /* tidy up a pad for a sub, */
128 padtidy_SUBCLONE, /* a cloned sub, */
129 padtidy_FORMAT /* or a format */
130} padtidy_type;
131
9f6ec8dd 132/* flags for pad_add_name_pvn. */
35f82371 133
9f6ec8dd
BF
134#define padadd_OUR 0x01 /* our declaration. */
135#define padadd_STATE 0x02 /* state declaration. */
136#define padadd_NO_DUP_CHECK 0x04 /* skip warning on dups. */
7ef30830
FC
137#define padadd_STALEOK 0x08 /* allow stale lexical in active
138 * sub, but only one level up */
35f82371 139
f3548bdc
DM
140/* ASSERT_CURPAD_LEGAL and ASSERT_CURPAD_ACTIVE respectively determine
141 * whether PL_comppad and PL_curpad are consistent and whether they have
142 * active values */
dd2155a4 143
1dba731d 144# define pad_peg(label)
1dba731d 145
f3548bdc
DM
146#ifdef DEBUGGING
147# define ASSERT_CURPAD_LEGAL(label) \
1dba731d 148 pad_peg(label); \
f3548bdc 149 if (PL_comppad ? (AvARRAY(PL_comppad) != PL_curpad) : (PL_curpad != 0)) \
61608bb7 150 Perl_croak(aTHX_ "panic: illegal pad in %s: 0x%" UVxf "[0x%" UVxf "]",\
f3548bdc
DM
151 label, PTR2UV(PL_comppad), PTR2UV(PL_curpad));
152
153
154# define ASSERT_CURPAD_ACTIVE(label) \
1dba731d 155 pad_peg(label); \
f3548bdc 156 if (!PL_comppad || (AvARRAY(PL_comppad) != PL_curpad)) \
61608bb7 157 Perl_croak(aTHX_ "panic: invalid pad in %s: 0x%" UVxf "[0x%" UVxf "]",\
f3548bdc
DM
158 label, PTR2UV(PL_comppad), PTR2UV(PL_curpad));
159#else
160# define ASSERT_CURPAD_LEGAL(label)
161# define ASSERT_CURPAD_ACTIVE(label)
162#endif
163
164
165
166/* Note: the following three macros are actually defined in scope.h, but
dd2155a4
DM
167 * they are documented here for completeness, since they directly or
168 * indirectly affect pads.
169
170=for apidoc m|void|SAVEPADSV |PADOFFSET po
171Save a pad slot (used to restore after an iteration)
172
300ca747
KW
173=cut
174
f3548bdc 175XXX DAPM it would make more sense to make the arg a PADOFFSET
300ca747 176
dd2155a4 177=for apidoc m|void|SAVECLEARSV |SV **svp
154e47c8 178Clear the pointed to pad value on scope exit. (i.e. the runtime action of
796b6530 179C<my>)
dd2155a4
DM
180
181=for apidoc m|void|SAVECOMPPAD
796b6530 182save C<PL_comppad> and C<PL_curpad>
dd2155a4 183
dd2155a4 184
314fdcc2 185=for apidoc Amx|PAD **|PadlistARRAY|PADLIST * padlist
35e035cc
FC
186The C array of a padlist, containing the pads. Only subscript it with
187numbers >= 1, as the 0th entry is not guaranteed to remain usable.
dd2155a4 188
314fdcc2 189=for apidoc Amx|SSize_t|PadlistMAX|PADLIST * padlist
57ee99bb 190The index of the last allocated space in the padlist. Note that the last
796b6530 191pad may be in an earlier slot. Any entries following it will be C<NULL> in
57ee99bb 192that case.
35e035cc 193
314fdcc2 194=for apidoc Amx|PADNAMELIST *|PadlistNAMES|PADLIST * padlist
35e035cc
FC
195The names associated with pad entries.
196
314fdcc2 197=for apidoc Amx|PADNAME **|PadlistNAMESARRAY|PADLIST * padlist
35e035cc
FC
198The C array of pad names.
199
314fdcc2 200=for apidoc Amx|SSize_t|PadlistNAMESMAX|PADLIST * padlist
35e035cc
FC
201The index of the last pad name.
202
314fdcc2 203=for apidoc Amx|U32|PadlistREFCNT|PADLIST * padlist
35e035cc
FC
204The reference count of the padlist. Currently this is always 1.
205
314fdcc2 206=for apidoc Amx|PADNAME **|PadnamelistARRAY|PADNAMELIST * pnl
35e035cc
FC
207The C array of pad names.
208
314fdcc2 209=for apidoc Amx|SSize_t|PadnamelistMAX|PADNAMELIST * pnl
35e035cc
FC
210The index of the last pad name.
211
314fdcc2 212=for apidoc Amx|SSize_t|PadnamelistREFCNT|PADNAMELIST * pnl
9b7476d7
FC
213The reference count of the pad name list.
214
314fdcc2 215=for apidoc Amx|void|PadnamelistREFCNT_dec|PADNAMELIST * pnl
9b7476d7
FC
216Lowers the reference count of the pad name list.
217
314fdcc2 218=for apidoc Amx|SV **|PadARRAY|PAD * pad
35e035cc
FC
219The C array of pad entries.
220
314fdcc2 221=for apidoc Amx|SSize_t|PadMAX|PAD * pad
35e035cc
FC
222The index of the last pad entry.
223
314fdcc2 224=for apidoc Amx|char *|PadnamePV|PADNAME * pn
796b6530 225The name stored in the pad name struct. This returns C<NULL> for a target
863f2221 226slot.
35e035cc 227
314fdcc2 228=for apidoc Amx|STRLEN|PadnameLEN|PADNAME * pn
35e035cc
FC
229The length of the name.
230
314fdcc2 231=for apidoc Amx|bool|PadnameUTF8|PADNAME * pn
4a4088c4 232Whether PadnamePV is in UTF-8. Currently, this is always true.
35e035cc 233
314fdcc2 234=for apidoc Amx|SV *|PadnameSV|PADNAME * pn
0f94cb1f 235Returns the pad name as a mortal SV.
97dad6bd 236
314fdcc2 237=for apidoc m|bool|PadnameIsOUR|PADNAME * pn
35e035cc
FC
238Whether this is an "our" variable.
239
86d2498c 240=for apidoc m|HV *|PadnameOURSTASH
35e035cc
FC
241The stash in which this "our" variable was declared.
242
314fdcc2 243=for apidoc m|bool|PadnameOUTER|PADNAME * pn
b19cb98d
FC
244Whether this entry belongs to an outer pad. Entries for which this is true
245are often referred to as 'fake'.
c44737a2 246
314fdcc2 247=for apidoc m|bool|PadnameIsSTATE|PADNAME * pn
643fe368
FC
248Whether this is a "state" variable.
249
314fdcc2 250=for apidoc m|HV *|PadnameTYPE|PADNAME * pn
796b6530 251The stash associated with a typed lexical. This returns the C<%Foo::> hash
35e035cc 252for C<my Foo $bar>.
dd2155a4 253
314fdcc2 254=for apidoc Amx|SSize_t|PadnameREFCNT|PADNAME * pn
0f94cb1f
FC
255The reference count of the pad name.
256
314fdcc2 257=for apidoc Amx|void|PadnameREFCNT_dec|PADNAME * pn
0f94cb1f
FC
258Lowers the reference count of the pad name.
259
dd2155a4
DM
260
261=for apidoc m|SV *|PAD_SETSV |PADOFFSET po|SV* sv
262Set the slot at offset C<po> in the current pad to C<sv>
263
9a0afbbc 264=for apidoc m|SV *|PAD_SV |PADOFFSET po
dd2155a4
DM
265Get the value at offset C<po> in the current pad
266
267=for apidoc m|SV *|PAD_SVl |PADOFFSET po
268Lightweight and lvalue version of C<PAD_SV>.
269Get or set the value at offset C<po> in the current pad.
270Unlike C<PAD_SV>, does not print diagnostics with -DX.
271For internal use only.
272
273=for apidoc m|SV *|PAD_BASE_SV |PADLIST padlist|PADOFFSET po
274Get the value from slot C<po> in the base (DEPTH=1) pad of a padlist
275
276=for apidoc m|void|PAD_SET_CUR |PADLIST padlist|I32 n
277Set the current pad to be pad C<n> in the padlist, saving
154e47c8 278the previous current pad. NB currently this macro expands to a string too
fd617465
DM
279long for some compilers, so it's best to replace it with
280
281 SAVECOMPPAD();
282 PAD_SET_CUR_NOSAVE(padlist,n);
283
dd2155a4 284
4e380990
DM
285=for apidoc m|void|PAD_SET_CUR_NOSAVE |PADLIST padlist|I32 n
286like PAD_SET_CUR, but without the save
287
dd2155a4
DM
288=for apidoc m|void|PAD_SAVE_SETNULLPAD
289Save the current pad then set it to null.
290
f3548bdc 291=for apidoc m|void|PAD_SAVE_LOCAL|PAD *opad|PAD *npad
796b6530
KW
292Save the current pad to the local variable C<opad>, then make the
293current pad equal to C<npad>
f3548bdc
DM
294
295=for apidoc m|void|PAD_RESTORE_LOCAL|PAD *opad
796b6530 296Restore the old pad saved into the local variable C<opad> by C<PAD_SAVE_LOCAL()>
dd2155a4
DM
297
298=cut
299*/
300
30dc90f1 301#define PadlistARRAY(pl) (pl)->xpadl_arr.xpadlarr_alloc
86d2498c 302#define PadlistMAX(pl) (pl)->xpadl_max
73949fca 303#define PadlistNAMES(pl) *((PADNAMELIST **)PadlistARRAY(pl))
86d2498c
FC
304#define PadlistNAMESARRAY(pl) PadnamelistARRAY(PadlistNAMES(pl))
305#define PadlistNAMESMAX(pl) PadnamelistMAX(PadlistNAMES(pl))
306#define PadlistREFCNT(pl) 1 /* reserved for future use */
7261499d 307
9b7476d7
FC
308#define PadnamelistARRAY(pnl) (pnl)->xpadnl_alloc
309#define PadnamelistMAX(pnl) (pnl)->xpadnl_fill
310#define PadnamelistMAXNAMED(pnl) (pnl)->xpadnl_max_named
311#define PadnamelistREFCNT(pnl) (pnl)->xpadnl_refcnt
312#define PadnamelistREFCNT_dec(pnl) Perl_padnamelist_free(aTHX_ pnl)
35e035cc 313
86d2498c
FC
314#define PadARRAY(pad) AvARRAY(pad)
315#define PadMAX(pad) AvFILLp(pad)
35e035cc 316
0f94cb1f
FC
317#define PadnamePV(pn) (pn)->xpadn_pv
318#define PadnameLEN(pn) (pn)->xpadn_len
319#define PadnameUTF8(pn) 1
320#define PadnameSV(pn) \
321 newSVpvn_flags(PadnamePV(pn), PadnameLEN(pn), SVs_TEMP|SVf_UTF8)
322#define PadnameFLAGS(pn) (pn)->xpadn_flags
323#define PadnameIsOUR(pn) (!!(pn)->xpadn_ourstash)
324#define PadnameOURSTASH(pn) (pn)->xpadn_ourstash
325#define PadnameTYPE(pn) (pn)->xpadn_type_u.xpadn_typestash
326#define PadnamePROTOCV(pn) (pn)->xpadn_type_u.xpadn_protocv
327#define PadnameREFCNT(pn) (pn)->xpadn_refcnt
328#define PadnameREFCNT_dec(pn) Perl_padname_free(aTHX_ pn)
329#define PadnameOURSTASH_set(pn,s) (PadnameOURSTASH(pn) = (s))
330#define PadnameTYPE_set(pn,s) (PadnameTYPE(pn) = (s))
331#define PadnameOUTER(pn) (PadnameFLAGS(pn) & PADNAMEt_OUTER)
332#define PadnameIsSTATE(pn) (PadnameFLAGS(pn) & PADNAMEt_STATE)
333#define PadnameLVALUE(pn) (PadnameFLAGS(pn) & PADNAMEt_LVALUE)
334
335#define PadnameLVALUE_on(pn) (PadnameFLAGS(pn) |= PADNAMEt_LVALUE)
336#define PadnameIsSTATE_on(pn) (PadnameFLAGS(pn) |= PADNAMEt_STATE)
337
338#define PADNAMEt_OUTER 1 /* outer lexical var */
339#define PADNAMEt_STATE 2 /* state var */
340#define PADNAMEt_LVALUE 4 /* used as lvalue */
341#define PADNAMEt_TYPED 8 /* for B; unused by core */
342#define PADNAMEt_OUR 16 /* for B; unused by core */
343
344/* backward compatibility */
345#define SvPAD_STATE PadnameIsSTATE
346#define SvPAD_TYPED(pn) (!!PadnameTYPE(pn))
347#define SvPAD_OUR(pn) (!!PadnameOURSTASH(pn))
348#define SvPAD_STATE_on PadnameIsSTATE_on
349#define SvPAD_TYPED_on(pn) (PadnameFLAGS(pn) |= PADNAMEt_TYPED)
350#define SvPAD_OUR_on(pn) (PadnameFLAGS(pn) |= PADNAMEt_OUR)
351#define SvOURSTASH PadnameOURSTASH
352#define SvOURSTASH_set PadnameOURSTASH_set
353#define SVpad_STATE PADNAMEt_STATE
354#define SVpad_TYPED PADNAMEt_TYPED
355#define SVpad_OUR PADNAMEt_OUR
35e035cc 356
dd2155a4
DM
357#ifdef DEBUGGING
358# define PAD_SV(po) pad_sv(po)
359# define PAD_SETSV(po,sv) pad_setsv(po,sv)
360#else
361# define PAD_SV(po) (PL_curpad[po])
362# define PAD_SETSV(po,sv) PL_curpad[po] = (sv)
363#endif
364
365#define PAD_SVl(po) (PL_curpad[po])
366
367#define PAD_BASE_SV(padlist, po) \
86d2498c
FC
368 (PadlistARRAY(padlist)[1]) \
369 ? AvARRAY(MUTABLE_AV((PadlistARRAY(padlist)[1])))[po] \
7261499d 370 : NULL;
7948fc08 371
dd2155a4 372
de5e01c2 373#define PAD_SET_CUR_NOSAVE(padlist,nth) \
86d2498c 374 PL_comppad = (PAD*) (PadlistARRAY(padlist)[nth]); \
f3548bdc
DM
375 PL_curpad = AvARRAY(PL_comppad); \
376 DEBUG_Xv(PerlIO_printf(Perl_debug_log, \
61608bb7 377 "Pad 0x%" UVxf "[0x%" UVxf "] set_cur depth=%d\n", \
de5e01c2 378 PTR2UV(PL_comppad), PTR2UV(PL_curpad), (int)(nth)));
f3548bdc
DM
379
380
de5e01c2 381#define PAD_SET_CUR(padlist,nth) \
4e380990 382 SAVECOMPPAD(); \
de5e01c2 383 PAD_SET_CUR_NOSAVE(padlist,nth);
4e380990
DM
384
385
f3548bdc 386#define PAD_SAVE_SETNULLPAD() SAVECOMPPAD(); \
4608196e 387 PL_comppad = NULL; PL_curpad = NULL; \
f3548bdc
DM
388 DEBUG_Xv(PerlIO_printf(Perl_debug_log, "Pad set_null\n"));
389
390#define PAD_SAVE_LOCAL(opad,npad) \
391 opad = PL_comppad; \
392 PL_comppad = (npad); \
4608196e 393 PL_curpad = PL_comppad ? AvARRAY(PL_comppad) : NULL; \
f3548bdc 394 DEBUG_Xv(PerlIO_printf(Perl_debug_log, \
61608bb7 395 "Pad 0x%" UVxf "[0x%" UVxf "] save_local\n", \
f3548bdc
DM
396 PTR2UV(PL_comppad), PTR2UV(PL_curpad)));
397
398#define PAD_RESTORE_LOCAL(opad) \
8c63ea58
GG
399 assert(!opad || !SvIS_FREED(opad)); \
400 PL_comppad = opad; \
4608196e 401 PL_curpad = PL_comppad ? AvARRAY(PL_comppad) : NULL; \
f3548bdc 402 DEBUG_Xv(PerlIO_printf(Perl_debug_log, \
61608bb7 403 "Pad 0x%" UVxf "[0x%" UVxf "] restore_local\n", \
f3548bdc 404 PTR2UV(PL_comppad), PTR2UV(PL_curpad)));
dd2155a4
DM
405
406
407/*
408=for apidoc m|void|CX_CURPAD_SAVE|struct context
409Save the current pad in the given context block structure.
410
f3548bdc 411=for apidoc m|SV *|CX_CURPAD_SV|struct context|PADOFFSET po
796b6530 412Access the SV at offset C<po> in the saved current pad in the given
dd2155a4
DM
413context block structure (can be used as an lvalue).
414
415=cut
416*/
417
f3548bdc 418#define CX_CURPAD_SAVE(block) (block).oldcomppad = PL_comppad
a062e10d 419#define CX_CURPAD_SV(block,po) (AvARRAY(MUTABLE_AV(((block).oldcomppad)))[po])
dd2155a4
DM
420
421
422/*
423=for apidoc m|U32|PAD_COMPNAME_FLAGS|PADOFFSET po
424Return the flags for the current compiling pad name
154e47c8 425at offset C<po>. Assumes a valid slot entry.
dd2155a4
DM
426
427=for apidoc m|char *|PAD_COMPNAME_PV|PADOFFSET po
428Return the name of the current compiling pad name
154e47c8 429at offset C<po>. Assumes a valid slot entry.
dd2155a4
DM
430
431=for apidoc m|HV *|PAD_COMPNAME_TYPE|PADOFFSET po
432Return the type (stash) of the current compiling pad name at offset
154e47c8 433C<po>. Must be a valid name. Returns null if not typed.
dd2155a4
DM
434
435=for apidoc m|HV *|PAD_COMPNAME_OURSTASH|PADOFFSET po
436Return the stash associated with an C<our> variable.
437Assumes the slot entry is a valid C<our> lexical.
438
439=for apidoc m|STRLEN|PAD_COMPNAME_GEN|PADOFFSET po
440The generation number of the name at offset C<po> in the current
e25bbd9e 441compiling pad (lvalue).
dd2155a4 442
b162af07
SP
443=for apidoc m|STRLEN|PAD_COMPNAME_GEN_set|PADOFFSET po|int gen
444Sets the generation number of the name at offset C<po> in the current
e25bbd9e 445ling pad (lvalue) to C<gen>.
dd2155a4 446=cut
b162af07 447
dd2155a4
DM
448*/
449
35e035cc 450#define PAD_COMPNAME(po) PAD_COMPNAME_SV(po)
9b7476d7 451#define PAD_COMPNAME_SV(po) (PadnamelistARRAY(PL_comppad_name)[(po)])
0f94cb1f 452#define PAD_COMPNAME_FLAGS(po) PadnameFLAGS(PAD_COMPNAME(po))
1979170b 453#define PAD_COMPNAME_FLAGS_isOUR(po) SvPAD_OUR(PAD_COMPNAME_SV(po))
e1c02f84 454#define PAD_COMPNAME_PV(po) PadnamePV(PAD_COMPNAME(po))
dd2155a4 455
afb6e3f5 456#define PAD_COMPNAME_TYPE(po) PadnameTYPE(PAD_COMPNAME(po))
dd2155a4
DM
457
458#define PAD_COMPNAME_OURSTASH(po) \
73d95100 459 (SvOURSTASH(PAD_COMPNAME_SV(po)))
dd2155a4 460
9b7476d7 461#define PAD_COMPNAME_GEN(po) \
0f94cb1f 462 ((STRLEN)PadnamelistARRAY(PL_comppad_name)[po]->xpadn_gen)
dd2155a4 463
9b7476d7 464#define PAD_COMPNAME_GEN_set(po, gen) \
0f94cb1f 465 (PadnamelistARRAY(PL_comppad_name)[po]->xpadn_gen = (gen))
dd2155a4
DM
466
467
468/*
d77cdebf 469=for apidoc m|void|PAD_CLONE_VARS|PerlInterpreter *proto_perl|CLONE_PARAMS* param
dd2155a4
DM
470Clone the state variables associated with running and compiling pads.
471
472=cut
473*/
474
c5ab0850
DM
475/* NB - we set PL_comppad to null unless it points at a value that
476 * has already been dup'ed, ie it points to part of an active padlist.
477 * Otherwise PL_comppad ends up being a leaked scalar in code like
478 * the following:
479 * threads->create(sub { threads->create(sub {...} ) } );
480 * where the second thread dups the outer sub's comppad but not the
481 * sub's CV or padlist. */
f3548bdc 482
dd2155a4 483#define PAD_CLONE_VARS(proto_perl, param) \
253649d9 484 PL_comppad = av_dup(proto_perl->Icomppad, param); \
4608196e 485 PL_curpad = PL_comppad ? AvARRAY(PL_comppad) : NULL; \
9b7476d7
FC
486 PL_comppad_name = \
487 padnamelist_dup(proto_perl->Icomppad_name, param); \
dd2155a4
DM
488 PL_comppad_name_fill = proto_perl->Icomppad_name_fill; \
489 PL_comppad_name_floor = proto_perl->Icomppad_name_floor; \
dd2155a4
DM
490 PL_min_intro_pending = proto_perl->Imin_intro_pending; \
491 PL_max_intro_pending = proto_perl->Imax_intro_pending; \
492 PL_padix = proto_perl->Ipadix; \
493 PL_padix_floor = proto_perl->Ipadix_floor; \
494 PL_pad_reset_pending = proto_perl->Ipad_reset_pending; \
495 PL_cop_seqmax = proto_perl->Icop_seqmax;
e9a8c099
MHM
496
497/*
3bb9fd01 498=for apidoc Am|PADOFFSET|pad_add_name_pvs|"name"|U32 flags|HV *typestash|HV *ourstash
cc76b5cc 499
1568d13a 500Exactly like L</pad_add_name_pvn>, but takes a literal string
0c395ea5 501instead of a string/length pair.
cc76b5cc
Z
502
503=cut
504*/
505
506#define pad_add_name_pvs(name,flags,typestash,ourstash) \
507 Perl_pad_add_name_pvn(aTHX_ STR_WITH_LEN(name), flags, typestash, ourstash)
508
509/*
3bb9fd01 510=for apidoc Am|PADOFFSET|pad_findmy_pvs|"name"|U32 flags
cc76b5cc 511
1568d13a 512Exactly like L</pad_findmy_pvn>, but takes a literal string
0c395ea5 513instead of a string/length pair.
cc76b5cc
Z
514
515=cut
516*/
517
518#define pad_findmy_pvs(name,flags) \
519 Perl_pad_findmy_pvn(aTHX_ STR_WITH_LEN(name), flags)
520
521/*
14d04a33 522 * ex: set ts=8 sts=4 sw=4 et:
e9a8c099 523 */