This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix typo in vms/gen_shrfls.pl itanium detector
[perl5.git] / scope.c
CommitLineData
a0d0e21e 1/* scope.c
79072805 2 *
4bb101f2 3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
54ca4ee7 4 * 2000, 2001, 2002, 2003, 2004, 2005, 2006, by Larry Wall and others
79072805
LW
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 *
a0d0e21e
LW
9 */
10
11/*
12 * "For the fashion of Minas Tirith was such that it was built on seven
13 * levels..."
79072805
LW
14 */
15
ddfa107c 16/* This file contains functions to manipulate several of Perl's stacks;
166f8a29
DM
17 * in particular it contains code to push various types of things onto
18 * the savestack, then to pop them off and perform the correct restorative
19 * action for each one. This corresponds to the cleanup Perl does at
20 * each scope exit.
21 */
22
79072805 23#include "EXTERN.h"
864dbfa3 24#define PERL_IN_SCOPE_C
79072805
LW
25#include "perl.h"
26
a0d0e21e 27SV**
864dbfa3 28Perl_stack_grow(pTHX_ SV **sp, SV **p, int n)
a0d0e21e 29{
97aff369 30 dVAR;
3280af22 31 PL_stack_sp = sp;
2ce36478 32#ifndef STRESS_REALLOC
3280af22 33 av_extend(PL_curstack, (p - PL_stack_base) + (n) + 128);
2ce36478 34#else
6b88bc9c 35 av_extend(PL_curstack, (p - PL_stack_base) + (n) + 1);
2ce36478 36#endif
3280af22 37 return PL_stack_sp;
a0d0e21e
LW
38}
39
2ce36478
SM
40#ifndef STRESS_REALLOC
41#define GROW(old) ((old) * 3 / 2)
42#else
43#define GROW(old) ((old) + 1)
44#endif
45
e336de0d 46PERL_SI *
864dbfa3 47Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems)
e336de0d 48{
97aff369 49 dVAR;
e336de0d 50 PERL_SI *si;
a02a5408 51 Newx(si, 1, PERL_SI);
e336de0d
GS
52 si->si_stack = newAV();
53 AvREAL_off(si->si_stack);
54 av_extend(si->si_stack, stitems > 0 ? stitems-1 : 0);
3280af22 55 AvALLOC(si->si_stack)[0] = &PL_sv_undef;
e336de0d
GS
56 AvFILLp(si->si_stack) = 0;
57 si->si_prev = 0;
58 si->si_next = 0;
59 si->si_cxmax = cxitems - 1;
60 si->si_cxix = -1;
e788e7d3 61 si->si_type = PERLSI_UNDEF;
a02a5408 62 Newx(si->si_cxstack, cxitems, PERL_CONTEXT);
9965345d
JH
63 /* Without any kind of initialising PUSHSUBST()
64 * in pp_subst() will read uninitialised heap. */
7e337ee0 65 PoisonNew(si->si_cxstack, cxitems, PERL_CONTEXT);
e336de0d
GS
66 return si;
67}
68
79072805 69I32
864dbfa3 70Perl_cxinc(pTHX)
79072805 71{
97aff369 72 dVAR;
a3b680e6 73 const IV old_max = cxstack_max;
2ce36478 74 cxstack_max = GROW(cxstack_max);
c09156bb 75 Renew(cxstack, cxstack_max + 1, PERL_CONTEXT); /* XXX should fix CXINC macro */
9965345d
JH
76 /* Without any kind of initialising deep enough recursion
77 * will end up reading uninitialised PERL_CONTEXTs. */
7e337ee0 78 PoisonNew(cxstack + old_max + 1, cxstack_max - old_max, PERL_CONTEXT);
79072805
LW
79 return cxstack_ix + 1;
80}
81
79072805 82void
864dbfa3 83Perl_push_scope(pTHX)
79072805 84{
97aff369 85 dVAR;
3280af22
NIS
86 if (PL_scopestack_ix == PL_scopestack_max) {
87 PL_scopestack_max = GROW(PL_scopestack_max);
88 Renew(PL_scopestack, PL_scopestack_max, I32);
79072805 89 }
3280af22 90 PL_scopestack[PL_scopestack_ix++] = PL_savestack_ix;
79072805
LW
91
92}
93
94void
864dbfa3 95Perl_pop_scope(pTHX)
79072805 96{
97aff369 97 dVAR;
35a4481c 98 const I32 oldsave = PL_scopestack[--PL_scopestack_ix];
8990e307 99 LEAVE_SCOPE(oldsave);
79072805
LW
100}
101
102void
864dbfa3 103Perl_markstack_grow(pTHX)
a0d0e21e 104{
97aff369 105 dVAR;
35a4481c
AL
106 const I32 oldmax = PL_markstack_max - PL_markstack;
107 const I32 newmax = GROW(oldmax);
a0d0e21e 108
3280af22
NIS
109 Renew(PL_markstack, newmax, I32);
110 PL_markstack_ptr = PL_markstack + oldmax;
111 PL_markstack_max = PL_markstack + newmax;
a0d0e21e
LW
112}
113
114void
864dbfa3 115Perl_savestack_grow(pTHX)
79072805 116{
97aff369 117 dVAR;
8aacddc1 118 PL_savestack_max = GROW(PL_savestack_max) + 4;
3280af22 119 Renew(PL_savestack, PL_savestack_max, ANY);
79072805
LW
120}
121
4b3c1a47
AE
122void
123Perl_savestack_grow_cnt(pTHX_ I32 need)
124{
97aff369 125 dVAR;
4b3c1a47
AE
126 PL_savestack_max = PL_savestack_ix + need;
127 Renew(PL_savestack, PL_savestack_max, ANY);
128}
129
2ce36478
SM
130#undef GROW
131
79072805 132void
864dbfa3 133Perl_tmps_grow(pTHX_ I32 n)
677b06e3 134{
97aff369 135 dVAR;
677b06e3
GS
136#ifndef STRESS_REALLOC
137 if (n < 128)
138 n = (PL_tmps_max < 512) ? 128 : 512;
139#endif
140 PL_tmps_max = PL_tmps_ix + n + 1;
141 Renew(PL_tmps_stack, PL_tmps_max, SV*);
142}
143
144
145void
864dbfa3 146Perl_free_tmps(pTHX)
79072805 147{
97aff369 148 dVAR;
79072805 149 /* XXX should tmps_floor live in cxstack? */
35a4481c 150 const I32 myfloor = PL_tmps_floor;
3280af22 151 while (PL_tmps_ix > myfloor) { /* clean up after last statement */
901017d6 152 SV* const sv = PL_tmps_stack[PL_tmps_ix];
a0714e2c 153 PL_tmps_stack[PL_tmps_ix--] = NULL;
8aacddc1 154 if (sv && sv != &PL_sv_undef) {
463ee0b2 155 SvTEMP_off(sv);
8990e307 156 SvREFCNT_dec(sv); /* note, can modify tmps_ix!!! */
463ee0b2 157 }
79072805
LW
158 }
159}
160
76e3520e 161STATIC SV *
cea2e8a9 162S_save_scalar_at(pTHX_ SV **sptr)
79072805 163{
97aff369 164 dVAR;
901017d6 165 SV * const osv = *sptr;
561b68a9 166 register SV * const sv = *sptr = newSV(0);
79072805 167
81d86705 168#ifdef PERL_MAD
49e9cc5f 169 /* FIXME for MAD - this is causing ext/Safe/t/safeops.t to abort. */
81d86705
NC
170 if (PL_formfeed && sv == PL_formfeed)
171 abort();
172#endif
173
a0d0e21e 174 if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) {
a0d0e21e 175 if (SvGMAGICAL(osv)) {
35a4481c 176 const bool oldtainted = PL_tainted;
a0d0e21e 177 SvFLAGS(osv) |= (SvFLAGS(osv) &
c268c2a6 178 (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT;
3280af22 179 PL_tainted = oldtainted;
a0d0e21e 180 }
0cbee0a4 181 mg_localize(osv, sv);
79072805
LW
182 }
183 return sv;
184}
185
7a4c00b4 186SV *
864dbfa3 187Perl_save_scalar(pTHX_ GV *gv)
7a4c00b4 188{
97aff369 189 dVAR;
fb4fc1fa 190 SV ** const sptr = &GvSVn(gv);
81d86705
NC
191#ifdef PERL_MAD
192 if (PL_formfeed && *sptr == PL_formfeed)
193 abort();
194#endif
27cc343c 195 PL_localizing = 1;
0cbee0a4 196 SvGETMAGIC(*sptr);
27cc343c 197 PL_localizing = 0;
7a4c00b4 198 SSCHECK(3);
b37c2d43 199 SSPUSHPTR(SvREFCNT_inc_simple(gv));
4e4c362e 200 SSPUSHPTR(SvREFCNT_inc(*sptr));
7a4c00b4 201 SSPUSHINT(SAVEt_SV);
4e4c362e 202 return save_scalar_at(sptr);
7a4c00b4
PP
203}
204
f4dd75d9 205/* Like save_sptr(), but also SvREFCNT_dec()s the new value. Can be used to
b9d12d37
GS
206 * restore a global SV to its prior contents, freeing new value. */
207void
864dbfa3 208Perl_save_generic_svref(pTHX_ SV **sptr)
b9d12d37 209{
97aff369 210 dVAR;
81d86705
NC
211#ifdef PERL_MAD
212 if (PL_formfeed && *sptr == PL_formfeed)
213 abort();
214#endif
b9d12d37
GS
215 SSCHECK(3);
216 SSPUSHPTR(sptr);
217 SSPUSHPTR(SvREFCNT_inc(*sptr));
218 SSPUSHINT(SAVEt_GENERIC_SVREF);
219}
220
f4dd75d9
GS
221/* Like save_pptr(), but also Safefree()s the new value if it is different
222 * from the old one. Can be used to restore a global char* to its prior
223 * contents, freeing new value. */
224void
225Perl_save_generic_pvref(pTHX_ char **str)
226{
97aff369 227 dVAR;
f4dd75d9
GS
228 SSCHECK(3);
229 SSPUSHPTR(str);
230 SSPUSHPTR(*str);
231 SSPUSHINT(SAVEt_GENERIC_PVREF);
232}
233
05ec9bb3
NIS
234/* Like save_generic_pvref(), but uses PerlMemShared_free() rather than Safefree().
235 * Can be used to restore a shared global char* to its prior
236 * contents, freeing new value. */
237void
238Perl_save_shared_pvref(pTHX_ char **str)
239{
97aff369 240 dVAR;
05ec9bb3
NIS
241 SSCHECK(3);
242 SSPUSHPTR(str);
243 SSPUSHPTR(*str);
244 SSPUSHINT(SAVEt_SHARED_PVREF);
245}
246
14f338dc
DM
247/* set the SvFLAGS specified by mask to the values in val */
248
249void
250Perl_save_set_svflags(pTHX_ SV* sv, U32 mask, U32 val)
251{
97aff369 252 dVAR;
14f338dc
DM
253 SSCHECK(4);
254 SSPUSHPTR(sv);
255 SSPUSHINT(mask);
256 SSPUSHINT(val);
257 SSPUSHINT(SAVEt_SET_SVFLAGS);
258}
259
79072805 260void
864dbfa3 261Perl_save_gp(pTHX_ GV *gv, I32 empty)
79072805 262{
97aff369 263 dVAR;
576df6af 264 SSGROW(3);
4633a7c4 265 SSPUSHPTR(SvREFCNT_inc(gv));
5f05dabc 266 SSPUSHPTR(GvGP(gv));
79072805
LW
267 SSPUSHINT(SAVEt_GP);
268
5f05dabc
PP
269 if (empty) {
270 register GP *gp;
fae75791 271
a02a5408 272 Newxz(gp, 1, GP);
146174a9 273
fae75791 274 if (GvCVu(gv))
3280af22 275 PL_sub_generation++; /* taking a method out of circulation */
146174a9
CB
276 if (GvIOp(gv) && (IoFLAGS(GvIOp(gv)) & IOf_ARGV)) {
277 gp->gp_io = newIO();
278 IoFLAGS(gp->gp_io) |= IOf_ARGV|IOf_START;
279 }
44a8e56a 280 GvGP(gv) = gp_ref(gp);
fb4fc1fa 281#ifndef PERL_DONT_CREATE_GVSV
561b68a9 282 GvSV(gv) = newSV(0);
fb4fc1fa 283#endif
146174a9 284 GvLINE(gv) = CopLINE(PL_curcop);
07409e01
NC
285 /* XXX Ideally this cast would be replaced with a change to const char*
286 in the struct. */
287 GvFILE(gv) = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : (char *) "";
5f05dabc
PP
288 GvEGV(gv) = gv;
289 }
290 else {
44a8e56a 291 gp_ref(GvGP(gv));
5f05dabc
PP
292 GvINTRO_on(gv);
293 }
79072805 294}
79072805 295
79072805 296AV *
864dbfa3 297Perl_save_ary(pTHX_ GV *gv)
79072805 298{
97aff369 299 dVAR;
901017d6 300 AV * const oav = GvAVn(gv);
67a38de0 301 AV *av;
fb73857a 302
67a38de0
NIS
303 if (!AvREAL(oav) && AvREIFY(oav))
304 av_reify(oav);
79072805
LW
305 SSCHECK(3);
306 SSPUSHPTR(gv);
67a38de0 307 SSPUSHPTR(oav);
79072805
LW
308 SSPUSHINT(SAVEt_AV);
309
4608196e 310 GvAV(gv) = NULL;
fb73857a 311 av = GvAVn(gv);
0cbee0a4
DM
312 if (SvMAGIC(oav))
313 mg_localize((SV*)oav, (SV*)av);
fb73857a 314 return av;
79072805
LW
315}
316
317HV *
864dbfa3 318Perl_save_hash(pTHX_ GV *gv)
79072805 319{
97aff369 320 dVAR;
fb73857a
PP
321 HV *ohv, *hv;
322
79072805
LW
323 SSCHECK(3);
324 SSPUSHPTR(gv);
fb73857a 325 SSPUSHPTR(ohv = GvHVn(gv));
79072805
LW
326 SSPUSHINT(SAVEt_HV);
327
4608196e 328 GvHV(gv) = NULL;
fb73857a 329 hv = GvHVn(gv);
0cbee0a4
DM
330 if (SvMAGIC(ohv))
331 mg_localize((SV*)ohv, (SV*)hv);
fb73857a 332 return hv;
79072805
LW
333}
334
335void
864dbfa3 336Perl_save_item(pTHX_ register SV *item)
79072805 337{
97aff369 338 dVAR;
901017d6 339 register SV * const sv = newSVsv(item);
79072805 340
81d86705
NC
341#ifdef PERL_MAD
342 if (PL_formfeed && item == PL_formfeed)
343 abort();
344#endif
345
79072805
LW
346 SSCHECK(3);
347 SSPUSHPTR(item); /* remember the pointer */
79072805
LW
348 SSPUSHPTR(sv); /* remember the value */
349 SSPUSHINT(SAVEt_ITEM);
350}
351
352void
864dbfa3 353Perl_save_int(pTHX_ int *intp)
79072805 354{
97aff369 355 dVAR;
79072805
LW
356 SSCHECK(3);
357 SSPUSHINT(*intp);
358 SSPUSHPTR(intp);
359 SSPUSHINT(SAVEt_INT);
360}
361
362void
9febdf04
RH
363Perl_save_bool(pTHX_ bool *boolp)
364{
97aff369 365 dVAR;
9febdf04
RH
366 SSCHECK(3);
367 SSPUSHBOOL(*boolp);
368 SSPUSHPTR(boolp);
369 SSPUSHINT(SAVEt_BOOL);
370}
371
372void
864dbfa3 373Perl_save_I32(pTHX_ I32 *intp)
79072805 374{
97aff369 375 dVAR;
79072805
LW
376 SSCHECK(3);
377 SSPUSHINT(*intp);
378 SSPUSHPTR(intp);
379 SSPUSHINT(SAVEt_I32);
380}
381
85e6fe83
LW
382/* Cannot use save_sptr() to store a char* since the SV** cast will
383 * force word-alignment and we'll miss the pointer.
384 */
385void
864dbfa3 386Perl_save_pptr(pTHX_ char **pptr)
85e6fe83 387{
97aff369 388 dVAR;
85e6fe83
LW
389 SSCHECK(3);
390 SSPUSHPTR(*pptr);
391 SSPUSHPTR(pptr);
392 SSPUSHINT(SAVEt_PPTR);
393}
394
79072805 395void
146174a9
CB
396Perl_save_vptr(pTHX_ void *ptr)
397{
97aff369 398 dVAR;
146174a9
CB
399 SSCHECK(3);
400 SSPUSHPTR(*(char**)ptr);
401 SSPUSHPTR(ptr);
402 SSPUSHINT(SAVEt_VPTR);
403}
404
405void
864dbfa3 406Perl_save_sptr(pTHX_ SV **sptr)
79072805 407{
97aff369 408 dVAR;
79072805
LW
409 SSCHECK(3);
410 SSPUSHPTR(*sptr);
411 SSPUSHPTR(sptr);
412 SSPUSHINT(SAVEt_SPTR);
413}
414
c3564e5c
GS
415void
416Perl_save_padsv(pTHX_ PADOFFSET off)
417{
97aff369 418 dVAR;
c3564e5c 419 SSCHECK(4);
f3548bdc 420 ASSERT_CURPAD_ACTIVE("save_padsv");
c3564e5c 421 SSPUSHPTR(PL_curpad[off]);
f3548bdc 422 SSPUSHPTR(PL_comppad);
c3564e5c
GS
423 SSPUSHLONG((long)off);
424 SSPUSHINT(SAVEt_PADSV);
425}
426
79072805 427void
864dbfa3 428Perl_save_hptr(pTHX_ HV **hptr)
79072805 429{
97aff369 430 dVAR;
79072805 431 SSCHECK(3);
85e6fe83 432 SSPUSHPTR(*hptr);
79072805
LW
433 SSPUSHPTR(hptr);
434 SSPUSHINT(SAVEt_HPTR);
435}
436
437void
864dbfa3 438Perl_save_aptr(pTHX_ AV **aptr)
79072805 439{
97aff369 440 dVAR;
79072805 441 SSCHECK(3);
85e6fe83 442 SSPUSHPTR(*aptr);
79072805
LW
443 SSPUSHPTR(aptr);
444 SSPUSHINT(SAVEt_APTR);
445}
446
447void
864dbfa3 448Perl_save_freesv(pTHX_ SV *sv)
8990e307 449{
97aff369 450 dVAR;
8990e307
LW
451 SSCHECK(2);
452 SSPUSHPTR(sv);
453 SSPUSHINT(SAVEt_FREESV);
454}
455
456void
26d9b02f
JH
457Perl_save_mortalizesv(pTHX_ SV *sv)
458{
97aff369 459 dVAR;
26d9b02f
JH
460 SSCHECK(2);
461 SSPUSHPTR(sv);
462 SSPUSHINT(SAVEt_MORTALIZESV);
463}
464
465void
864dbfa3 466Perl_save_freeop(pTHX_ OP *o)
8990e307 467{
97aff369 468 dVAR;
8990e307 469 SSCHECK(2);
11343788 470 SSPUSHPTR(o);
8990e307
LW
471 SSPUSHINT(SAVEt_FREEOP);
472}
473
474void
864dbfa3 475Perl_save_freepv(pTHX_ char *pv)
8990e307 476{
97aff369 477 dVAR;
8990e307
LW
478 SSCHECK(2);
479 SSPUSHPTR(pv);
480 SSPUSHINT(SAVEt_FREEPV);
481}
482
483void
864dbfa3 484Perl_save_clearsv(pTHX_ SV **svp)
8990e307 485{
97aff369 486 dVAR;
f3548bdc 487 ASSERT_CURPAD_ACTIVE("save_clearsv");
8990e307 488 SSCHECK(2);
3280af22 489 SSPUSHLONG((long)(svp-PL_curpad));
8990e307 490 SSPUSHINT(SAVEt_CLEARSV);
d9d18af6 491 SvPADSTALE_off(*svp); /* mark lexical as active */
8990e307
LW
492}
493
494void
864dbfa3 495Perl_save_delete(pTHX_ HV *hv, char *key, I32 klen)
8990e307 496{
97aff369 497 dVAR;
8990e307
LW
498 SSCHECK(4);
499 SSPUSHINT(klen);
500 SSPUSHPTR(key);
b37c2d43 501 SSPUSHPTR(SvREFCNT_inc_simple(hv));
8990e307
LW
502 SSPUSHINT(SAVEt_DELETE);
503}
504
505void
146174a9
CB
506Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p)
507{
97aff369 508 dVAR;
146174a9
CB
509 SSCHECK(3);
510 SSPUSHDXPTR(f);
511 SSPUSHPTR(p);
512 SSPUSHINT(SAVEt_DESTRUCTOR_X);
513}
514
515void
59413342 516Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
4e4c362e 517{
97aff369 518 dVAR;
bfc4de9f 519 SV *sv;
0cbee0a4 520 SvGETMAGIC(*sptr);
4e4c362e 521 SSCHECK(4);
b37c2d43 522 SSPUSHPTR(SvREFCNT_inc_simple(av));
4e4c362e
GS
523 SSPUSHINT(idx);
524 SSPUSHPTR(SvREFCNT_inc(*sptr));
525 SSPUSHINT(SAVEt_AELEM);
5dd42e15
DM
526 /* if it gets reified later, the restore will have the wrong refcnt */
527 if (!AvREAL(av) && AvREIFY(av))
b37c2d43 528 SvREFCNT_inc_void(*sptr);
4e4c362e 529 save_scalar_at(sptr);
bfc4de9f
DM
530 sv = *sptr;
531 /* If we're localizing a tied array element, this new sv
532 * won't actually be stored in the array - so it won't get
533 * reaped when the localize ends. Ensure it gets reaped by
534 * mortifying it instead. DAPM */
535 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
536 sv_2mortal(sv);
4e4c362e
GS
537}
538
539void
e1ec3a88 540Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr)
4e4c362e 541{
97aff369 542 dVAR;
bfc4de9f 543 SV *sv;
0cbee0a4 544 SvGETMAGIC(*sptr);
4e4c362e 545 SSCHECK(4);
b37c2d43
AL
546 SSPUSHPTR(SvREFCNT_inc_simple(hv));
547 SSPUSHPTR(SvREFCNT_inc_simple(key));
4e4c362e
GS
548 SSPUSHPTR(SvREFCNT_inc(*sptr));
549 SSPUSHINT(SAVEt_HELEM);
550 save_scalar_at(sptr);
bfc4de9f
DM
551 sv = *sptr;
552 /* If we're localizing a tied hash element, this new sv
553 * won't actually be stored in the hash - so it won't get
554 * reaped when the localize ends. Ensure it gets reaped by
555 * mortifying it instead. DAPM */
556 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
557 sv_2mortal(sv);
4e4c362e
GS
558}
559
2053acbf
NC
560SV*
561Perl_save_svref(pTHX_ SV **sptr)
562{
563 dVAR;
81d86705
NC
564#ifdef PERL_MAD
565 if (PL_formfeed && *sptr == PL_formfeed)
566 abort();
567#endif
2053acbf
NC
568 SvGETMAGIC(*sptr);
569 SSCHECK(3);
570 SSPUSHPTR(sptr);
571 SSPUSHPTR(SvREFCNT_inc(*sptr));
572 SSPUSHINT(SAVEt_SVREF);
573 return save_scalar_at(sptr);
574}
575
4e4c362e 576void
864dbfa3 577Perl_save_op(pTHX)
462e5cf6 578{
97aff369 579 dVAR;
462e5cf6 580 SSCHECK(2);
533c011a 581 SSPUSHPTR(PL_op);
462e5cf6
MB
582 SSPUSHINT(SAVEt_OP);
583}
584
455ece5e 585I32
864dbfa3 586Perl_save_alloc(pTHX_ I32 size, I32 pad)
455ece5e 587{
97aff369 588 dVAR;
35a4481c 589 register const I32 start = pad + ((char*)&PL_savestack[PL_savestack_ix]
8aacddc1 590 - (char*)PL_savestack);
35a4481c 591 register const I32 elems = 1 + ((size + pad - 1) / sizeof(*PL_savestack));
455ece5e
AD
592
593 /* SSCHECK may not be good enough */
594 while (PL_savestack_ix + elems + 2 > PL_savestack_max)
8aacddc1 595 savestack_grow();
455ece5e
AD
596
597 PL_savestack_ix += elems;
598 SSPUSHINT(elems);
599 SSPUSHINT(SAVEt_ALLOC);
600 return start;
601}
602
462e5cf6 603void
864dbfa3 604Perl_leave_scope(pTHX_ I32 base)
79072805 605{
97aff369 606 dVAR;
79072805
LW
607 register SV *sv;
608 register SV *value;
609 register GV *gv;
610 register AV *av;
611 register HV *hv;
20454177 612 void* ptr;
f4dd75d9 613 register char* str;
161b7d16 614 I32 i;
79072805
LW
615
616 if (base < -1)
cea2e8a9 617 Perl_croak(aTHX_ "panic: corrupt saved stack index");
3280af22 618 while (PL_savestack_ix > base) {
79072805
LW
619 switch (SSPOPINT) {
620 case SAVEt_ITEM: /* normal string */
621 value = (SV*)SSPOPPTR;
622 sv = (SV*)SSPOPPTR;
623 sv_replace(sv,value);
3280af22 624 PL_localizing = 2;
79072805 625 SvSETMAGIC(sv);
3280af22 626 PL_localizing = 0;
79072805 627 break;
8aacddc1 628 case SAVEt_SV: /* scalar reference */
79072805
LW
629 value = (SV*)SSPOPPTR;
630 gv = (GV*)SSPOPPTR;
7a4c00b4 631 ptr = &GvSV(gv);
5dd42e15 632 av = (AV*)gv; /* what to refcnt_dec */
2053acbf
NC
633 restore_sv:
634 sv = *(SV**)ptr;
635 DEBUG_S(PerlIO_printf(Perl_debug_log,
636 "restore svref: %p %p:%s -> %p:%s\n",
637 ptr, sv, SvPEEK(sv), value, SvPEEK(value)));
638 *(SV**)ptr = value;
639 SvREFCNT_dec(sv);
640 PL_localizing = 2;
641 SvSETMAGIC(value);
642 PL_localizing = 0;
643 SvREFCNT_dec(value);
644 if (av) /* actually an av, hv or gv */
645 SvREFCNT_dec(av);
646 break;
8aacddc1 647 case SAVEt_GENERIC_PVREF: /* generic pv */
f4dd75d9
GS
648 str = (char*)SSPOPPTR;
649 ptr = SSPOPPTR;
650 if (*(char**)ptr != str) {
651 Safefree(*(char**)ptr);
652 *(char**)ptr = str;
653 }
654 break;
05ec9bb3
NIS
655 case SAVEt_SHARED_PVREF: /* shared pv */
656 str = (char*)SSPOPPTR;
657 ptr = SSPOPPTR;
658 if (*(char**)ptr != str) {
5e54c26f 659#ifdef NETWARE
9ecbcc42 660 PerlMem_free(*(char**)ptr);
5e54c26f 661#else
05ec9bb3 662 PerlMemShared_free(*(char**)ptr);
5e54c26f 663#endif
05ec9bb3
NIS
664 *(char**)ptr = str;
665 }
666 break;
8aacddc1 667 case SAVEt_GENERIC_SVREF: /* generic sv */
b9d12d37
GS
668 value = (SV*)SSPOPPTR;
669 ptr = SSPOPPTR;
f4dd75d9
GS
670 sv = *(SV**)ptr;
671 *(SV**)ptr = value;
672 SvREFCNT_dec(sv);
b9d12d37
GS
673 SvREFCNT_dec(value);
674 break;
8aacddc1 675 case SAVEt_AV: /* array reference */
79072805
LW
676 av = (AV*)SSPOPPTR;
677 gv = (GV*)SSPOPPTR;
fb73857a 678 if (GvAV(gv)) {
35a4481c 679 AV * const goner = GvAV(gv);
404a4710
NC
680 /* FIXME - this is a temporary hack until we work out what
681 the correct behaviour for magic should be. */
682 sv_unmagic((SV*)goner, PERL_MAGIC_arylen_p);
b162af07 683 SvMAGIC_set(av, SvMAGIC(goner));
32da55ab 684 SvFLAGS((SV*)av) |= SvMAGICAL(goner);
fb73857a 685 SvMAGICAL_off(goner);
b162af07 686 SvMAGIC_set(goner, NULL);
fb73857a
PP
687 SvREFCNT_dec(goner);
688 }
8aacddc1 689 GvAV(gv) = av;
fb73857a 690 if (SvMAGICAL(av)) {
3280af22 691 PL_localizing = 2;
fb73857a 692 SvSETMAGIC((SV*)av);
3280af22 693 PL_localizing = 0;
fb73857a 694 }
8aacddc1
NIS
695 break;
696 case SAVEt_HV: /* hash reference */
79072805
LW
697 hv = (HV*)SSPOPPTR;
698 gv = (GV*)SSPOPPTR;
fb73857a 699 if (GvHV(gv)) {
35a4481c 700 HV * const goner = GvHV(gv);
b162af07 701 SvMAGIC_set(hv, SvMAGIC(goner));
fb73857a
PP
702 SvFLAGS(hv) |= SvMAGICAL(goner);
703 SvMAGICAL_off(goner);
b162af07 704 SvMAGIC_set(goner, NULL);
fb73857a
PP
705 SvREFCNT_dec(goner);
706 }
8aacddc1 707 GvHV(gv) = hv;
fb73857a 708 if (SvMAGICAL(hv)) {
3280af22 709 PL_localizing = 2;
fb73857a 710 SvSETMAGIC((SV*)hv);
3280af22 711 PL_localizing = 0;
fb73857a 712 }
8aacddc1 713 break;
79072805
LW
714 case SAVEt_INT: /* int reference */
715 ptr = SSPOPPTR;
716 *(int*)ptr = (int)SSPOPINT;
717 break;
9febdf04
RH
718 case SAVEt_BOOL: /* bool reference */
719 ptr = SSPOPPTR;
720 *(bool*)ptr = (bool)SSPOPBOOL;
721 break;
79072805
LW
722 case SAVEt_I32: /* I32 reference */
723 ptr = SSPOPPTR;
724 *(I32*)ptr = (I32)SSPOPINT;
725 break;
726 case SAVEt_SPTR: /* SV* reference */
727 ptr = SSPOPPTR;
728 *(SV**)ptr = (SV*)SSPOPPTR;
729 break;
146174a9 730 case SAVEt_VPTR: /* random* reference */
85e6fe83
LW
731 case SAVEt_PPTR: /* char* reference */
732 ptr = SSPOPPTR;
733 *(char**)ptr = (char*)SSPOPPTR;
734 break;
79072805
LW
735 case SAVEt_HPTR: /* HV* reference */
736 ptr = SSPOPPTR;
737 *(HV**)ptr = (HV*)SSPOPPTR;
738 break;
739 case SAVEt_APTR: /* AV* reference */
740 ptr = SSPOPPTR;
741 *(AV**)ptr = (AV*)SSPOPPTR;
742 break;
fb73857a 743 case SAVEt_GP: /* scalar reference */
79072805
LW
744 ptr = SSPOPPTR;
745 gv = (GV*)SSPOPPTR;
8aacddc1
NIS
746 gp_free(gv);
747 GvGP(gv) = (GP*)ptr;
fae75791 748 if (GvCVu(gv))
3280af22 749 PL_sub_generation++; /* putting a method back into circulation */
4633a7c4 750 SvREFCNT_dec(gv);
8aacddc1 751 break;
8990e307
LW
752 case SAVEt_FREESV:
753 ptr = SSPOPPTR;
754 SvREFCNT_dec((SV*)ptr);
755 break;
26d9b02f
JH
756 case SAVEt_MORTALIZESV:
757 ptr = SSPOPPTR;
758 sv_2mortal((SV*)ptr);
759 break;
8990e307
LW
760 case SAVEt_FREEOP:
761 ptr = SSPOPPTR;
f3548bdc 762 ASSERT_CURPAD_LEGAL("SAVEt_FREEOP"); /* XXX DAPM tmp */
8990e307
LW
763 op_free((OP*)ptr);
764 break;
765 case SAVEt_FREEPV:
766 ptr = SSPOPPTR;
1df70142 767 Safefree(ptr);
8990e307
LW
768 break;
769 case SAVEt_CLEARSV:
3280af22 770 ptr = (void*)&PL_curpad[SSPOPLONG];
8990e307 771 sv = *(SV**)ptr;
dd2155a4
DM
772
773 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
f3548bdc
DM
774 "Pad 0x%"UVxf"[0x%"UVxf"] clearsv: %ld sv=0x%"UVxf"<%"IVdf"> %s\n",
775 PTR2UV(PL_comppad), PTR2UV(PL_curpad),
776 (long)((SV **)ptr-PL_curpad), PTR2UV(sv), (IV)SvREFCNT(sv),
dd2155a4
DM
777 (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) ? "clear" : "abandon"
778 ));
779
bc44cdaf
GS
780 /* Can clear pad variable in place? */
781 if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) {
8aacddc1
NIS
782 /*
783 * if a my variable that was made readonly is going out of
784 * scope, we want to remove the readonlyness so that it can
785 * go out of scope quietly
8aacddc1 786 */
a26e96df 787 if (SvPADMY(sv) && !SvFAKE(sv))
8aacddc1
NIS
788 SvREADONLY_off(sv);
789
6fc92669 790 if (SvTHINKFIRST(sv))
840a7b70 791 sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF);
a0d0e21e
LW
792 if (SvMAGICAL(sv))
793 mg_free(sv);
8990e307
LW
794
795 switch (SvTYPE(sv)) {
796 case SVt_NULL:
797 break;
798 case SVt_PVAV:
44a8e56a 799 av_clear((AV*)sv);
8990e307
LW
800 break;
801 case SVt_PVHV:
44a8e56a 802 hv_clear((HV*)sv);
8990e307
LW
803 break;
804 case SVt_PVCV:
cea2e8a9 805 Perl_croak(aTHX_ "panic: leave_scope pad code");
8990e307 806 default:
0c34ef67 807 SvOK_off(sv);
8990e307
LW
808 break;
809 }
d9d18af6 810 SvPADSTALE_on(sv); /* mark as no longer live */
8990e307
LW
811 }
812 else { /* Someone has a claim on this, so abandon it. */
35a4481c 813 const U32 padflags = SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP);
8990e307
LW
814 switch (SvTYPE(sv)) { /* Console ourselves with a new value */
815 case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break;
816 case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break;
561b68a9 817 default: *(SV**)ptr = newSV(0); break;
8990e307 818 }
53868620 819 SvREFCNT_dec(sv); /* Cast current value to the winds. */
d9d18af6
DM
820 /* preserve pad nature, but also mark as not live
821 * for any closure capturing */
2740392c 822 SvFLAGS(*(SV**)ptr) |= padflags | SVs_PADSTALE;
8990e307
LW
823 }
824 break;
825 case SAVEt_DELETE:
826 ptr = SSPOPPTR;
827 hv = (HV*)ptr;
828 ptr = SSPOPPTR;
7d654f43 829 (void)hv_delete(hv, (char*)ptr, (I32)SSPOPINT, G_DISCARD);
4e4c362e 830 SvREFCNT_dec(hv);
8aacddc1 831 Safefree(ptr);
8990e307 832 break;
146174a9
CB
833 case SAVEt_DESTRUCTOR_X:
834 ptr = SSPOPPTR;
acfe0abc 835 (*SSPOPDXPTR)(aTHX_ ptr);
a0d0e21e
LW
836 break;
837 case SAVEt_REGCONTEXT:
455ece5e 838 case SAVEt_ALLOC:
161b7d16 839 i = SSPOPINT;
3280af22 840 PL_savestack_ix -= i; /* regexp must have croaked */
a0d0e21e 841 break;
55497cff 842 case SAVEt_STACK_POS: /* Position on Perl stack */
161b7d16 843 i = SSPOPINT;
3280af22 844 PL_stack_sp = PL_stack_base + i;
55497cff 845 break;
161b7d16
SM
846 case SAVEt_AELEM: /* array element */
847 value = (SV*)SSPOPPTR;
848 i = SSPOPINT;
849 av = (AV*)SSPOPPTR;
5dd42e15
DM
850 if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */
851 SvREFCNT_dec(value);
161b7d16 852 ptr = av_fetch(av,i,1);
4e4c362e
GS
853 if (ptr) {
854 sv = *(SV**)ptr;
3280af22 855 if (sv && sv != &PL_sv_undef) {
14befaf4 856 if (SvTIED_mg((SV*)av, PERL_MAGIC_tied))
b37c2d43 857 SvREFCNT_inc_void_NN(sv);
4e4c362e
GS
858 goto restore_sv;
859 }
860 }
861 SvREFCNT_dec(av);
862 SvREFCNT_dec(value);
863 break;
161b7d16
SM
864 case SAVEt_HELEM: /* hash element */
865 value = (SV*)SSPOPPTR;
9002cb76 866 sv = (SV*)SSPOPPTR;
161b7d16
SM
867 hv = (HV*)SSPOPPTR;
868 ptr = hv_fetch_ent(hv, sv, 1, 0);
4e4c362e 869 if (ptr) {
35a4481c 870 const SV * const oval = HeVAL((HE*)ptr);
3280af22 871 if (oval && oval != &PL_sv_undef) {
4e4c362e 872 ptr = &HeVAL((HE*)ptr);
14befaf4 873 if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied))
b37c2d43 874 SvREFCNT_inc_void(*(SV**)ptr);
4e4c362e 875 SvREFCNT_dec(sv);
5dd42e15 876 av = (AV*)hv; /* what to refcnt_dec */
4e4c362e
GS
877 goto restore_sv;
878 }
879 }
880 SvREFCNT_dec(hv);
881 SvREFCNT_dec(sv);
882 SvREFCNT_dec(value);
883 break;
462e5cf6 884 case SAVEt_OP:
533c011a 885 PL_op = (OP*)SSPOPPTR;
462e5cf6 886 break;
25eaa213 887 case SAVEt_HINTS:
045ac317
RGS
888 if ((PL_hints & HINT_LOCALIZE_HH) && GvHV(PL_hintgv)) {
889 SvREFCNT_dec((SV*)GvHV(PL_hintgv));
890 GvHV(PL_hintgv) = NULL;
891 }
3280af22 892 *(I32*)&PL_hints = (I32)SSPOPINT;
b3ca2e83
NC
893 Perl_refcounted_he_free(aTHX_ PL_compiling.cop_hints);
894 PL_compiling.cop_hints = (struct refcounted_he *) SSPOPPTR;
dfa41748
DM
895 if (PL_hints & HINT_LOCALIZE_HH) {
896 SvREFCNT_dec((SV*)GvHV(PL_hintgv));
897 GvHV(PL_hintgv) = (HV*)SSPOPPTR;
5b9c0671
NC
898 assert(GvHV(PL_hintgv));
899 } else if (!GvHV(PL_hintgv)) {
900 /* Need to add a new one manually, else gv_fetchpv() can
901 add one in this code:
902
903 if (SvTYPE(gv) == SVt_PVGV) {
904 if (add) {
905 GvMULTI_on(gv);
906 gv_init_sv(gv, sv_type);
907 if (*name=='!' && sv_type == SVt_PVHV && len==1)
908 require_errno(gv);
909 }
910 return gv;
911 }
912
913 and it won't have the magic set. */
914
915 HV *const hv = newHV();
916 hv_magic(hv, NULL, PERL_MAGIC_hints);
917 GvHV(PL_hintgv) = hv;
dfa41748 918 }
5b9c0671 919 assert(GvHV(PL_hintgv));
b3ac6de7 920 break;
cb50131a 921 case SAVEt_COMPPAD:
f3548bdc 922 PL_comppad = (PAD*)SSPOPPTR;
58ed4fbe 923 if (PL_comppad)
cb50131a
CB
924 PL_curpad = AvARRAY(PL_comppad);
925 else
4608196e 926 PL_curpad = NULL;
cb50131a 927 break;
c3564e5c
GS
928 case SAVEt_PADSV:
929 {
35a4481c 930 const PADOFFSET off = (PADOFFSET)SSPOPLONG;
c3564e5c
GS
931 ptr = SSPOPPTR;
932 if (ptr)
f3548bdc 933 AvARRAY((PAD*)ptr)[off] = (SV*)SSPOPPTR;
c3564e5c
GS
934 }
935 break;
8b7059b1
DM
936 case SAVEt_SAVESWITCHSTACK:
937 {
938 dSP;
7452cf6a
AL
939 AV* const t = (AV*)SSPOPPTR;
940 AV* const f = (AV*)SSPOPPTR;
8b7059b1
DM
941 SWITCHSTACK(t,f);
942 PL_curstackinfo->si_stack = f;
943 }
944 break;
14f338dc
DM
945 case SAVEt_SET_SVFLAGS:
946 {
35a4481c
AL
947 const U32 val = (U32)SSPOPINT;
948 const U32 mask = (U32)SSPOPINT;
14f338dc
DM
949 sv = (SV*)SSPOPPTR;
950 SvFLAGS(sv) &= ~mask;
951 SvFLAGS(sv) |= val;
952 }
953 break;
2053acbf
NC
954 /* These are only saved in mathoms.c */
955 case SAVEt_SVREF: /* scalar reference */
956 value = (SV*)SSPOPPTR;
957 ptr = SSPOPPTR;
958 av = NULL; /* what to refcnt_dec */
959 goto restore_sv;
960 case SAVEt_LONG: /* long reference */
961 ptr = SSPOPPTR;
962 *(long*)ptr = (long)SSPOPLONG;
963 break;
964 case SAVEt_I16: /* I16 reference */
965 ptr = SSPOPPTR;
966 *(I16*)ptr = (I16)SSPOPINT;
967 break;
968 case SAVEt_I8: /* I8 reference */
969 ptr = SSPOPPTR;
970 *(I8*)ptr = (I8)SSPOPINT;
971 break;
972 case SAVEt_IV: /* IV reference */
973 ptr = SSPOPPTR;
974 *(IV*)ptr = (IV)SSPOPIV;
975 break;
976 case SAVEt_NSTAB:
977 gv = (GV*)SSPOPPTR;
978 (void)sv_clear((SV*)gv);
979 break;
980 case SAVEt_DESTRUCTOR:
981 ptr = SSPOPPTR;
982 (*SSPOPDPTR)(ptr);
983 break;
79072805 984 default:
cea2e8a9 985 Perl_croak(aTHX_ "panic: leave_scope inconsistency");
79072805
LW
986 }
987 }
988}
8990e307 989
8990e307 990void
864dbfa3 991Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
8990e307 992{
97aff369 993 dVAR;
35ff7856 994#ifdef DEBUGGING
22c35a8c 995 PerlIO_printf(Perl_debug_log, "CX %ld = %s\n", (long)(cx - cxstack), PL_block_type[CxTYPE(cx)]);
6b35e009 996 if (CxTYPE(cx) != CXt_SUBST) {
760ac839 997 PerlIO_printf(Perl_debug_log, "BLK_OLDSP = %ld\n", (long)cx->blk_oldsp);
146174a9
CB
998 PerlIO_printf(Perl_debug_log, "BLK_OLDCOP = 0x%"UVxf"\n",
999 PTR2UV(cx->blk_oldcop));
760ac839
LW
1000 PerlIO_printf(Perl_debug_log, "BLK_OLDMARKSP = %ld\n", (long)cx->blk_oldmarksp);
1001 PerlIO_printf(Perl_debug_log, "BLK_OLDSCOPESP = %ld\n", (long)cx->blk_oldscopesp);
146174a9
CB
1002 PerlIO_printf(Perl_debug_log, "BLK_OLDPM = 0x%"UVxf"\n",
1003 PTR2UV(cx->blk_oldpm));
760ac839 1004 PerlIO_printf(Perl_debug_log, "BLK_GIMME = %s\n", cx->blk_gimme ? "LIST" : "SCALAR");
8990e307 1005 }
6b35e009 1006 switch (CxTYPE(cx)) {
8990e307
LW
1007 case CXt_NULL:
1008 case CXt_BLOCK:
1009 break;
146174a9
CB
1010 case CXt_FORMAT:
1011 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1012 PTR2UV(cx->blk_sub.cv));
1013 PerlIO_printf(Perl_debug_log, "BLK_SUB.GV = 0x%"UVxf"\n",
1014 PTR2UV(cx->blk_sub.gv));
1015 PerlIO_printf(Perl_debug_log, "BLK_SUB.DFOUTGV = 0x%"UVxf"\n",
1016 PTR2UV(cx->blk_sub.dfoutgv));
1017 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
1018 (int)cx->blk_sub.hasargs);
f39bc417
DM
1019 PerlIO_printf(Perl_debug_log, "BLK_SUB.RETOP = 0x%"UVxf"\n",
1020 PTR2UV(cx->blk_sub.retop));
146174a9 1021 break;
8990e307 1022 case CXt_SUB:
146174a9
CB
1023 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1024 PTR2UV(cx->blk_sub.cv));
760ac839 1025 PerlIO_printf(Perl_debug_log, "BLK_SUB.OLDDEPTH = %ld\n",
8990e307 1026 (long)cx->blk_sub.olddepth);
760ac839 1027 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
8990e307 1028 (int)cx->blk_sub.hasargs);
146174a9
CB
1029 PerlIO_printf(Perl_debug_log, "BLK_SUB.LVAL = %d\n",
1030 (int)cx->blk_sub.lval);
f39bc417
DM
1031 PerlIO_printf(Perl_debug_log, "BLK_SUB.RETOP = 0x%"UVxf"\n",
1032 PTR2UV(cx->blk_sub.retop));
8990e307
LW
1033 break;
1034 case CXt_EVAL:
760ac839 1035 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_IN_EVAL = %ld\n",
8990e307 1036 (long)cx->blk_eval.old_in_eval);
760ac839 1037 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_OP_TYPE = %s (%s)\n",
22c35a8c
GS
1038 PL_op_name[cx->blk_eval.old_op_type],
1039 PL_op_desc[cx->blk_eval.old_op_type]);
0f79a09d
GS
1040 if (cx->blk_eval.old_namesv)
1041 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
aa07b2f6 1042 SvPVX_const(cx->blk_eval.old_namesv));
146174a9
CB
1043 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%"UVxf"\n",
1044 PTR2UV(cx->blk_eval.old_eval_root));
f39bc417
DM
1045 PerlIO_printf(Perl_debug_log, "BLK_EVAL.RETOP = 0x%"UVxf"\n",
1046 PTR2UV(cx->blk_eval.retop));
8990e307
LW
1047 break;
1048
1049 case CXt_LOOP:
760ac839 1050 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LABEL = %s\n",
8990e307 1051 cx->blk_loop.label);
760ac839 1052 PerlIO_printf(Perl_debug_log, "BLK_LOOP.RESETSP = %ld\n",
8990e307 1053 (long)cx->blk_loop.resetsp);
146174a9
CB
1054 PerlIO_printf(Perl_debug_log, "BLK_LOOP.REDO_OP = 0x%"UVxf"\n",
1055 PTR2UV(cx->blk_loop.redo_op));
1056 PerlIO_printf(Perl_debug_log, "BLK_LOOP.NEXT_OP = 0x%"UVxf"\n",
1057 PTR2UV(cx->blk_loop.next_op));
1058 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LAST_OP = 0x%"UVxf"\n",
1059 PTR2UV(cx->blk_loop.last_op));
760ac839 1060 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
8990e307 1061 (long)cx->blk_loop.iterix);
146174a9
CB
1062 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
1063 PTR2UV(cx->blk_loop.iterary));
1064 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
1065 PTR2UV(CxITERVAR(cx)));
1066 if (CxITERVAR(cx))
1067 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%"UVxf"\n",
1068 PTR2UV(cx->blk_loop.itersave));
1069 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERLVAL = 0x%"UVxf"\n",
1070 PTR2UV(cx->blk_loop.iterlval));
8990e307
LW
1071 break;
1072
1073 case CXt_SUBST:
760ac839 1074 PerlIO_printf(Perl_debug_log, "SB_ITERS = %ld\n",
8990e307 1075 (long)cx->sb_iters);
760ac839 1076 PerlIO_printf(Perl_debug_log, "SB_MAXITERS = %ld\n",
8990e307 1077 (long)cx->sb_maxiters);
35ef4773
GS
1078 PerlIO_printf(Perl_debug_log, "SB_RFLAGS = %ld\n",
1079 (long)cx->sb_rflags);
760ac839 1080 PerlIO_printf(Perl_debug_log, "SB_ONCE = %ld\n",
8990e307 1081 (long)cx->sb_once);
760ac839 1082 PerlIO_printf(Perl_debug_log, "SB_ORIG = %s\n",
8990e307 1083 cx->sb_orig);
146174a9
CB
1084 PerlIO_printf(Perl_debug_log, "SB_DSTR = 0x%"UVxf"\n",
1085 PTR2UV(cx->sb_dstr));
1086 PerlIO_printf(Perl_debug_log, "SB_TARG = 0x%"UVxf"\n",
1087 PTR2UV(cx->sb_targ));
1088 PerlIO_printf(Perl_debug_log, "SB_S = 0x%"UVxf"\n",
1089 PTR2UV(cx->sb_s));
1090 PerlIO_printf(Perl_debug_log, "SB_M = 0x%"UVxf"\n",
1091 PTR2UV(cx->sb_m));
1092 PerlIO_printf(Perl_debug_log, "SB_STREND = 0x%"UVxf"\n",
1093 PTR2UV(cx->sb_strend));
1094 PerlIO_printf(Perl_debug_log, "SB_RXRES = 0x%"UVxf"\n",
1095 PTR2UV(cx->sb_rxres));
8990e307
LW
1096 break;
1097 }
65e66c80 1098#else
96a5add6 1099 PERL_UNUSED_CONTEXT;
65e66c80 1100 PERL_UNUSED_ARG(cx);
17c3b450 1101#endif /* DEBUGGING */
35ff7856 1102}
241d1a3b
NC
1103
1104/*
1105 * Local variables:
1106 * c-indentation-style: bsd
1107 * c-basic-offset: 4
1108 * indent-tabs-mode: t
1109 * End:
1110 *
37442d52
RGS
1111 * ex: set ts=8 sts=4 sw=4 noet:
1112 */