Upgrade to podlators 1.27.
[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);
a0d0e21e 217 SvFLAGS(sv) |= SvMAGICAL(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
79072805 284void
864dbfa3 285Perl_save_gp(pTHX_ GV *gv, I32 empty)
79072805 286{
4b3c1a47 287 SSGROW(6);
fb73857a 288 SSPUSHIV((IV)SvLEN(gv));
289 SvLEN(gv) = 0; /* forget that anything was allocated here */
290 SSPUSHIV((IV)SvCUR(gv));
291 SSPUSHPTR(SvPVX(gv));
292 SvPOK_off(gv);
4633a7c4 293 SSPUSHPTR(SvREFCNT_inc(gv));
5f05dabc 294 SSPUSHPTR(GvGP(gv));
79072805 295 SSPUSHINT(SAVEt_GP);
296
5f05dabc 297 if (empty) {
298 register GP *gp;
fae75791 299
146174a9 300 Newz(602, gp, 1, GP);
301
fae75791 302 if (GvCVu(gv))
3280af22 303 PL_sub_generation++; /* taking a method out of circulation */
146174a9 304 if (GvIOp(gv) && (IoFLAGS(GvIOp(gv)) & IOf_ARGV)) {
305 gp->gp_io = newIO();
306 IoFLAGS(gp->gp_io) |= IOf_ARGV|IOf_START;
307 }
44a8e56a 308 GvGP(gv) = gp_ref(gp);
5f05dabc 309 GvSV(gv) = NEWSV(72,0);
146174a9 310 GvLINE(gv) = CopLINE(PL_curcop);
94051fc1 311 GvFILE(gv) = CopFILE(PL_curcop) ? CopFILE(PL_curcop) : "";
5f05dabc 312 GvEGV(gv) = gv;
313 }
314 else {
44a8e56a 315 gp_ref(GvGP(gv));
5f05dabc 316 GvINTRO_on(gv);
317 }
79072805 318}
79072805 319
79072805 320AV *
864dbfa3 321Perl_save_ary(pTHX_ GV *gv)
79072805 322{
67a38de0 323 AV *oav = GvAVn(gv);
324 AV *av;
fb73857a 325
67a38de0 326 if (!AvREAL(oav) && AvREIFY(oav))
327 av_reify(oav);
79072805 328 SSCHECK(3);
329 SSPUSHPTR(gv);
67a38de0 330 SSPUSHPTR(oav);
79072805 331 SSPUSHINT(SAVEt_AV);
332
333 GvAV(gv) = Null(AV*);
fb73857a 334 av = GvAVn(gv);
335 if (SvMAGIC(oav)) {
336 SvMAGIC(av) = SvMAGIC(oav);
32da55ab 337 SvFLAGS((SV*)av) |= SvMAGICAL(oav);
fb73857a 338 SvMAGICAL_off(oav);
339 SvMAGIC(oav) = 0;
3280af22 340 PL_localizing = 1;
fb73857a 341 SvSETMAGIC((SV*)av);
3280af22 342 PL_localizing = 0;
fb73857a 343 }
344 return av;
79072805 345}
346
347HV *
864dbfa3 348Perl_save_hash(pTHX_ GV *gv)
79072805 349{
fb73857a 350 HV *ohv, *hv;
351
79072805 352 SSCHECK(3);
353 SSPUSHPTR(gv);
fb73857a 354 SSPUSHPTR(ohv = GvHVn(gv));
79072805 355 SSPUSHINT(SAVEt_HV);
356
357 GvHV(gv) = Null(HV*);
fb73857a 358 hv = GvHVn(gv);
359 if (SvMAGIC(ohv)) {
360 SvMAGIC(hv) = SvMAGIC(ohv);
32da55ab 361 SvFLAGS((SV*)hv) |= SvMAGICAL(ohv);
fb73857a 362 SvMAGICAL_off(ohv);
363 SvMAGIC(ohv) = 0;
3280af22 364 PL_localizing = 1;
fb73857a 365 SvSETMAGIC((SV*)hv);
3280af22 366 PL_localizing = 0;
fb73857a 367 }
368 return hv;
79072805 369}
370
371void
864dbfa3 372Perl_save_item(pTHX_ register SV *item)
79072805 373{
f46d017c 374 register SV *sv = NEWSV(0,0);
79072805 375
f46d017c 376 sv_setsv(sv,item);
79072805 377 SSCHECK(3);
378 SSPUSHPTR(item); /* remember the pointer */
79072805 379 SSPUSHPTR(sv); /* remember the value */
380 SSPUSHINT(SAVEt_ITEM);
381}
382
383void
864dbfa3 384Perl_save_int(pTHX_ int *intp)
79072805 385{
386 SSCHECK(3);
387 SSPUSHINT(*intp);
388 SSPUSHPTR(intp);
389 SSPUSHINT(SAVEt_INT);
390}
391
392void
864dbfa3 393Perl_save_long(pTHX_ long int *longp)
85e6fe83 394{
395 SSCHECK(3);
396 SSPUSHLONG(*longp);
397 SSPUSHPTR(longp);
398 SSPUSHINT(SAVEt_LONG);
399}
400
401void
9febdf04 402Perl_save_bool(pTHX_ bool *boolp)
403{
404 SSCHECK(3);
405 SSPUSHBOOL(*boolp);
406 SSPUSHPTR(boolp);
407 SSPUSHINT(SAVEt_BOOL);
408}
409
410void
864dbfa3 411Perl_save_I32(pTHX_ I32 *intp)
79072805 412{
413 SSCHECK(3);
414 SSPUSHINT(*intp);
415 SSPUSHPTR(intp);
416 SSPUSHINT(SAVEt_I32);
417}
418
a0d0e21e 419void
864dbfa3 420Perl_save_I16(pTHX_ I16 *intp)
55497cff 421{
422 SSCHECK(3);
423 SSPUSHINT(*intp);
424 SSPUSHPTR(intp);
425 SSPUSHINT(SAVEt_I16);
426}
427
428void
146174a9 429Perl_save_I8(pTHX_ I8 *bytep)
430{
146174a9 431 SSCHECK(3);
432 SSPUSHINT(*bytep);
433 SSPUSHPTR(bytep);
434 SSPUSHINT(SAVEt_I8);
435}
436
437void
864dbfa3 438Perl_save_iv(pTHX_ IV *ivp)
a0d0e21e 439{
440 SSCHECK(3);
4aa0a1f7 441 SSPUSHIV(*ivp);
a0d0e21e 442 SSPUSHPTR(ivp);
443 SSPUSHINT(SAVEt_IV);
444}
445
85e6fe83 446/* Cannot use save_sptr() to store a char* since the SV** cast will
447 * force word-alignment and we'll miss the pointer.
448 */
449void
864dbfa3 450Perl_save_pptr(pTHX_ char **pptr)
85e6fe83 451{
452 SSCHECK(3);
453 SSPUSHPTR(*pptr);
454 SSPUSHPTR(pptr);
455 SSPUSHINT(SAVEt_PPTR);
456}
457
79072805 458void
146174a9 459Perl_save_vptr(pTHX_ void *ptr)
460{
146174a9 461 SSCHECK(3);
462 SSPUSHPTR(*(char**)ptr);
463 SSPUSHPTR(ptr);
464 SSPUSHINT(SAVEt_VPTR);
465}
466
467void
864dbfa3 468Perl_save_sptr(pTHX_ SV **sptr)
79072805 469{
470 SSCHECK(3);
471 SSPUSHPTR(*sptr);
472 SSPUSHPTR(sptr);
473 SSPUSHINT(SAVEt_SPTR);
474}
475
c3564e5c 476void
477Perl_save_padsv(pTHX_ PADOFFSET off)
478{
c3564e5c 479 SSCHECK(4);
f3548bdc 480 ASSERT_CURPAD_ACTIVE("save_padsv");
c3564e5c 481 SSPUSHPTR(PL_curpad[off]);
f3548bdc 482 SSPUSHPTR(PL_comppad);
c3564e5c 483 SSPUSHLONG((long)off);
484 SSPUSHINT(SAVEt_PADSV);
485}
486
54b9620d 487SV **
864dbfa3 488Perl_save_threadsv(pTHX_ PADOFFSET i)
54b9620d 489{
cea2e8a9 490 Perl_croak(aTHX_ "panic: save_threadsv called in non-threaded perl");
54b9620d 491 return 0;
54b9620d 492}
493
79072805 494void
864dbfa3 495Perl_save_nogv(pTHX_ GV *gv)
79072805 496{
497 SSCHECK(2);
498 SSPUSHPTR(gv);
499 SSPUSHINT(SAVEt_NSTAB);
500}
501
502void
864dbfa3 503Perl_save_hptr(pTHX_ HV **hptr)
79072805 504{
505 SSCHECK(3);
85e6fe83 506 SSPUSHPTR(*hptr);
79072805 507 SSPUSHPTR(hptr);
508 SSPUSHINT(SAVEt_HPTR);
509}
510
511void
864dbfa3 512Perl_save_aptr(pTHX_ AV **aptr)
79072805 513{
514 SSCHECK(3);
85e6fe83 515 SSPUSHPTR(*aptr);
79072805 516 SSPUSHPTR(aptr);
517 SSPUSHINT(SAVEt_APTR);
518}
519
520void
864dbfa3 521Perl_save_freesv(pTHX_ SV *sv)
8990e307 522{
523 SSCHECK(2);
524 SSPUSHPTR(sv);
525 SSPUSHINT(SAVEt_FREESV);
526}
527
528void
26d9b02f 529Perl_save_mortalizesv(pTHX_ SV *sv)
530{
531 SSCHECK(2);
532 SSPUSHPTR(sv);
533 SSPUSHINT(SAVEt_MORTALIZESV);
534}
535
536void
864dbfa3 537Perl_save_freeop(pTHX_ OP *o)
8990e307 538{
539 SSCHECK(2);
11343788 540 SSPUSHPTR(o);
8990e307 541 SSPUSHINT(SAVEt_FREEOP);
542}
543
544void
864dbfa3 545Perl_save_freepv(pTHX_ char *pv)
8990e307 546{
547 SSCHECK(2);
548 SSPUSHPTR(pv);
549 SSPUSHINT(SAVEt_FREEPV);
550}
551
552void
864dbfa3 553Perl_save_clearsv(pTHX_ SV **svp)
8990e307 554{
f3548bdc 555 ASSERT_CURPAD_ACTIVE("save_clearsv");
8990e307 556 SSCHECK(2);
3280af22 557 SSPUSHLONG((long)(svp-PL_curpad));
8990e307 558 SSPUSHINT(SAVEt_CLEARSV);
d9d18af6 559 SvPADSTALE_off(*svp); /* mark lexical as active */
8990e307 560}
561
562void
864dbfa3 563Perl_save_delete(pTHX_ HV *hv, char *key, I32 klen)
8990e307 564{
565 SSCHECK(4);
566 SSPUSHINT(klen);
567 SSPUSHPTR(key);
4e4c362e 568 SSPUSHPTR(SvREFCNT_inc(hv));
8990e307 569 SSPUSHINT(SAVEt_DELETE);
570}
571
572void
864dbfa3 573Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
79072805 574{
575 register SV *sv;
576 register I32 i;
577
79072805 578 for (i = 1; i <= maxsarg; i++) {
79072805 579 sv = NEWSV(0,0);
580 sv_setsv(sv,sarg[i]);
f46d017c 581 SSCHECK(3);
582 SSPUSHPTR(sarg[i]); /* remember the pointer */
79072805 583 SSPUSHPTR(sv); /* remember the value */
584 SSPUSHINT(SAVEt_ITEM);
585 }
586}
587
588void
146174a9 589Perl_save_destructor(pTHX_ DESTRUCTORFUNC_NOCONTEXT_t f, void* p)
a0d0e21e 590{
591 SSCHECK(3);
592 SSPUSHDPTR(f);
593 SSPUSHPTR(p);
594 SSPUSHINT(SAVEt_DESTRUCTOR);
595}
596
597void
146174a9 598Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p)
599{
146174a9 600 SSCHECK(3);
601 SSPUSHDXPTR(f);
602 SSPUSHPTR(p);
603 SSPUSHINT(SAVEt_DESTRUCTOR_X);
604}
605
606void
864dbfa3 607Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
4e4c362e 608{
bfc4de9f 609 SV *sv;
4e4c362e 610 SSCHECK(4);
611 SSPUSHPTR(SvREFCNT_inc(av));
612 SSPUSHINT(idx);
613 SSPUSHPTR(SvREFCNT_inc(*sptr));
614 SSPUSHINT(SAVEt_AELEM);
51d9a56b 615 /* if it gets reified later, the restore will have the wrong refcnt */
616 if (!AvREAL(av) && AvREIFY(av))
617 SvREFCNT_inc(*sptr);
4e4c362e 618 save_scalar_at(sptr);
bfc4de9f 619 sv = *sptr;
620 /* If we're localizing a tied array element, this new sv
621 * won't actually be stored in the array - so it won't get
622 * reaped when the localize ends. Ensure it gets reaped by
623 * mortifying it instead. DAPM */
624 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
625 sv_2mortal(sv);
4e4c362e 626}
627
628void
864dbfa3 629Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr)
4e4c362e 630{
bfc4de9f 631 SV *sv;
4e4c362e 632 SSCHECK(4);
633 SSPUSHPTR(SvREFCNT_inc(hv));
634 SSPUSHPTR(SvREFCNT_inc(key));
635 SSPUSHPTR(SvREFCNT_inc(*sptr));
636 SSPUSHINT(SAVEt_HELEM);
637 save_scalar_at(sptr);
bfc4de9f 638 sv = *sptr;
639 /* If we're localizing a tied hash element, this new sv
640 * won't actually be stored in the hash - so it won't get
641 * reaped when the localize ends. Ensure it gets reaped by
642 * mortifying it instead. DAPM */
643 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
644 sv_2mortal(sv);
4e4c362e 645}
646
647void
864dbfa3 648Perl_save_op(pTHX)
462e5cf6 649{
462e5cf6 650 SSCHECK(2);
533c011a 651 SSPUSHPTR(PL_op);
462e5cf6 652 SSPUSHINT(SAVEt_OP);
653}
654
455ece5e 655I32
864dbfa3 656Perl_save_alloc(pTHX_ I32 size, I32 pad)
455ece5e 657{
455ece5e 658 register I32 start = pad + ((char*)&PL_savestack[PL_savestack_ix]
8aacddc1 659 - (char*)PL_savestack);
455ece5e 660 register I32 elems = 1 + ((size + pad - 1) / sizeof(*PL_savestack));
661
662 /* SSCHECK may not be good enough */
663 while (PL_savestack_ix + elems + 2 > PL_savestack_max)
8aacddc1 664 savestack_grow();
455ece5e 665
666 PL_savestack_ix += elems;
667 SSPUSHINT(elems);
668 SSPUSHINT(SAVEt_ALLOC);
669 return start;
670}
671
462e5cf6 672void
864dbfa3 673Perl_leave_scope(pTHX_ I32 base)
79072805 674{
675 register SV *sv;
676 register SV *value;
677 register GV *gv;
678 register AV *av;
679 register HV *hv;
680 register void* ptr;
f4dd75d9 681 register char* str;
161b7d16 682 I32 i;
79072805 683
684 if (base < -1)
cea2e8a9 685 Perl_croak(aTHX_ "panic: corrupt saved stack index");
3280af22 686 while (PL_savestack_ix > base) {
79072805 687 switch (SSPOPINT) {
688 case SAVEt_ITEM: /* normal string */
689 value = (SV*)SSPOPPTR;
690 sv = (SV*)SSPOPPTR;
691 sv_replace(sv,value);
3280af22 692 PL_localizing = 2;
79072805 693 SvSETMAGIC(sv);
3280af22 694 PL_localizing = 0;
79072805 695 break;
8aacddc1 696 case SAVEt_SV: /* scalar reference */
79072805 697 value = (SV*)SSPOPPTR;
698 gv = (GV*)SSPOPPTR;
7a4c00b4 699 ptr = &GvSV(gv);
51d9a56b 700 av = (AV*)gv; /* what to refcnt_dec */
7a4c00b4 701 goto restore_sv;
8aacddc1 702 case SAVEt_GENERIC_PVREF: /* generic pv */
f4dd75d9 703 str = (char*)SSPOPPTR;
704 ptr = SSPOPPTR;
705 if (*(char**)ptr != str) {
706 Safefree(*(char**)ptr);
707 *(char**)ptr = str;
708 }
709 break;
05ec9bb3 710 case SAVEt_SHARED_PVREF: /* shared pv */
711 str = (char*)SSPOPPTR;
712 ptr = SSPOPPTR;
713 if (*(char**)ptr != str) {
5e54c26f 714#ifdef NETWARE
9ecbcc42 715 PerlMem_free(*(char**)ptr);
5e54c26f 716#else
05ec9bb3 717 PerlMemShared_free(*(char**)ptr);
5e54c26f 718#endif
05ec9bb3 719 *(char**)ptr = str;
720 }
721 break;
8aacddc1 722 case SAVEt_GENERIC_SVREF: /* generic sv */
b9d12d37 723 value = (SV*)SSPOPPTR;
724 ptr = SSPOPPTR;
f4dd75d9 725 sv = *(SV**)ptr;
726 *(SV**)ptr = value;
727 SvREFCNT_dec(sv);
b9d12d37 728 SvREFCNT_dec(value);
729 break;
8aacddc1 730 case SAVEt_SVREF: /* scalar reference */
7a4c00b4 731 value = (SV*)SSPOPPTR;
79072805 732 ptr = SSPOPPTR;
51d9a56b 733 av = Nullav; /* what to refcnt_dec */
7a4c00b4 734 restore_sv:
79072805 735 sv = *(SV**)ptr;
146174a9 736 DEBUG_S(PerlIO_printf(Perl_debug_log,
54b9620d 737 "restore svref: %p %p:%s -> %p:%s\n",
8aacddc1 738 ptr, sv, SvPEEK(sv), value, SvPEEK(value)));
cdec4f49 739 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv) &&
740 SvTYPE(sv) != SVt_PVGV)
741 {
a0d0e21e 742 (void)SvUPGRADE(value, SvTYPE(sv));
743 SvMAGIC(value) = SvMAGIC(sv);
744 SvFLAGS(value) |= SvMAGICAL(sv);
745 SvMAGICAL_off(sv);
79072805 746 SvMAGIC(sv) = 0;
a0d0e21e 747 }
2d5e9e5d 748 /* XXX This branch is pretty bogus. This code irretrievably
749 * clears(!) the magic on the SV (either to avoid further
750 * croaking that might ensue when the SvSETMAGIC() below is
751 * called, or to avoid two different SVs pointing at the same
752 * SvMAGIC()). This needs a total rethink. --GSAR */
cdec4f49 753 else if (SvTYPE(value) >= SVt_PVMG && SvMAGIC(value) &&
754 SvTYPE(value) != SVt_PVGV)
755 {
7a4c00b4 756 SvFLAGS(value) |= (SvFLAGS(value) &
8aacddc1 757 (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
7a4c00b4 758 SvMAGICAL_off(value);
2d5e9e5d 759 /* XXX this is a leak when we get here because the
760 * mg_get() in save_scalar_at() croaked */
761 SvMAGIC(value) = 0;
7a4c00b4 762 }
8aacddc1 763 SvREFCNT_dec(sv);
a0d0e21e 764 *(SV**)ptr = value;
3280af22 765 PL_localizing = 2;
a0d0e21e 766 SvSETMAGIC(value);
3280af22 767 PL_localizing = 0;
4e4c362e 768 SvREFCNT_dec(value);
51d9a56b 769 if (av) /* actually an av, hv or gv */
770 SvREFCNT_dec(av);
8aacddc1 771 break;
772 case SAVEt_AV: /* array reference */
79072805 773 av = (AV*)SSPOPPTR;
774 gv = (GV*)SSPOPPTR;
fb73857a 775 if (GvAV(gv)) {
776 AV *goner = GvAV(gv);
777 SvMAGIC(av) = SvMAGIC(goner);
32da55ab 778 SvFLAGS((SV*)av) |= SvMAGICAL(goner);
fb73857a 779 SvMAGICAL_off(goner);
780 SvMAGIC(goner) = 0;
781 SvREFCNT_dec(goner);
782 }
8aacddc1 783 GvAV(gv) = av;
fb73857a 784 if (SvMAGICAL(av)) {
3280af22 785 PL_localizing = 2;
fb73857a 786 SvSETMAGIC((SV*)av);
3280af22 787 PL_localizing = 0;
fb73857a 788 }
8aacddc1 789 break;
790 case SAVEt_HV: /* hash reference */
79072805 791 hv = (HV*)SSPOPPTR;
792 gv = (GV*)SSPOPPTR;
fb73857a 793 if (GvHV(gv)) {
794 HV *goner = GvHV(gv);
795 SvMAGIC(hv) = SvMAGIC(goner);
796 SvFLAGS(hv) |= SvMAGICAL(goner);
797 SvMAGICAL_off(goner);
798 SvMAGIC(goner) = 0;
799 SvREFCNT_dec(goner);
800 }
8aacddc1 801 GvHV(gv) = hv;
fb73857a 802 if (SvMAGICAL(hv)) {
3280af22 803 PL_localizing = 2;
fb73857a 804 SvSETMAGIC((SV*)hv);
3280af22 805 PL_localizing = 0;
fb73857a 806 }
8aacddc1 807 break;
79072805 808 case SAVEt_INT: /* int reference */
809 ptr = SSPOPPTR;
810 *(int*)ptr = (int)SSPOPINT;
811 break;
85e6fe83 812 case SAVEt_LONG: /* long reference */
813 ptr = SSPOPPTR;
814 *(long*)ptr = (long)SSPOPLONG;
815 break;
9febdf04 816 case SAVEt_BOOL: /* bool reference */
817 ptr = SSPOPPTR;
818 *(bool*)ptr = (bool)SSPOPBOOL;
819 break;
79072805 820 case SAVEt_I32: /* I32 reference */
821 ptr = SSPOPPTR;
822 *(I32*)ptr = (I32)SSPOPINT;
823 break;
55497cff 824 case SAVEt_I16: /* I16 reference */
825 ptr = SSPOPPTR;
826 *(I16*)ptr = (I16)SSPOPINT;
827 break;
146174a9 828 case SAVEt_I8: /* I8 reference */
829 ptr = SSPOPPTR;
830 *(I8*)ptr = (I8)SSPOPINT;
831 break;
a0d0e21e 832 case SAVEt_IV: /* IV reference */
833 ptr = SSPOPPTR;
834 *(IV*)ptr = (IV)SSPOPIV;
835 break;
79072805 836 case SAVEt_SPTR: /* SV* reference */
837 ptr = SSPOPPTR;
838 *(SV**)ptr = (SV*)SSPOPPTR;
839 break;
146174a9 840 case SAVEt_VPTR: /* random* reference */
85e6fe83 841 case SAVEt_PPTR: /* char* reference */
842 ptr = SSPOPPTR;
843 *(char**)ptr = (char*)SSPOPPTR;
844 break;
79072805 845 case SAVEt_HPTR: /* HV* reference */
846 ptr = SSPOPPTR;
847 *(HV**)ptr = (HV*)SSPOPPTR;
848 break;
849 case SAVEt_APTR: /* AV* reference */
850 ptr = SSPOPPTR;
851 *(AV**)ptr = (AV*)SSPOPPTR;
852 break;
853 case SAVEt_NSTAB:
854 gv = (GV*)SSPOPPTR;
1f96a9ed 855 (void)sv_clear((SV*)gv);
79072805 856 break;
fb73857a 857 case SAVEt_GP: /* scalar reference */
79072805 858 ptr = SSPOPPTR;
859 gv = (GV*)SSPOPPTR;
8aacddc1 860 if (SvPVX(gv) && SvLEN(gv) > 0) {
861 Safefree(SvPVX(gv));
862 }
863 SvPVX(gv) = (char *)SSPOPPTR;
864 SvCUR(gv) = (STRLEN)SSPOPIV;
865 SvLEN(gv) = (STRLEN)SSPOPIV;
866 gp_free(gv);
867 GvGP(gv) = (GP*)ptr;
fae75791 868 if (GvCVu(gv))
3280af22 869 PL_sub_generation++; /* putting a method back into circulation */
4633a7c4 870 SvREFCNT_dec(gv);
8aacddc1 871 break;
8990e307 872 case SAVEt_FREESV:
873 ptr = SSPOPPTR;
874 SvREFCNT_dec((SV*)ptr);
875 break;
26d9b02f 876 case SAVEt_MORTALIZESV:
877 ptr = SSPOPPTR;
878 sv_2mortal((SV*)ptr);
879 break;
8990e307 880 case SAVEt_FREEOP:
881 ptr = SSPOPPTR;
f3548bdc 882 ASSERT_CURPAD_LEGAL("SAVEt_FREEOP"); /* XXX DAPM tmp */
8990e307 883 op_free((OP*)ptr);
884 break;
885 case SAVEt_FREEPV:
886 ptr = SSPOPPTR;
887 Safefree((char*)ptr);
888 break;
889 case SAVEt_CLEARSV:
3280af22 890 ptr = (void*)&PL_curpad[SSPOPLONG];
8990e307 891 sv = *(SV**)ptr;
dd2155a4 892
893 DEBUG_Xv(PerlIO_printf(Perl_debug_log,
f3548bdc 894 "Pad 0x%"UVxf"[0x%"UVxf"] clearsv: %ld sv=0x%"UVxf"<%"IVdf"> %s\n",
895 PTR2UV(PL_comppad), PTR2UV(PL_curpad),
896 (long)((SV **)ptr-PL_curpad), PTR2UV(sv), (IV)SvREFCNT(sv),
dd2155a4 897 (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) ? "clear" : "abandon"
898 ));
899
bc44cdaf 900 /* Can clear pad variable in place? */
901 if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) {
8aacddc1 902 /*
903 * if a my variable that was made readonly is going out of
904 * scope, we want to remove the readonlyness so that it can
905 * go out of scope quietly
8aacddc1 906 */
a26e96df 907 if (SvPADMY(sv) && !SvFAKE(sv))
8aacddc1 908 SvREADONLY_off(sv);
909
6fc92669 910 if (SvTHINKFIRST(sv))
840a7b70 911 sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF);
a0d0e21e 912 if (SvMAGICAL(sv))
913 mg_free(sv);
8990e307 914
915 switch (SvTYPE(sv)) {
916 case SVt_NULL:
917 break;
918 case SVt_PVAV:
44a8e56a 919 av_clear((AV*)sv);
8990e307 920 break;
921 case SVt_PVHV:
44a8e56a 922 hv_clear((HV*)sv);
8990e307 923 break;
924 case SVt_PVCV:
cea2e8a9 925 Perl_croak(aTHX_ "panic: leave_scope pad code");
5377b701 926 case SVt_RV:
927 case SVt_IV:
928 case SVt_NV:
929 (void)SvOK_off(sv);
8990e307 930 break;
931 default:
a0d0e21e 932 (void)SvOK_off(sv);
5377b701 933 (void)SvOOK_off(sv);
8990e307 934 break;
935 }
d9d18af6 936 SvPADSTALE_on(sv); /* mark as no longer live */
8990e307 937 }
938 else { /* Someone has a claim on this, so abandon it. */
235cc2e3 939 U32 padflags = SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP);
8990e307 940 switch (SvTYPE(sv)) { /* Console ourselves with a new value */
941 case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break;
942 case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break;
943 default: *(SV**)ptr = NEWSV(0,0); break;
944 }
53868620 945 SvREFCNT_dec(sv); /* Cast current value to the winds. */
d9d18af6 946 /* preserve pad nature, but also mark as not live
947 * for any closure capturing */
948 SvFLAGS(*(SV**)ptr) |= padflags & SVs_PADSTALE;
8990e307 949 }
950 break;
951 case SAVEt_DELETE:
952 ptr = SSPOPPTR;
953 hv = (HV*)ptr;
954 ptr = SSPOPPTR;
748a9306 955 (void)hv_delete(hv, (char*)ptr, (U32)SSPOPINT, G_DISCARD);
4e4c362e 956 SvREFCNT_dec(hv);
8aacddc1 957 Safefree(ptr);
8990e307 958 break;
a0d0e21e 959 case SAVEt_DESTRUCTOR:
960 ptr = SSPOPPTR;
146174a9 961 (*SSPOPDPTR)(ptr);
962 break;
963 case SAVEt_DESTRUCTOR_X:
964 ptr = SSPOPPTR;
acfe0abc 965 (*SSPOPDXPTR)(aTHX_ ptr);
a0d0e21e 966 break;
967 case SAVEt_REGCONTEXT:
455ece5e 968 case SAVEt_ALLOC:
161b7d16 969 i = SSPOPINT;
3280af22 970 PL_savestack_ix -= i; /* regexp must have croaked */
a0d0e21e 971 break;
55497cff 972 case SAVEt_STACK_POS: /* Position on Perl stack */
161b7d16 973 i = SSPOPINT;
3280af22 974 PL_stack_sp = PL_stack_base + i;
55497cff 975 break;
161b7d16 976 case SAVEt_AELEM: /* array element */
977 value = (SV*)SSPOPPTR;
978 i = SSPOPINT;
979 av = (AV*)SSPOPPTR;
51d9a56b 980 if (!AvREAL(av) && AvREIFY(av)) /* undo reify guard */
981 SvREFCNT_dec(value);
161b7d16 982 ptr = av_fetch(av,i,1);
4e4c362e 983 if (ptr) {
984 sv = *(SV**)ptr;
3280af22 985 if (sv && sv != &PL_sv_undef) {
14befaf4 986 if (SvTIED_mg((SV*)av, PERL_MAGIC_tied))
4e4c362e 987 (void)SvREFCNT_inc(sv);
4e4c362e 988 goto restore_sv;
989 }
990 }
991 SvREFCNT_dec(av);
992 SvREFCNT_dec(value);
993 break;
161b7d16 994 case SAVEt_HELEM: /* hash element */
995 value = (SV*)SSPOPPTR;
9002cb76 996 sv = (SV*)SSPOPPTR;
161b7d16 997 hv = (HV*)SSPOPPTR;
998 ptr = hv_fetch_ent(hv, sv, 1, 0);
4e4c362e 999 if (ptr) {
1000 SV *oval = HeVAL((HE*)ptr);
3280af22 1001 if (oval && oval != &PL_sv_undef) {
4e4c362e 1002 ptr = &HeVAL((HE*)ptr);
14befaf4 1003 if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied))
4e4c362e 1004 (void)SvREFCNT_inc(*(SV**)ptr);
4e4c362e 1005 SvREFCNT_dec(sv);
51d9a56b 1006 av = (AV*)hv; /* what to refcnt_dec */
4e4c362e 1007 goto restore_sv;
1008 }
1009 }
1010 SvREFCNT_dec(hv);
1011 SvREFCNT_dec(sv);
1012 SvREFCNT_dec(value);
1013 break;
462e5cf6 1014 case SAVEt_OP:
533c011a 1015 PL_op = (OP*)SSPOPPTR;
462e5cf6 1016 break;
25eaa213 1017 case SAVEt_HINTS:
045ac317 1018 if ((PL_hints & HINT_LOCALIZE_HH) && GvHV(PL_hintgv)) {
1019 SvREFCNT_dec((SV*)GvHV(PL_hintgv));
1020 GvHV(PL_hintgv) = NULL;
1021 }
3280af22 1022 *(I32*)&PL_hints = (I32)SSPOPINT;
b3ac6de7 1023 break;
cb50131a 1024 case SAVEt_COMPPAD:
f3548bdc 1025 PL_comppad = (PAD*)SSPOPPTR;
cb50131a 1026 if (PL_comppad)
1027 PL_curpad = AvARRAY(PL_comppad);
1028 else
1029 PL_curpad = Null(SV**);
1030 break;
c3564e5c 1031 case SAVEt_PADSV:
1032 {
1033 PADOFFSET off = (PADOFFSET)SSPOPLONG;
1034 ptr = SSPOPPTR;
1035 if (ptr)
f3548bdc 1036 AvARRAY((PAD*)ptr)[off] = (SV*)SSPOPPTR;
c3564e5c 1037 }
1038 break;
79072805 1039 default:
cea2e8a9 1040 Perl_croak(aTHX_ "panic: leave_scope inconsistency");
79072805 1041 }
1042 }
1043}
8990e307 1044
8990e307 1045void
864dbfa3 1046Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
8990e307 1047{
35ff7856 1048#ifdef DEBUGGING
22c35a8c 1049 PerlIO_printf(Perl_debug_log, "CX %ld = %s\n", (long)(cx - cxstack), PL_block_type[CxTYPE(cx)]);
6b35e009 1050 if (CxTYPE(cx) != CXt_SUBST) {
760ac839 1051 PerlIO_printf(Perl_debug_log, "BLK_OLDSP = %ld\n", (long)cx->blk_oldsp);
146174a9 1052 PerlIO_printf(Perl_debug_log, "BLK_OLDCOP = 0x%"UVxf"\n",
1053 PTR2UV(cx->blk_oldcop));
760ac839 1054 PerlIO_printf(Perl_debug_log, "BLK_OLDMARKSP = %ld\n", (long)cx->blk_oldmarksp);
1055 PerlIO_printf(Perl_debug_log, "BLK_OLDSCOPESP = %ld\n", (long)cx->blk_oldscopesp);
1056 PerlIO_printf(Perl_debug_log, "BLK_OLDRETSP = %ld\n", (long)cx->blk_oldretsp);
146174a9 1057 PerlIO_printf(Perl_debug_log, "BLK_OLDPM = 0x%"UVxf"\n",
1058 PTR2UV(cx->blk_oldpm));
760ac839 1059 PerlIO_printf(Perl_debug_log, "BLK_GIMME = %s\n", cx->blk_gimme ? "LIST" : "SCALAR");
8990e307 1060 }
6b35e009 1061 switch (CxTYPE(cx)) {
8990e307 1062 case CXt_NULL:
1063 case CXt_BLOCK:
1064 break;
146174a9 1065 case CXt_FORMAT:
1066 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1067 PTR2UV(cx->blk_sub.cv));
1068 PerlIO_printf(Perl_debug_log, "BLK_SUB.GV = 0x%"UVxf"\n",
1069 PTR2UV(cx->blk_sub.gv));
1070 PerlIO_printf(Perl_debug_log, "BLK_SUB.DFOUTGV = 0x%"UVxf"\n",
1071 PTR2UV(cx->blk_sub.dfoutgv));
1072 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
1073 (int)cx->blk_sub.hasargs);
1074 break;
8990e307 1075 case CXt_SUB:
146174a9 1076 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1077 PTR2UV(cx->blk_sub.cv));
760ac839 1078 PerlIO_printf(Perl_debug_log, "BLK_SUB.OLDDEPTH = %ld\n",
8990e307 1079 (long)cx->blk_sub.olddepth);
760ac839 1080 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
8990e307 1081 (int)cx->blk_sub.hasargs);
146174a9 1082 PerlIO_printf(Perl_debug_log, "BLK_SUB.LVAL = %d\n",
1083 (int)cx->blk_sub.lval);
8990e307 1084 break;
1085 case CXt_EVAL:
760ac839 1086 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_IN_EVAL = %ld\n",
8990e307 1087 (long)cx->blk_eval.old_in_eval);
760ac839 1088 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_OP_TYPE = %s (%s)\n",
22c35a8c 1089 PL_op_name[cx->blk_eval.old_op_type],
1090 PL_op_desc[cx->blk_eval.old_op_type]);
0f79a09d 1091 if (cx->blk_eval.old_namesv)
1092 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
1093 SvPVX(cx->blk_eval.old_namesv));
146174a9 1094 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%"UVxf"\n",
1095 PTR2UV(cx->blk_eval.old_eval_root));
8990e307 1096 break;
1097
1098 case CXt_LOOP:
760ac839 1099 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LABEL = %s\n",
8990e307 1100 cx->blk_loop.label);
760ac839 1101 PerlIO_printf(Perl_debug_log, "BLK_LOOP.RESETSP = %ld\n",
8990e307 1102 (long)cx->blk_loop.resetsp);
146174a9 1103 PerlIO_printf(Perl_debug_log, "BLK_LOOP.REDO_OP = 0x%"UVxf"\n",
1104 PTR2UV(cx->blk_loop.redo_op));
1105 PerlIO_printf(Perl_debug_log, "BLK_LOOP.NEXT_OP = 0x%"UVxf"\n",
1106 PTR2UV(cx->blk_loop.next_op));
1107 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LAST_OP = 0x%"UVxf"\n",
1108 PTR2UV(cx->blk_loop.last_op));
760ac839 1109 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
8990e307 1110 (long)cx->blk_loop.iterix);
146174a9 1111 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
1112 PTR2UV(cx->blk_loop.iterary));
1113 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
1114 PTR2UV(CxITERVAR(cx)));
1115 if (CxITERVAR(cx))
1116 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%"UVxf"\n",
1117 PTR2UV(cx->blk_loop.itersave));
1118 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERLVAL = 0x%"UVxf"\n",
1119 PTR2UV(cx->blk_loop.iterlval));
8990e307 1120 break;
1121
1122 case CXt_SUBST:
760ac839 1123 PerlIO_printf(Perl_debug_log, "SB_ITERS = %ld\n",
8990e307 1124 (long)cx->sb_iters);
760ac839 1125 PerlIO_printf(Perl_debug_log, "SB_MAXITERS = %ld\n",
8990e307 1126 (long)cx->sb_maxiters);
35ef4773 1127 PerlIO_printf(Perl_debug_log, "SB_RFLAGS = %ld\n",
1128 (long)cx->sb_rflags);
760ac839 1129 PerlIO_printf(Perl_debug_log, "SB_ONCE = %ld\n",
8990e307 1130 (long)cx->sb_once);
760ac839 1131 PerlIO_printf(Perl_debug_log, "SB_ORIG = %s\n",
8990e307 1132 cx->sb_orig);
146174a9 1133 PerlIO_printf(Perl_debug_log, "SB_DSTR = 0x%"UVxf"\n",
1134 PTR2UV(cx->sb_dstr));
1135 PerlIO_printf(Perl_debug_log, "SB_TARG = 0x%"UVxf"\n",
1136 PTR2UV(cx->sb_targ));
1137 PerlIO_printf(Perl_debug_log, "SB_S = 0x%"UVxf"\n",
1138 PTR2UV(cx->sb_s));
1139 PerlIO_printf(Perl_debug_log, "SB_M = 0x%"UVxf"\n",
1140 PTR2UV(cx->sb_m));
1141 PerlIO_printf(Perl_debug_log, "SB_STREND = 0x%"UVxf"\n",
1142 PTR2UV(cx->sb_strend));
1143 PerlIO_printf(Perl_debug_log, "SB_RXRES = 0x%"UVxf"\n",
1144 PTR2UV(cx->sb_rxres));
8990e307 1145 break;
1146 }
17c3b450 1147#endif /* DEBUGGING */
35ff7856 1148}