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