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