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