Commit | Line | Data |
a0d0e21e |
1 | /* scope.c |
79072805 |
2 | * |
a0d0e21e |
3 | * Copyright (c) 1991-1994, Larry Wall |
79072805 |
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 |
8 | */ |
9 | |
10 | /* |
11 | * "For the fashion of Minas Tirith was such that it was built on seven |
12 | * levels..." |
79072805 |
13 | */ |
14 | |
15 | #include "EXTERN.h" |
16 | #include "perl.h" |
17 | |
5377b701 |
18 | /* |
19 | * This value determines how small an SV is "small enough" to keep |
20 | * in a lexical variable in anticipation of the next invocation. |
21 | */ |
22 | #define PADVAL_SMALL_ENOUGH 240 |
23 | |
a0d0e21e |
24 | SV** |
25 | stack_grow(sp, p, n) |
26 | SV** sp; |
27 | SV** p; |
28 | int n; |
29 | { |
30 | stack_sp = sp; |
1f96a9ed |
31 | av_extend(curstack, (p - stack_base) + (n) + 128); |
a0d0e21e |
32 | return stack_sp; |
33 | } |
34 | |
79072805 |
35 | I32 |
36 | cxinc() |
37 | { |
38 | cxstack_max = cxstack_max * 3 / 2; |
a38d6535 |
39 | Renew(cxstack, cxstack_max + 1, CONTEXT); /* XXX should fix CXINC macro */ |
79072805 |
40 | return cxstack_ix + 1; |
41 | } |
42 | |
43 | void |
44 | push_return(retop) |
45 | OP *retop; |
46 | { |
47 | if (retstack_ix == retstack_max) { |
48 | retstack_max = retstack_max * 3 / 2; |
49 | Renew(retstack, retstack_max, OP*); |
50 | } |
51 | retstack[retstack_ix++] = retop; |
52 | } |
53 | |
54 | OP * |
55 | pop_return() |
56 | { |
57 | if (retstack_ix > 0) |
58 | return retstack[--retstack_ix]; |
59 | else |
60 | return Nullop; |
61 | } |
62 | |
63 | void |
64 | push_scope() |
65 | { |
66 | if (scopestack_ix == scopestack_max) { |
67 | scopestack_max = scopestack_max * 3 / 2; |
68 | Renew(scopestack, scopestack_max, I32); |
69 | } |
70 | scopestack[scopestack_ix++] = savestack_ix; |
71 | |
72 | } |
73 | |
74 | void |
75 | pop_scope() |
76 | { |
77 | I32 oldsave = scopestack[--scopestack_ix]; |
8990e307 |
78 | LEAVE_SCOPE(oldsave); |
79072805 |
79 | } |
80 | |
81 | void |
a0d0e21e |
82 | markstack_grow() |
83 | { |
84 | I32 oldmax = markstack_max - markstack; |
85 | I32 newmax = oldmax * 3 / 2; |
86 | |
87 | Renew(markstack, newmax, I32); |
88 | markstack_ptr = markstack + oldmax; |
89 | markstack_max = markstack + newmax; |
90 | } |
91 | |
92 | void |
79072805 |
93 | savestack_grow() |
94 | { |
95 | savestack_max = savestack_max * 3 / 2; |
96 | Renew(savestack, savestack_max, ANY); |
97 | } |
98 | |
99 | void |
100 | free_tmps() |
101 | { |
102 | /* XXX should tmps_floor live in cxstack? */ |
103 | I32 myfloor = tmps_floor; |
104 | while (tmps_ix > myfloor) { /* clean up after last statement */ |
105 | SV* sv = tmps_stack[tmps_ix]; |
106 | tmps_stack[tmps_ix--] = Nullsv; |
463ee0b2 |
107 | if (sv) { |
108 | #ifdef DEBUGGING |
109 | SvTEMP_off(sv); |
110 | #endif |
8990e307 |
111 | SvREFCNT_dec(sv); /* note, can modify tmps_ix!!! */ |
463ee0b2 |
112 | } |
79072805 |
113 | } |
114 | } |
115 | |
7a4c00b4 |
116 | static SV * |
117 | save_scalar_at(sptr) |
118 | SV **sptr; |
79072805 |
119 | { |
120 | register SV *sv; |
7a4c00b4 |
121 | SV *osv = *sptr; |
79072805 |
122 | |
7a4c00b4 |
123 | sv = *sptr = NEWSV(0,0); |
a0d0e21e |
124 | if (SvTYPE(osv) >= SVt_PVMG && SvMAGIC(osv) && SvTYPE(osv) != SVt_PVGV) { |
79072805 |
125 | sv_upgrade(sv, SvTYPE(osv)); |
a0d0e21e |
126 | if (SvGMAGICAL(osv)) { |
748a9306 |
127 | MAGIC* mg; |
128 | bool oldtainted = tainted; |
a0d0e21e |
129 | mg_get(osv); |
748a9306 |
130 | if (tainting && tainted && (mg = mg_find(osv, 't'))) { |
131 | SAVESPTR(mg->mg_obj); |
132 | mg->mg_obj = osv; |
133 | } |
a0d0e21e |
134 | SvFLAGS(osv) |= (SvFLAGS(osv) & |
135 | (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT; |
748a9306 |
136 | tainted = oldtainted; |
a0d0e21e |
137 | } |
79072805 |
138 | SvMAGIC(sv) = SvMAGIC(osv); |
a0d0e21e |
139 | SvFLAGS(sv) |= SvMAGICAL(osv); |
748a9306 |
140 | localizing = 1; |
79072805 |
141 | SvSETMAGIC(sv); |
748a9306 |
142 | localizing = 0; |
79072805 |
143 | } |
144 | return sv; |
145 | } |
146 | |
7a4c00b4 |
147 | SV * |
148 | save_scalar(gv) |
149 | GV *gv; |
150 | { |
151 | SSCHECK(3); |
152 | SSPUSHPTR(gv); |
153 | SSPUSHPTR(GvSV(gv)); |
154 | SSPUSHINT(SAVEt_SV); |
155 | return save_scalar_at(&GvSV(gv)); |
156 | } |
157 | |
158 | SV* |
159 | save_svref(sptr) |
160 | SV **sptr; |
161 | { |
162 | SSCHECK(3); |
163 | SSPUSHPTR(sptr); |
164 | SSPUSHPTR(*sptr); |
165 | SSPUSHINT(SAVEt_SVREF); |
166 | return save_scalar_at(sptr); |
167 | } |
168 | |
79072805 |
169 | void |
5f05dabc |
170 | save_gp(gv, empty) |
79072805 |
171 | GV *gv; |
5f05dabc |
172 | I32 empty; |
79072805 |
173 | { |
79072805 |
174 | SSCHECK(3); |
4633a7c4 |
175 | SSPUSHPTR(SvREFCNT_inc(gv)); |
5f05dabc |
176 | SSPUSHPTR(GvGP(gv)); |
79072805 |
177 | SSPUSHINT(SAVEt_GP); |
178 | |
5f05dabc |
179 | if (empty) { |
180 | register GP *gp; |
181 | Newz(602, gp, 1, GP); |
182 | GvGP(gv) = gp; |
183 | GvREFCNT(gv) = 1; |
184 | GvSV(gv) = NEWSV(72,0); |
185 | GvLINE(gv) = curcop->cop_line; |
186 | GvEGV(gv) = gv; |
187 | } |
188 | else { |
189 | GvGP(gv)->gp_refcnt++; |
190 | GvINTRO_on(gv); |
191 | } |
79072805 |
192 | } |
79072805 |
193 | |
79072805 |
194 | AV * |
195 | save_ary(gv) |
196 | GV *gv; |
197 | { |
198 | SSCHECK(3); |
199 | SSPUSHPTR(gv); |
200 | SSPUSHPTR(GvAVn(gv)); |
201 | SSPUSHINT(SAVEt_AV); |
202 | |
203 | GvAV(gv) = Null(AV*); |
204 | return GvAVn(gv); |
205 | } |
206 | |
207 | HV * |
208 | save_hash(gv) |
209 | GV *gv; |
210 | { |
211 | SSCHECK(3); |
212 | SSPUSHPTR(gv); |
213 | SSPUSHPTR(GvHVn(gv)); |
214 | SSPUSHINT(SAVEt_HV); |
215 | |
216 | GvHV(gv) = Null(HV*); |
217 | return GvHVn(gv); |
218 | } |
219 | |
220 | void |
221 | save_item(item) |
222 | register SV *item; |
223 | { |
224 | register SV *sv; |
225 | |
226 | SSCHECK(3); |
227 | SSPUSHPTR(item); /* remember the pointer */ |
228 | sv = NEWSV(0,0); |
229 | sv_setsv(sv,item); |
230 | SSPUSHPTR(sv); /* remember the value */ |
231 | SSPUSHINT(SAVEt_ITEM); |
232 | } |
233 | |
234 | void |
235 | save_int(intp) |
236 | int *intp; |
237 | { |
238 | SSCHECK(3); |
239 | SSPUSHINT(*intp); |
240 | SSPUSHPTR(intp); |
241 | SSPUSHINT(SAVEt_INT); |
242 | } |
243 | |
244 | void |
85e6fe83 |
245 | save_long(longp) |
246 | long *longp; |
247 | { |
248 | SSCHECK(3); |
249 | SSPUSHLONG(*longp); |
250 | SSPUSHPTR(longp); |
251 | SSPUSHINT(SAVEt_LONG); |
252 | } |
253 | |
254 | void |
79072805 |
255 | save_I32(intp) |
256 | I32 *intp; |
257 | { |
258 | SSCHECK(3); |
259 | SSPUSHINT(*intp); |
260 | SSPUSHPTR(intp); |
261 | SSPUSHINT(SAVEt_I32); |
262 | } |
263 | |
a0d0e21e |
264 | void |
55497cff |
265 | save_I16(intp) |
266 | I16 *intp; |
267 | { |
268 | SSCHECK(3); |
269 | SSPUSHINT(*intp); |
270 | SSPUSHPTR(intp); |
271 | SSPUSHINT(SAVEt_I16); |
272 | } |
273 | |
274 | void |
a0d0e21e |
275 | save_iv(ivp) |
276 | IV *ivp; |
277 | { |
278 | SSCHECK(3); |
4aa0a1f7 |
279 | SSPUSHIV(*ivp); |
a0d0e21e |
280 | SSPUSHPTR(ivp); |
281 | SSPUSHINT(SAVEt_IV); |
282 | } |
283 | |
85e6fe83 |
284 | /* Cannot use save_sptr() to store a char* since the SV** cast will |
285 | * force word-alignment and we'll miss the pointer. |
286 | */ |
287 | void |
288 | save_pptr(pptr) |
289 | char **pptr; |
290 | { |
291 | SSCHECK(3); |
292 | SSPUSHPTR(*pptr); |
293 | SSPUSHPTR(pptr); |
294 | SSPUSHINT(SAVEt_PPTR); |
295 | } |
296 | |
79072805 |
297 | void |
298 | save_sptr(sptr) |
299 | SV **sptr; |
300 | { |
301 | SSCHECK(3); |
302 | SSPUSHPTR(*sptr); |
303 | SSPUSHPTR(sptr); |
304 | SSPUSHINT(SAVEt_SPTR); |
305 | } |
306 | |
307 | void |
308 | save_nogv(gv) |
309 | GV *gv; |
310 | { |
311 | SSCHECK(2); |
312 | SSPUSHPTR(gv); |
313 | SSPUSHINT(SAVEt_NSTAB); |
314 | } |
315 | |
316 | void |
317 | save_hptr(hptr) |
318 | HV **hptr; |
319 | { |
320 | SSCHECK(3); |
85e6fe83 |
321 | SSPUSHPTR(*hptr); |
79072805 |
322 | SSPUSHPTR(hptr); |
323 | SSPUSHINT(SAVEt_HPTR); |
324 | } |
325 | |
326 | void |
327 | save_aptr(aptr) |
328 | AV **aptr; |
329 | { |
330 | SSCHECK(3); |
85e6fe83 |
331 | SSPUSHPTR(*aptr); |
79072805 |
332 | SSPUSHPTR(aptr); |
333 | SSPUSHINT(SAVEt_APTR); |
334 | } |
335 | |
336 | void |
8990e307 |
337 | save_freesv(sv) |
338 | SV *sv; |
339 | { |
340 | SSCHECK(2); |
341 | SSPUSHPTR(sv); |
342 | SSPUSHINT(SAVEt_FREESV); |
343 | } |
344 | |
345 | void |
346 | save_freeop(op) |
347 | OP *op; |
348 | { |
349 | SSCHECK(2); |
350 | SSPUSHPTR(op); |
351 | SSPUSHINT(SAVEt_FREEOP); |
352 | } |
353 | |
354 | void |
355 | save_freepv(pv) |
356 | char *pv; |
357 | { |
358 | SSCHECK(2); |
359 | SSPUSHPTR(pv); |
360 | SSPUSHINT(SAVEt_FREEPV); |
361 | } |
362 | |
363 | void |
364 | save_clearsv(svp) |
365 | SV** svp; |
366 | { |
367 | SSCHECK(2); |
4aa0a1f7 |
368 | SSPUSHLONG((long)(svp-curpad)); |
8990e307 |
369 | SSPUSHINT(SAVEt_CLEARSV); |
370 | } |
371 | |
372 | void |
373 | save_delete(hv,key,klen) |
374 | HV *hv; |
375 | char *key; |
376 | I32 klen; |
377 | { |
378 | SSCHECK(4); |
379 | SSPUSHINT(klen); |
380 | SSPUSHPTR(key); |
381 | SSPUSHPTR(hv); |
382 | SSPUSHINT(SAVEt_DELETE); |
383 | } |
384 | |
385 | void |
79072805 |
386 | save_list(sarg,maxsarg) |
387 | register SV **sarg; |
388 | I32 maxsarg; |
389 | { |
390 | register SV *sv; |
391 | register I32 i; |
392 | |
393 | SSCHECK(3 * maxsarg); |
394 | for (i = 1; i <= maxsarg; i++) { |
395 | SSPUSHPTR(sarg[i]); /* remember the pointer */ |
396 | sv = NEWSV(0,0); |
397 | sv_setsv(sv,sarg[i]); |
398 | SSPUSHPTR(sv); /* remember the value */ |
399 | SSPUSHINT(SAVEt_ITEM); |
400 | } |
401 | } |
402 | |
403 | void |
a0d0e21e |
404 | save_destructor(f,p) |
405 | void (*f) _((void*)); |
406 | void* p; |
407 | { |
408 | SSCHECK(3); |
409 | SSPUSHDPTR(f); |
410 | SSPUSHPTR(p); |
411 | SSPUSHINT(SAVEt_DESTRUCTOR); |
412 | } |
413 | |
414 | void |
79072805 |
415 | leave_scope(base) |
416 | I32 base; |
417 | { |
418 | register SV *sv; |
419 | register SV *value; |
420 | register GV *gv; |
421 | register AV *av; |
422 | register HV *hv; |
423 | register void* ptr; |
424 | |
425 | if (base < -1) |
463ee0b2 |
426 | croak("panic: corrupt saved stack index"); |
79072805 |
427 | while (savestack_ix > base) { |
428 | switch (SSPOPINT) { |
429 | case SAVEt_ITEM: /* normal string */ |
430 | value = (SV*)SSPOPPTR; |
431 | sv = (SV*)SSPOPPTR; |
432 | sv_replace(sv,value); |
748a9306 |
433 | localizing = 2; |
79072805 |
434 | SvSETMAGIC(sv); |
748a9306 |
435 | localizing = 0; |
79072805 |
436 | break; |
437 | case SAVEt_SV: /* scalar reference */ |
438 | value = (SV*)SSPOPPTR; |
439 | gv = (GV*)SSPOPPTR; |
7a4c00b4 |
440 | ptr = &GvSV(gv); |
441 | goto restore_sv; |
79072805 |
442 | case SAVEt_SVREF: /* scalar reference */ |
7a4c00b4 |
443 | value = (SV*)SSPOPPTR; |
79072805 |
444 | ptr = SSPOPPTR; |
7a4c00b4 |
445 | restore_sv: |
79072805 |
446 | sv = *(SV**)ptr; |
748a9306 |
447 | if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv) && |
448 | SvTYPE(sv) != SVt_PVGV) |
449 | { |
a0d0e21e |
450 | (void)SvUPGRADE(value, SvTYPE(sv)); |
451 | SvMAGIC(value) = SvMAGIC(sv); |
452 | SvFLAGS(value) |= SvMAGICAL(sv); |
453 | SvMAGICAL_off(sv); |
79072805 |
454 | SvMAGIC(sv) = 0; |
a0d0e21e |
455 | } |
7a4c00b4 |
456 | else if (SvTYPE(value) >= SVt_PVMG && SvMAGIC(value) && |
457 | SvTYPE(value) != SVt_PVGV) |
458 | { |
459 | SvFLAGS(value) |= (SvFLAGS(value) & |
460 | (SVp_IOK|SVp_NOK|SVp_POK)) >> PRIVSHIFT; |
461 | SvMAGICAL_off(value); |
462 | SvMAGIC(value) = 0; |
463 | } |
8990e307 |
464 | SvREFCNT_dec(sv); |
a0d0e21e |
465 | *(SV**)ptr = value; |
748a9306 |
466 | localizing = 2; |
a0d0e21e |
467 | SvSETMAGIC(value); |
748a9306 |
468 | localizing = 0; |
79072805 |
469 | break; |
470 | case SAVEt_AV: /* array reference */ |
471 | av = (AV*)SSPOPPTR; |
472 | gv = (GV*)SSPOPPTR; |
8990e307 |
473 | SvREFCNT_dec(GvAV(gv)); |
79072805 |
474 | GvAV(gv) = av; |
475 | break; |
476 | case SAVEt_HV: /* hash reference */ |
477 | hv = (HV*)SSPOPPTR; |
478 | gv = (GV*)SSPOPPTR; |
8990e307 |
479 | SvREFCNT_dec(GvHV(gv)); |
79072805 |
480 | GvHV(gv) = hv; |
481 | break; |
482 | case SAVEt_INT: /* int reference */ |
483 | ptr = SSPOPPTR; |
484 | *(int*)ptr = (int)SSPOPINT; |
485 | break; |
85e6fe83 |
486 | case SAVEt_LONG: /* long reference */ |
487 | ptr = SSPOPPTR; |
488 | *(long*)ptr = (long)SSPOPLONG; |
489 | break; |
79072805 |
490 | case SAVEt_I32: /* I32 reference */ |
491 | ptr = SSPOPPTR; |
492 | *(I32*)ptr = (I32)SSPOPINT; |
493 | break; |
55497cff |
494 | case SAVEt_I16: /* I16 reference */ |
495 | ptr = SSPOPPTR; |
496 | *(I16*)ptr = (I16)SSPOPINT; |
497 | break; |
a0d0e21e |
498 | case SAVEt_IV: /* IV reference */ |
499 | ptr = SSPOPPTR; |
500 | *(IV*)ptr = (IV)SSPOPIV; |
501 | break; |
79072805 |
502 | case SAVEt_SPTR: /* SV* reference */ |
503 | ptr = SSPOPPTR; |
504 | *(SV**)ptr = (SV*)SSPOPPTR; |
505 | break; |
85e6fe83 |
506 | case SAVEt_PPTR: /* char* reference */ |
507 | ptr = SSPOPPTR; |
508 | *(char**)ptr = (char*)SSPOPPTR; |
509 | break; |
79072805 |
510 | case SAVEt_HPTR: /* HV* reference */ |
511 | ptr = SSPOPPTR; |
512 | *(HV**)ptr = (HV*)SSPOPPTR; |
513 | break; |
514 | case SAVEt_APTR: /* AV* reference */ |
515 | ptr = SSPOPPTR; |
516 | *(AV**)ptr = (AV*)SSPOPPTR; |
517 | break; |
518 | case SAVEt_NSTAB: |
519 | gv = (GV*)SSPOPPTR; |
1f96a9ed |
520 | (void)sv_clear((SV*)gv); |
79072805 |
521 | break; |
522 | case SAVEt_GP: /* scalar reference */ |
523 | ptr = SSPOPPTR; |
524 | gv = (GV*)SSPOPPTR; |
525 | gp_free(gv); |
526 | GvGP(gv) = (GP*)ptr; |
4633a7c4 |
527 | SvREFCNT_dec(gv); |
79072805 |
528 | break; |
8990e307 |
529 | case SAVEt_FREESV: |
530 | ptr = SSPOPPTR; |
531 | SvREFCNT_dec((SV*)ptr); |
532 | break; |
533 | case SAVEt_FREEOP: |
534 | ptr = SSPOPPTR; |
535 | curpad = AvARRAY(comppad); |
536 | op_free((OP*)ptr); |
537 | break; |
538 | case SAVEt_FREEPV: |
539 | ptr = SSPOPPTR; |
540 | Safefree((char*)ptr); |
541 | break; |
542 | case SAVEt_CLEARSV: |
4aa0a1f7 |
543 | ptr = (void*)&curpad[SSPOPLONG]; |
8990e307 |
544 | sv = *(SV**)ptr; |
a0d0e21e |
545 | if (SvREFCNT(sv) <= 1) { /* Can clear pad variable in place. */ |
8990e307 |
546 | if (SvTHINKFIRST(sv)) { |
547 | if (SvREADONLY(sv)) |
548 | croak("panic: leave_scope clearsv"); |
549 | if (SvROK(sv)) |
550 | sv_unref(sv); |
551 | } |
a0d0e21e |
552 | if (SvMAGICAL(sv)) |
553 | mg_free(sv); |
8990e307 |
554 | |
555 | switch (SvTYPE(sv)) { |
556 | case SVt_NULL: |
557 | break; |
558 | case SVt_PVAV: |
5377b701 |
559 | if (AvMAX(sv) < (PADVAL_SMALL_ENOUGH / sizeof(SV*))) |
560 | av_clear((AV*)sv); |
561 | else |
562 | av_undef((AV*)sv); |
8990e307 |
563 | break; |
564 | case SVt_PVHV: |
5377b701 |
565 | if (HvMAX(sv) < (PADVAL_SMALL_ENOUGH / sizeof(SV*))) |
566 | hv_clear((HV*)sv); |
567 | else |
568 | hv_undef((HV*)sv); |
8990e307 |
569 | break; |
570 | case SVt_PVCV: |
5377b701 |
571 | croak("panic: leave_scope pad code"); |
572 | case SVt_RV: |
573 | case SVt_IV: |
574 | case SVt_NV: |
575 | (void)SvOK_off(sv); |
8990e307 |
576 | break; |
577 | default: |
a0d0e21e |
578 | (void)SvOK_off(sv); |
5377b701 |
579 | (void)SvOOK_off(sv); |
580 | if (SvPVX(sv) && SvLEN(sv) > PADVAL_SMALL_ENOUGH) { |
581 | Safefree(SvPVX(sv)); |
582 | SvPVX(sv) = Nullch; |
583 | SvLEN(sv) = 0; |
584 | SvCUR(sv) = 0; |
585 | } |
8990e307 |
586 | break; |
587 | } |
588 | } |
589 | else { /* Someone has a claim on this, so abandon it. */ |
4aa0a1f7 |
590 | U32 padflags = SvFLAGS(sv) & (SVs_PADBUSY|SVs_PADMY|SVs_PADTMP); |
8990e307 |
591 | SvREFCNT_dec(sv); /* Cast current value to the winds. */ |
592 | switch (SvTYPE(sv)) { /* Console ourselves with a new value */ |
593 | case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break; |
594 | case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break; |
595 | default: *(SV**)ptr = NEWSV(0,0); break; |
596 | } |
4aa0a1f7 |
597 | SvFLAGS(*(SV**)ptr) |= padflags; /* preserve pad nature */ |
8990e307 |
598 | } |
599 | break; |
600 | case SAVEt_DELETE: |
601 | ptr = SSPOPPTR; |
602 | hv = (HV*)ptr; |
603 | ptr = SSPOPPTR; |
748a9306 |
604 | (void)hv_delete(hv, (char*)ptr, (U32)SSPOPINT, G_DISCARD); |
adbc6bb1 |
605 | Safefree(ptr); |
8990e307 |
606 | break; |
a0d0e21e |
607 | case SAVEt_DESTRUCTOR: |
608 | ptr = SSPOPPTR; |
609 | (*SSPOPDPTR)(ptr); |
610 | break; |
611 | case SAVEt_REGCONTEXT: |
8e07c86e |
612 | { |
613 | I32 delta = SSPOPINT; |
614 | savestack_ix -= delta; /* regexp must have croaked */ |
615 | } |
a0d0e21e |
616 | break; |
55497cff |
617 | case SAVEt_STACK_POS: /* Position on Perl stack */ |
618 | { |
619 | I32 delta = SSPOPINT; |
620 | stack_sp = stack_base + delta; |
621 | } |
622 | break; |
79072805 |
623 | default: |
463ee0b2 |
624 | croak("panic: leave_scope inconsistency"); |
79072805 |
625 | } |
626 | } |
627 | } |
8990e307 |
628 | |
629 | #ifdef DEBUGGING |
1f96a9ed |
630 | |
8990e307 |
631 | void |
632 | cx_dump(cx) |
633 | CONTEXT* cx; |
634 | { |
760ac839 |
635 | PerlIO_printf(Perl_debug_log, "CX %d = %s\n", cx - cxstack, block_type[cx->cx_type]); |
8990e307 |
636 | if (cx->cx_type != CXt_SUBST) { |
760ac839 |
637 | PerlIO_printf(Perl_debug_log, "BLK_OLDSP = %ld\n", (long)cx->blk_oldsp); |
638 | PerlIO_printf(Perl_debug_log, "BLK_OLDCOP = 0x%lx\n", (long)cx->blk_oldcop); |
639 | PerlIO_printf(Perl_debug_log, "BLK_OLDMARKSP = %ld\n", (long)cx->blk_oldmarksp); |
640 | PerlIO_printf(Perl_debug_log, "BLK_OLDSCOPESP = %ld\n", (long)cx->blk_oldscopesp); |
641 | PerlIO_printf(Perl_debug_log, "BLK_OLDRETSP = %ld\n", (long)cx->blk_oldretsp); |
642 | PerlIO_printf(Perl_debug_log, "BLK_OLDPM = 0x%lx\n", (long)cx->blk_oldpm); |
643 | PerlIO_printf(Perl_debug_log, "BLK_GIMME = %s\n", cx->blk_gimme ? "LIST" : "SCALAR"); |
8990e307 |
644 | } |
645 | switch (cx->cx_type) { |
646 | case CXt_NULL: |
647 | case CXt_BLOCK: |
648 | break; |
649 | case CXt_SUB: |
760ac839 |
650 | PerlIO_printf(Perl_debug_log, "BLK_SUB.CV = 0x%lx\n", |
8990e307 |
651 | (long)cx->blk_sub.cv); |
760ac839 |
652 | PerlIO_printf(Perl_debug_log, "BLK_SUB.GV = 0x%lx\n", |
8990e307 |
653 | (long)cx->blk_sub.gv); |
760ac839 |
654 | PerlIO_printf(Perl_debug_log, "BLK_SUB.DFOUTGV = 0x%lx\n", |
8990e307 |
655 | (long)cx->blk_sub.dfoutgv); |
760ac839 |
656 | PerlIO_printf(Perl_debug_log, "BLK_SUB.OLDDEPTH = %ld\n", |
8990e307 |
657 | (long)cx->blk_sub.olddepth); |
760ac839 |
658 | PerlIO_printf(Perl_debug_log, "BLK_SUB.HASARGS = %d\n", |
8990e307 |
659 | (int)cx->blk_sub.hasargs); |
660 | break; |
661 | case CXt_EVAL: |
760ac839 |
662 | PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_IN_EVAL = %ld\n", |
8990e307 |
663 | (long)cx->blk_eval.old_in_eval); |
760ac839 |
664 | PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_OP_TYPE = %s (%s)\n", |
c07a80fd |
665 | op_name[cx->blk_eval.old_op_type], |
666 | op_desc[cx->blk_eval.old_op_type]); |
760ac839 |
667 | PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_NAME = %s\n", |
8990e307 |
668 | cx->blk_eval.old_name); |
760ac839 |
669 | PerlIO_printf(Perl_debug_log, "BLK_EVAL.OLD_EVAL_ROOT = 0x%lx\n", |
8990e307 |
670 | (long)cx->blk_eval.old_eval_root); |
671 | break; |
672 | |
673 | case CXt_LOOP: |
760ac839 |
674 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.LABEL = %s\n", |
8990e307 |
675 | cx->blk_loop.label); |
760ac839 |
676 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.RESETSP = %ld\n", |
8990e307 |
677 | (long)cx->blk_loop.resetsp); |
760ac839 |
678 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.REDO_OP = 0x%lx\n", |
8990e307 |
679 | (long)cx->blk_loop.redo_op); |
760ac839 |
680 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.NEXT_OP = 0x%lx\n", |
8990e307 |
681 | (long)cx->blk_loop.next_op); |
760ac839 |
682 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.LAST_OP = 0x%lx\n", |
8990e307 |
683 | (long)cx->blk_loop.last_op); |
760ac839 |
684 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERIX = %ld\n", |
8990e307 |
685 | (long)cx->blk_loop.iterix); |
760ac839 |
686 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERARY = 0x%lx\n", |
8990e307 |
687 | (long)cx->blk_loop.iterary); |
760ac839 |
688 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERVAR = 0x%lx\n", |
8990e307 |
689 | (long)cx->blk_loop.itervar); |
690 | if (cx->blk_loop.itervar) |
760ac839 |
691 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERSAVE = 0x%lx\n", |
8990e307 |
692 | (long)cx->blk_loop.itersave); |
7a4c00b4 |
693 | PerlIO_printf(Perl_debug_log, "BLK_LOOP.ITERLVAL = 0x%lx\n", |
694 | (long)cx->blk_loop.iterlval); |
8990e307 |
695 | break; |
696 | |
697 | case CXt_SUBST: |
760ac839 |
698 | PerlIO_printf(Perl_debug_log, "SB_ITERS = %ld\n", |
8990e307 |
699 | (long)cx->sb_iters); |
760ac839 |
700 | PerlIO_printf(Perl_debug_log, "SB_MAXITERS = %ld\n", |
8990e307 |
701 | (long)cx->sb_maxiters); |
760ac839 |
702 | PerlIO_printf(Perl_debug_log, "SB_SAFEBASE = %ld\n", |
8990e307 |
703 | (long)cx->sb_safebase); |
760ac839 |
704 | PerlIO_printf(Perl_debug_log, "SB_ONCE = %ld\n", |
8990e307 |
705 | (long)cx->sb_once); |
760ac839 |
706 | PerlIO_printf(Perl_debug_log, "SB_ORIG = %s\n", |
8990e307 |
707 | cx->sb_orig); |
760ac839 |
708 | PerlIO_printf(Perl_debug_log, "SB_DSTR = 0x%lx\n", |
8990e307 |
709 | (long)cx->sb_dstr); |
760ac839 |
710 | PerlIO_printf(Perl_debug_log, "SB_TARG = 0x%lx\n", |
8990e307 |
711 | (long)cx->sb_targ); |
760ac839 |
712 | PerlIO_printf(Perl_debug_log, "SB_S = 0x%lx\n", |
8990e307 |
713 | (long)cx->sb_s); |
760ac839 |
714 | PerlIO_printf(Perl_debug_log, "SB_M = 0x%lx\n", |
8990e307 |
715 | (long)cx->sb_m); |
760ac839 |
716 | PerlIO_printf(Perl_debug_log, "SB_STREND = 0x%lx\n", |
8990e307 |
717 | (long)cx->sb_strend); |
760ac839 |
718 | PerlIO_printf(Perl_debug_log, "SB_SUBBASE = 0x%lx\n", |
8990e307 |
719 | (long)cx->sb_subbase); |
720 | break; |
721 | } |
722 | } |
723 | #endif |