This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
better handling of whitespace in autodoc declarations; fragment from:
[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
GS
462 SSCHECK(4);
463 SSPUSHPTR(PL_curpad[off]);
464 SSPUSHPTR(PL_curpad);
465 SSPUSHLONG((long)off);
466 SSPUSHINT(SAVEt_PADSV);
467}
468
54b9620d 469SV **
864dbfa3 470Perl_save_threadsv(pTHX_ PADOFFSET i)
54b9620d 471{
4d1ff10f 472#ifdef USE_5005THREADS
940cb80d 473 SV **svp = &THREADSV(i); /* XXX Change to save by offset */
146174a9
CB
474 DEBUG_S(PerlIO_printf(Perl_debug_log, "save_threadsv %"UVuf": %p %p:%s\n",
475 (UV)i, svp, *svp, SvPEEK(*svp)));
54b9620d
MB
476 save_svref(svp);
477 return svp;
478#else
cea2e8a9 479 Perl_croak(aTHX_ "panic: save_threadsv called in non-threaded perl");
54b9620d 480 return 0;
4d1ff10f 481#endif /* USE_5005THREADS */
54b9620d
MB
482}
483
79072805 484void
864dbfa3 485Perl_save_nogv(pTHX_ GV *gv)
79072805
LW
486{
487 SSCHECK(2);
488 SSPUSHPTR(gv);
489 SSPUSHINT(SAVEt_NSTAB);
490}
491
492void
864dbfa3 493Perl_save_hptr(pTHX_ HV **hptr)
79072805
LW
494{
495 SSCHECK(3);
85e6fe83 496 SSPUSHPTR(*hptr);
79072805
LW
497 SSPUSHPTR(hptr);
498 SSPUSHINT(SAVEt_HPTR);
499}
500
501void
864dbfa3 502Perl_save_aptr(pTHX_ AV **aptr)
79072805
LW
503{
504 SSCHECK(3);
85e6fe83 505 SSPUSHPTR(*aptr);
79072805
LW
506 SSPUSHPTR(aptr);
507 SSPUSHINT(SAVEt_APTR);
508}
509
510void
864dbfa3 511Perl_save_freesv(pTHX_ SV *sv)
8990e307
LW
512{
513 SSCHECK(2);
514 SSPUSHPTR(sv);
515 SSPUSHINT(SAVEt_FREESV);
516}
517
518void
26d9b02f
JH
519Perl_save_mortalizesv(pTHX_ SV *sv)
520{
521 SSCHECK(2);
522 SSPUSHPTR(sv);
523 SSPUSHINT(SAVEt_MORTALIZESV);
524}
525
526void
864dbfa3 527Perl_save_freeop(pTHX_ OP *o)
8990e307
LW
528{
529 SSCHECK(2);
11343788 530 SSPUSHPTR(o);
8990e307
LW
531 SSPUSHINT(SAVEt_FREEOP);
532}
533
534void
864dbfa3 535Perl_save_freepv(pTHX_ char *pv)
8990e307
LW
536{
537 SSCHECK(2);
538 SSPUSHPTR(pv);
539 SSPUSHINT(SAVEt_FREEPV);
540}
541
542void
864dbfa3 543Perl_save_clearsv(pTHX_ SV **svp)
8990e307
LW
544{
545 SSCHECK(2);
3280af22 546 SSPUSHLONG((long)(svp-PL_curpad));
8990e307
LW
547 SSPUSHINT(SAVEt_CLEARSV);
548}
549
550void
864dbfa3 551Perl_save_delete(pTHX_ HV *hv, char *key, I32 klen)
8990e307
LW
552{
553 SSCHECK(4);
554 SSPUSHINT(klen);
555 SSPUSHPTR(key);
4e4c362e 556 SSPUSHPTR(SvREFCNT_inc(hv));
8990e307
LW
557 SSPUSHINT(SAVEt_DELETE);
558}
559
560void
864dbfa3 561Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
79072805
LW
562{
563 register SV *sv;
564 register I32 i;
565
79072805 566 for (i = 1; i <= maxsarg; i++) {
79072805
LW
567 sv = NEWSV(0,0);
568 sv_setsv(sv,sarg[i]);
f46d017c
GS
569 SSCHECK(3);
570 SSPUSHPTR(sarg[i]); /* remember the pointer */
79072805
LW
571 SSPUSHPTR(sv); /* remember the value */
572 SSPUSHINT(SAVEt_ITEM);
573 }
574}
575
576void
146174a9 577Perl_save_destructor(pTHX_ DESTRUCTORFUNC_NOCONTEXT_t f, void* p)
a0d0e21e
LW
578{
579 SSCHECK(3);
580 SSPUSHDPTR(f);
581 SSPUSHPTR(p);
582 SSPUSHINT(SAVEt_DESTRUCTOR);
583}
584
585void
146174a9
CB
586Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p)
587{
146174a9
CB
588 SSCHECK(3);
589 SSPUSHDXPTR(f);
590 SSPUSHPTR(p);
591 SSPUSHINT(SAVEt_DESTRUCTOR_X);
592}
593
594void
864dbfa3 595Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
4e4c362e 596{
bfc4de9f 597 SV *sv;
4e4c362e
GS
598 SSCHECK(4);
599 SSPUSHPTR(SvREFCNT_inc(av));
600 SSPUSHINT(idx);
601 SSPUSHPTR(SvREFCNT_inc(*sptr));
602 SSPUSHINT(SAVEt_AELEM);
603 save_scalar_at(sptr);
bfc4de9f
DM
604 sv = *sptr;
605 /* If we're localizing a tied array element, this new sv
606 * won't actually be stored in the array - so it won't get
607 * reaped when the localize ends. Ensure it gets reaped by
608 * mortifying it instead. DAPM */
609 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
610 sv_2mortal(sv);
4e4c362e
GS
611}
612
613void
864dbfa3 614Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr)
4e4c362e 615{
bfc4de9f 616 SV *sv;
4e4c362e
GS
617 SSCHECK(4);
618 SSPUSHPTR(SvREFCNT_inc(hv));
619 SSPUSHPTR(SvREFCNT_inc(key));
620 SSPUSHPTR(SvREFCNT_inc(*sptr));
621 SSPUSHINT(SAVEt_HELEM);
622 save_scalar_at(sptr);
bfc4de9f
DM
623 sv = *sptr;
624 /* If we're localizing a tied hash element, this new sv
625 * won't actually be stored in the hash - so it won't get
626 * reaped when the localize ends. Ensure it gets reaped by
627 * mortifying it instead. DAPM */
628 if (SvTIED_mg(sv, PERL_MAGIC_tiedelem))
629 sv_2mortal(sv);
4e4c362e
GS
630}
631
632void
864dbfa3 633Perl_save_op(pTHX)
462e5cf6 634{
462e5cf6 635 SSCHECK(2);
533c011a 636 SSPUSHPTR(PL_op);
462e5cf6
MB
637 SSPUSHINT(SAVEt_OP);
638}
639
455ece5e 640I32
864dbfa3 641Perl_save_alloc(pTHX_ I32 size, I32 pad)
455ece5e 642{
455ece5e 643 register I32 start = pad + ((char*)&PL_savestack[PL_savestack_ix]
8aacddc1 644 - (char*)PL_savestack);
455ece5e
AD
645 register I32 elems = 1 + ((size + pad - 1) / sizeof(*PL_savestack));
646
647 /* SSCHECK may not be good enough */
648 while (PL_savestack_ix + elems + 2 > PL_savestack_max)
8aacddc1 649 savestack_grow();
455ece5e
AD
650
651 PL_savestack_ix += elems;
652 SSPUSHINT(elems);
653 SSPUSHINT(SAVEt_ALLOC);
654 return start;
655}
656
462e5cf6 657void
864dbfa3 658Perl_leave_scope(pTHX_ I32 base)
79072805
LW
659{
660 register SV *sv;
661 register SV *value;
662 register GV *gv;
663 register AV *av;
664 register HV *hv;
665 register void* ptr;
f4dd75d9 666 register char* str;
161b7d16 667 I32 i;
79072805
LW
668
669 if (base < -1)
cea2e8a9 670 Perl_croak(aTHX_ "panic: corrupt saved stack index");
3280af22 671 while (PL_savestack_ix > base) {
79072805
LW
672 switch (SSPOPINT) {
673 case SAVEt_ITEM: /* normal string */
674 value = (SV*)SSPOPPTR;
675 sv = (SV*)SSPOPPTR;
676 sv_replace(sv,value);
3280af22 677 PL_localizing = 2;
79072805 678 SvSETMAGIC(sv);
3280af22 679 PL_localizing = 0;
79072805 680 break;
8aacddc1 681 case SAVEt_SV: /* scalar reference */
79072805
LW
682 value = (SV*)SSPOPPTR;
683 gv = (GV*)SSPOPPTR;
7a4c00b4 684 ptr = &GvSV(gv);
4e4c362e 685 SvREFCNT_dec(gv);
7a4c00b4 686 goto restore_sv;
8aacddc1 687 case SAVEt_GENERIC_PVREF: /* generic pv */
f4dd75d9
GS
688 str = (char*)SSPOPPTR;
689 ptr = SSPOPPTR;
690 if (*(char**)ptr != str) {
691 Safefree(*(char**)ptr);
692 *(char**)ptr = str;
693 }
694 break;
05ec9bb3
NIS
695 case SAVEt_SHARED_PVREF: /* shared pv */
696 str = (char*)SSPOPPTR;
697 ptr = SSPOPPTR;
698 if (*(char**)ptr != str) {
5e54c26f 699#ifdef NETWARE
9ecbcc42 700 PerlMem_free(*(char**)ptr);
5e54c26f 701#else
05ec9bb3 702 PerlMemShared_free(*(char**)ptr);
5e54c26f 703#endif
05ec9bb3
NIS
704 *(char**)ptr = str;
705 }
706 break;
8aacddc1 707 case SAVEt_GENERIC_SVREF: /* generic sv */
b9d12d37
GS
708 value = (SV*)SSPOPPTR;
709 ptr = SSPOPPTR;
f4dd75d9
GS
710 sv = *(SV**)ptr;
711 *(SV**)ptr = value;
712 SvREFCNT_dec(sv);
b9d12d37
GS
713 SvREFCNT_dec(value);
714 break;
8aacddc1 715 case SAVEt_SVREF: /* scalar reference */
7a4c00b4 716 value = (SV*)SSPOPPTR;
79072805 717 ptr = SSPOPPTR;
7a4c00b4 718 restore_sv:
79072805 719 sv = *(SV**)ptr;
146174a9 720 DEBUG_S(PerlIO_printf(Perl_debug_log,
54b9620d 721 "restore svref: %p %p:%s -> %p:%s\n",
8aacddc1 722 ptr, sv, SvPEEK(sv), value, SvPEEK(value)));
cdec4f49
JH
723 if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv) &&
724 SvTYPE(sv) != SVt_PVGV)
725 {
a0d0e21e
LW
726 (void)SvUPGRADE(value, SvTYPE(sv));
727 SvMAGIC(value) = SvMAGIC(sv);
728 SvFLAGS(value) |= SvMAGICAL(sv);
729 SvMAGICAL_off(sv);
79072805 730 SvMAGIC(sv) = 0;
a0d0e21e 731 }
2d5e9e5d
JH
732 /* XXX This branch is pretty bogus. This code irretrievably
733 * clears(!) the magic on the SV (either to avoid further
734 * croaking that might ensue when the SvSETMAGIC() below is
735 * called, or to avoid two different SVs pointing at the same
736 * SvMAGIC()). This needs a total rethink. --GSAR */
cdec4f49
JH
737 else if (SvTYPE(value) >= SVt_PVMG && SvMAGIC(value) &&
738 SvTYPE(value) != SVt_PVGV)
739 {
7a4c00b4 740 SvFLAGS(value) |= (SvFLAGS(value) &
8aacddc1 741 (SVp_NOK|SVp_POK)) >> PRIVSHIFT;
7a4c00b4 742 SvMAGICAL_off(value);
2d5e9e5d
JH
743 /* XXX this is a leak when we get here because the
744 * mg_get() in save_scalar_at() croaked */
745 SvMAGIC(value) = 0;
7a4c00b4 746 }
8aacddc1 747 SvREFCNT_dec(sv);
a0d0e21e 748 *(SV**)ptr = value;
3280af22 749 PL_localizing = 2;
a0d0e21e 750 SvSETMAGIC(value);
3280af22 751 PL_localizing = 0;
4e4c362e 752 SvREFCNT_dec(value);
8aacddc1
NIS
753 break;
754 case SAVEt_AV: /* array reference */
79072805
LW
755 av = (AV*)SSPOPPTR;
756 gv = (GV*)SSPOPPTR;
fb73857a
PP
757 if (GvAV(gv)) {
758 AV *goner = GvAV(gv);
759 SvMAGIC(av) = SvMAGIC(goner);
32da55ab 760 SvFLAGS((SV*)av) |= SvMAGICAL(goner);
fb73857a
PP
761 SvMAGICAL_off(goner);
762 SvMAGIC(goner) = 0;
763 SvREFCNT_dec(goner);
764 }
8aacddc1 765 GvAV(gv) = av;
fb73857a 766 if (SvMAGICAL(av)) {
3280af22 767 PL_localizing = 2;
fb73857a 768 SvSETMAGIC((SV*)av);
3280af22 769 PL_localizing = 0;
fb73857a 770 }
8aacddc1
NIS
771 break;
772 case SAVEt_HV: /* hash reference */
79072805
LW
773 hv = (HV*)SSPOPPTR;
774 gv = (GV*)SSPOPPTR;
fb73857a
PP
775 if (GvHV(gv)) {
776 HV *goner = GvHV(gv);
777 SvMAGIC(hv) = SvMAGIC(goner);
778 SvFLAGS(hv) |= SvMAGICAL(goner);
779 SvMAGICAL_off(goner);
780 SvMAGIC(goner) = 0;
781 SvREFCNT_dec(goner);
782 }
8aacddc1 783 GvHV(gv) = hv;
fb73857a 784 if (SvMAGICAL(hv)) {
3280af22 785 PL_localizing = 2;
fb73857a 786 SvSETMAGIC((SV*)hv);
3280af22 787 PL_localizing = 0;
fb73857a 788 }
8aacddc1 789 break;
79072805
LW
790 case SAVEt_INT: /* int reference */
791 ptr = SSPOPPTR;
792 *(int*)ptr = (int)SSPOPINT;
793 break;
85e6fe83
LW
794 case SAVEt_LONG: /* long reference */
795 ptr = SSPOPPTR;
796 *(long*)ptr = (long)SSPOPLONG;
797 break;
79072805
LW
798 case SAVEt_I32: /* I32 reference */
799 ptr = SSPOPPTR;
800 *(I32*)ptr = (I32)SSPOPINT;
801 break;
55497cff
PP
802 case SAVEt_I16: /* I16 reference */
803 ptr = SSPOPPTR;
804 *(I16*)ptr = (I16)SSPOPINT;
805 break;
146174a9
CB
806 case SAVEt_I8: /* I8 reference */
807 ptr = SSPOPPTR;
808 *(I8*)ptr = (I8)SSPOPINT;
809 break;
a0d0e21e
LW
810 case SAVEt_IV: /* IV reference */
811 ptr = SSPOPPTR;
812 *(IV*)ptr = (IV)SSPOPIV;
813 break;
79072805
LW
814 case SAVEt_SPTR: /* SV* reference */
815 ptr = SSPOPPTR;
816 *(SV**)ptr = (SV*)SSPOPPTR;
817 break;
146174a9 818 case SAVEt_VPTR: /* random* reference */
85e6fe83
LW
819 case SAVEt_PPTR: /* char* reference */
820 ptr = SSPOPPTR;
821 *(char**)ptr = (char*)SSPOPPTR;
822 break;
79072805
LW
823 case SAVEt_HPTR: /* HV* reference */
824 ptr = SSPOPPTR;
825 *(HV**)ptr = (HV*)SSPOPPTR;
826 break;
827 case SAVEt_APTR: /* AV* reference */
828 ptr = SSPOPPTR;
829 *(AV**)ptr = (AV*)SSPOPPTR;
830 break;
831 case SAVEt_NSTAB:
832 gv = (GV*)SSPOPPTR;
1f96a9ed 833 (void)sv_clear((SV*)gv);
79072805 834 break;
fb73857a 835 case SAVEt_GP: /* scalar reference */
79072805
LW
836 ptr = SSPOPPTR;
837 gv = (GV*)SSPOPPTR;
8aacddc1
NIS
838 if (SvPVX(gv) && SvLEN(gv) > 0) {
839 Safefree(SvPVX(gv));
840 }
841 SvPVX(gv) = (char *)SSPOPPTR;
842 SvCUR(gv) = (STRLEN)SSPOPIV;
843 SvLEN(gv) = (STRLEN)SSPOPIV;
844 gp_free(gv);
845 GvGP(gv) = (GP*)ptr;
fae75791 846 if (GvCVu(gv))
3280af22 847 PL_sub_generation++; /* putting a method back into circulation */
4633a7c4 848 SvREFCNT_dec(gv);
8aacddc1 849 break;
8990e307
LW
850 case SAVEt_FREESV:
851 ptr = SSPOPPTR;
852 SvREFCNT_dec((SV*)ptr);
853 break;
26d9b02f
JH
854 case SAVEt_MORTALIZESV:
855 ptr = SSPOPPTR;
856 sv_2mortal((SV*)ptr);
857 break;
8990e307
LW
858 case SAVEt_FREEOP:
859 ptr = SSPOPPTR;
3280af22
NIS
860 if (PL_comppad)
861 PL_curpad = AvARRAY(PL_comppad);
8990e307
LW
862 op_free((OP*)ptr);
863 break;
864 case SAVEt_FREEPV:
865 ptr = SSPOPPTR;
866 Safefree((char*)ptr);
867 break;
868 case SAVEt_CLEARSV:
3280af22 869 ptr = (void*)&PL_curpad[SSPOPLONG];
8990e307 870 sv = *(SV**)ptr;
bc44cdaf
GS
871 /* Can clear pad variable in place? */
872 if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) {
8aacddc1
NIS
873 /*
874 * if a my variable that was made readonly is going out of
875 * scope, we want to remove the readonlyness so that it can
876 * go out of scope quietly
8aacddc1 877 */
a26e96df 878 if (SvPADMY(sv) && !SvFAKE(sv))
8aacddc1
NIS
879 SvREADONLY_off(sv);
880
6fc92669 881 if (SvTHINKFIRST(sv))
840a7b70 882 sv_force_normal_flags(sv, SV_IMMEDIATE_UNREF);
a0d0e21e
LW
883 if (SvMAGICAL(sv))
884 mg_free(sv);
8990e307
LW
885
886 switch (SvTYPE(sv)) {
887 case SVt_NULL:
888 break;
889 case SVt_PVAV:
44a8e56a 890 av_clear((AV*)sv);
8990e307
LW
891 break;
892 case SVt_PVHV:
44a8e56a 893 hv_clear((HV*)sv);
8990e307
LW
894 break;
895 case SVt_PVCV:
cea2e8a9 896 Perl_croak(aTHX_ "panic: leave_scope pad code");
5377b701
CS
897 case SVt_RV:
898 case SVt_IV:
899 case SVt_NV:
900 (void)SvOK_off(sv);
8990e307
LW
901 break;
902 default:
a0d0e21e 903 (void)SvOK_off(sv);
5377b701 904 (void)SvOOK_off(sv);
8990e307
LW
905 break;
906 }
907 }
908 else { /* Someone has a claim on this, so abandon it. */
4aa0a1f7 909 U32 padflags = SvFLAGS(sv) & (SVs_PADBUSY|SVs_PADMY|SVs_PADTMP);
8990e307
LW
910 switch (SvTYPE(sv)) { /* Console ourselves with a new value */
911 case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break;
912 case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break;
913 default: *(SV**)ptr = NEWSV(0,0); break;
914 }
53868620 915 SvREFCNT_dec(sv); /* Cast current value to the winds. */
4aa0a1f7 916 SvFLAGS(*(SV**)ptr) |= padflags; /* preserve pad nature */
8990e307
LW
917 }
918 break;
919 case SAVEt_DELETE:
920 ptr = SSPOPPTR;
921 hv = (HV*)ptr;
922 ptr = SSPOPPTR;
748a9306 923 (void)hv_delete(hv, (char*)ptr, (U32)SSPOPINT, G_DISCARD);
4e4c362e 924 SvREFCNT_dec(hv);
8aacddc1 925 Safefree(ptr);
8990e307 926 break;
a0d0e21e
LW
927 case SAVEt_DESTRUCTOR:
928 ptr = SSPOPPTR;
146174a9
CB
929 (*SSPOPDPTR)(ptr);
930 break;
931 case SAVEt_DESTRUCTOR_X:
932 ptr = SSPOPPTR;
acfe0abc 933 (*SSPOPDXPTR)(aTHX_ ptr);
a0d0e21e
LW
934 break;
935 case SAVEt_REGCONTEXT:
455ece5e 936 case SAVEt_ALLOC:
161b7d16 937 i = SSPOPINT;
3280af22 938 PL_savestack_ix -= i; /* regexp must have croaked */
a0d0e21e 939 break;
55497cff 940 case SAVEt_STACK_POS: /* Position on Perl stack */
161b7d16 941 i = SSPOPINT;
3280af22 942 PL_stack_sp = PL_stack_base + i;
55497cff 943 break;
161b7d16
SM
944 case SAVEt_AELEM: /* array element */
945 value = (SV*)SSPOPPTR;
946 i = SSPOPINT;
947 av = (AV*)SSPOPPTR;
948 ptr = av_fetch(av,i,1);
4e4c362e
GS
949 if (ptr) {
950 sv = *(SV**)ptr;
3280af22 951 if (sv && sv != &PL_sv_undef) {
14befaf4 952 if (SvTIED_mg((SV*)av, PERL_MAGIC_tied))
4e4c362e
GS
953 (void)SvREFCNT_inc(sv);
954 SvREFCNT_dec(av);
955 goto restore_sv;
956 }
957 }
958 SvREFCNT_dec(av);
959 SvREFCNT_dec(value);
960 break;
161b7d16
SM
961 case SAVEt_HELEM: /* hash element */
962 value = (SV*)SSPOPPTR;
9002cb76 963 sv = (SV*)SSPOPPTR;
161b7d16
SM
964 hv = (HV*)SSPOPPTR;
965 ptr = hv_fetch_ent(hv, sv, 1, 0);
4e4c362e
GS
966 if (ptr) {
967 SV *oval = HeVAL((HE*)ptr);
3280af22 968 if (oval && oval != &PL_sv_undef) {
4e4c362e 969 ptr = &HeVAL((HE*)ptr);
14befaf4 970 if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied))
4e4c362e
GS
971 (void)SvREFCNT_inc(*(SV**)ptr);
972 SvREFCNT_dec(hv);
973 SvREFCNT_dec(sv);
974 goto restore_sv;
975 }
976 }
977 SvREFCNT_dec(hv);
978 SvREFCNT_dec(sv);
979 SvREFCNT_dec(value);
980 break;
462e5cf6 981 case SAVEt_OP:
533c011a 982 PL_op = (OP*)SSPOPPTR;
462e5cf6 983 break;
25eaa213 984 case SAVEt_HINTS:
045ac317
RGS
985 if ((PL_hints & HINT_LOCALIZE_HH) && GvHV(PL_hintgv)) {
986 SvREFCNT_dec((SV*)GvHV(PL_hintgv));
987 GvHV(PL_hintgv) = NULL;
988 }
3280af22 989 *(I32*)&PL_hints = (I32)SSPOPINT;
b3ac6de7 990 break;
cb50131a
CB
991 case SAVEt_COMPPAD:
992 PL_comppad = (AV*)SSPOPPTR;
993 if (PL_comppad)
994 PL_curpad = AvARRAY(PL_comppad);
995 else
996 PL_curpad = Null(SV**);
997 break;
c3564e5c
GS
998 case SAVEt_PADSV:
999 {
1000 PADOFFSET off = (PADOFFSET)SSPOPLONG;
1001 ptr = SSPOPPTR;
1002 if (ptr)
1003 ((SV**)ptr)[off] = (SV*)SSPOPPTR;
1004 }
1005 break;
79072805 1006 default:
cea2e8a9 1007 Perl_croak(aTHX_ "panic: leave_scope inconsistency");
79072805
LW
1008 }
1009 }
1010}
8990e307 1011
8990e307 1012void
864dbfa3 1013Perl_cx_dump(pTHX_ PERL_CONTEXT *cx)
8990e307 1014{
35ff7856 1015#ifdef DEBUGGING
22c35a8c 1016 PerlIO_printf(Perl_debug_log, "CX %ld = %s\n", (long)(cx - cxstack), PL_block_type[CxTYPE(cx)]);
6b35e009 1017 if (CxTYPE(cx) != CXt_SUBST) {
760ac839 1018 PerlIO_printf(Perl_debug_log, "BLK_OLDSP = %ld\n", (long)cx->blk_oldsp);
146174a9
CB
1019 PerlIO_printf(Perl_debug_log, "BLK_OLDCOP = 0x%"UVxf"\n",
1020 PTR2UV(cx->blk_oldcop));
760ac839
LW
1021 PerlIO_printf(Perl_debug_log, "BLK_OLDMARKSP = %ld\n", (long)cx->blk_oldmarksp);
1022 PerlIO_printf(Perl_debug_log, "BLK_OLDSCOPESP = %ld\n", (long)cx->blk_oldscopesp);
1023 PerlIO_printf(Perl_debug_log, "BLK_OLDRETSP = %ld\n", (long)cx->blk_oldretsp);
146174a9
CB
1024 PerlIO_printf(Perl_debug_log, "BLK_OLDPM = 0x%"UVxf"\n",
1025 PTR2UV(cx->blk_oldpm));
760ac839 1026 PerlIO_printf(Perl_debug_log, "BLK_GIMME = %s\n", cx->blk_gimme ? "LIST" : "SCALAR");
8990e307 1027 }
6b35e009 1028 switch (CxTYPE(cx)) {
8990e307
LW
1029 case CXt_NULL:
1030 case CXt_BLOCK:
1031 break;
146174a9
CB
1032 case CXt_FORMAT:
1033 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1034 PTR2UV(cx->blk_sub.cv));
1035 PerlIO_printf(Perl_debug_log, "BLK_SUB.GV = 0x%"UVxf"\n",
1036 PTR2UV(cx->blk_sub.gv));
1037 PerlIO_printf(Perl_debug_log, "BLK_SUB.DFOUTGV = 0x%"UVxf"\n",
1038 PTR2UV(cx->blk_sub.dfoutgv));
1039 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
1040 (int)cx->blk_sub.hasargs);
1041 break;
8990e307 1042 case CXt_SUB:
146174a9
CB
1043 PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%"UVxf"\n",
1044 PTR2UV(cx->blk_sub.cv));
760ac839 1045 PerlIO_printf(Perl_debug_log, "BLK_SUB.OLDDEPTH = %ld\n",
8990e307 1046 (long)cx->blk_sub.olddepth);
760ac839 1047 PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n",
8990e307 1048 (int)cx->blk_sub.hasargs);
146174a9
CB
1049 PerlIO_printf(Perl_debug_log, "BLK_SUB.LVAL = %d\n",
1050 (int)cx->blk_sub.lval);
8990e307
LW
1051 break;
1052 case CXt_EVAL:
760ac839 1053 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_IN_EVAL = %ld\n",
8990e307 1054 (long)cx->blk_eval.old_in_eval);
760ac839 1055 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_OP_TYPE = %s (%s)\n",
22c35a8c
GS
1056 PL_op_name[cx->blk_eval.old_op_type],
1057 PL_op_desc[cx->blk_eval.old_op_type]);
0f79a09d
GS
1058 if (cx->blk_eval.old_namesv)
1059 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n",
1060 SvPVX(cx->blk_eval.old_namesv));
146174a9
CB
1061 PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%"UVxf"\n",
1062 PTR2UV(cx->blk_eval.old_eval_root));
8990e307
LW
1063 break;
1064
1065 case CXt_LOOP:
760ac839 1066 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LABEL = %s\n",
8990e307 1067 cx->blk_loop.label);
760ac839 1068 PerlIO_printf(Perl_debug_log, "BLK_LOOP.RESETSP = %ld\n",
8990e307 1069 (long)cx->blk_loop.resetsp);
146174a9
CB
1070 PerlIO_printf(Perl_debug_log, "BLK_LOOP.REDO_OP = 0x%"UVxf"\n",
1071 PTR2UV(cx->blk_loop.redo_op));
1072 PerlIO_printf(Perl_debug_log, "BLK_LOOP.NEXT_OP = 0x%"UVxf"\n",
1073 PTR2UV(cx->blk_loop.next_op));
1074 PerlIO_printf(Perl_debug_log, "BLK_LOOP.LAST_OP = 0x%"UVxf"\n",
1075 PTR2UV(cx->blk_loop.last_op));
760ac839 1076 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n",
8990e307 1077 (long)cx->blk_loop.iterix);
146174a9
CB
1078 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%"UVxf"\n",
1079 PTR2UV(cx->blk_loop.iterary));
1080 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%"UVxf"\n",
1081 PTR2UV(CxITERVAR(cx)));
1082 if (CxITERVAR(cx))
1083 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%"UVxf"\n",
1084 PTR2UV(cx->blk_loop.itersave));
1085 PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERLVAL = 0x%"UVxf"\n",
1086 PTR2UV(cx->blk_loop.iterlval));
8990e307
LW
1087 break;
1088
1089 case CXt_SUBST:
760ac839 1090 PerlIO_printf(Perl_debug_log, "SB_ITERS = %ld\n",
8990e307 1091 (long)cx->sb_iters);
760ac839 1092 PerlIO_printf(Perl_debug_log, "SB_MAXITERS = %ld\n",
8990e307 1093 (long)cx->sb_maxiters);
35ef4773
GS
1094 PerlIO_printf(Perl_debug_log, "SB_RFLAGS = %ld\n",
1095 (long)cx->sb_rflags);
760ac839 1096 PerlIO_printf(Perl_debug_log, "SB_ONCE = %ld\n",
8990e307 1097 (long)cx->sb_once);
760ac839 1098 PerlIO_printf(Perl_debug_log, "SB_ORIG = %s\n",
8990e307 1099 cx->sb_orig);
146174a9
CB
1100 PerlIO_printf(Perl_debug_log, "SB_DSTR = 0x%"UVxf"\n",
1101 PTR2UV(cx->sb_dstr));
1102 PerlIO_printf(Perl_debug_log, "SB_TARG = 0x%"UVxf"\n",
1103 PTR2UV(cx->sb_targ));
1104 PerlIO_printf(Perl_debug_log, "SB_S = 0x%"UVxf"\n",
1105 PTR2UV(cx->sb_s));
1106 PerlIO_printf(Perl_debug_log, "SB_M = 0x%"UVxf"\n",
1107 PTR2UV(cx->sb_m));
1108 PerlIO_printf(Perl_debug_log, "SB_STREND = 0x%"UVxf"\n",
1109 PTR2UV(cx->sb_strend));
1110 PerlIO_printf(Perl_debug_log, "SB_RXRES = 0x%"UVxf"\n",
1111 PTR2UV(cx->sb_rxres));
8990e307
LW
1112 break;
1113 }
17c3b450 1114#endif /* DEBUGGING */
35ff7856 1115}