return save_scalar_at(sptr);
}
-SV*
-Perl_save_svref(pTHX_ SV **sptr)
-{
- dVAR;
- SvGETMAGIC(*sptr);
- SSCHECK(3);
- SSPUSHPTR(sptr);
- SSPUSHPTR(SvREFCNT_inc(*sptr));
- SSPUSHINT(SAVEt_SVREF);
- return save_scalar_at(sptr);
-}
-
/* Like save_sptr(), but also SvREFCNT_dec()s the new value. Can be used to
* restore a global SV to its prior contents, freeing new value. */
void
}
void
-Perl_save_long(pTHX_ long int *longp)
-{
- dVAR;
- SSCHECK(3);
- SSPUSHLONG(*longp);
- SSPUSHPTR(longp);
- SSPUSHINT(SAVEt_LONG);
-}
-
-void
Perl_save_bool(pTHX_ bool *boolp)
{
dVAR;
SSPUSHINT(SAVEt_I32);
}
-void
-Perl_save_I16(pTHX_ I16 *intp)
-{
- dVAR;
- SSCHECK(3);
- SSPUSHINT(*intp);
- SSPUSHPTR(intp);
- SSPUSHINT(SAVEt_I16);
-}
-
-void
-Perl_save_I8(pTHX_ I8 *bytep)
-{
- dVAR;
- SSCHECK(3);
- SSPUSHINT(*bytep);
- SSPUSHPTR(bytep);
- SSPUSHINT(SAVEt_I8);
-}
-
-void
-Perl_save_iv(pTHX_ IV *ivp)
-{
- dVAR;
- SSCHECK(3);
- SSPUSHIV(*ivp);
- SSPUSHPTR(ivp);
- SSPUSHINT(SAVEt_IV);
-}
-
/* Cannot use save_sptr() to store a char* since the SV** cast will
* force word-alignment and we'll miss the pointer.
*/
}
void
-Perl_save_nogv(pTHX_ GV *gv)
-{
- dVAR;
- SSCHECK(2);
- SSPUSHPTR(gv);
- SSPUSHINT(SAVEt_NSTAB);
-}
-
-void
Perl_save_hptr(pTHX_ HV **hptr)
{
dVAR;
}
void
-Perl_save_list(pTHX_ register SV **sarg, I32 maxsarg)
-{
- dVAR;
- register I32 i;
-
- for (i = 1; i <= maxsarg; i++) {
- register SV * const sv = newSV(0);
- sv_setsv(sv,sarg[i]);
- SSCHECK(3);
- SSPUSHPTR(sarg[i]); /* remember the pointer */
- SSPUSHPTR(sv); /* remember the value */
- SSPUSHINT(SAVEt_ITEM);
- }
-}
-
-void
-Perl_save_destructor(pTHX_ DESTRUCTORFUNC_NOCONTEXT_t f, void* p)
-{
- dVAR;
- SSCHECK(3);
- SSPUSHDPTR(f);
- SSPUSHPTR(p);
- SSPUSHINT(SAVEt_DESTRUCTOR);
-}
-
-void
Perl_save_destructor_x(pTHX_ DESTRUCTORFUNC_t f, void* p)
{
dVAR;
sv_2mortal(sv);
}
+SV*
+Perl_save_svref(pTHX_ SV **sptr)
+{
+ dVAR;
+ SvGETMAGIC(*sptr);
+ SSCHECK(3);
+ SSPUSHPTR(sptr);
+ SSPUSHPTR(SvREFCNT_inc(*sptr));
+ SSPUSHINT(SAVEt_SVREF);
+ return save_scalar_at(sptr);
+}
+
void
Perl_save_op(pTHX)
{
gv = (GV*)SSPOPPTR;
ptr = &GvSV(gv);
av = (AV*)gv; /* what to refcnt_dec */
- goto restore_sv;
+ restore_sv:
+ sv = *(SV**)ptr;
+ DEBUG_S(PerlIO_printf(Perl_debug_log,
+ "restore svref: %p %p:%s -> %p:%s\n",
+ ptr, sv, SvPEEK(sv), value, SvPEEK(value)));
+ *(SV**)ptr = value;
+ SvREFCNT_dec(sv);
+ PL_localizing = 2;
+ SvSETMAGIC(value);
+ PL_localizing = 0;
+ SvREFCNT_dec(value);
+ if (av) /* actually an av, hv or gv */
+ SvREFCNT_dec(av);
+ break;
case SAVEt_GENERIC_PVREF: /* generic pv */
str = (char*)SSPOPPTR;
ptr = SSPOPPTR;
SvREFCNT_dec(sv);
SvREFCNT_dec(value);
break;
- case SAVEt_SVREF: /* scalar reference */
- value = (SV*)SSPOPPTR;
- ptr = SSPOPPTR;
- av = NULL; /* what to refcnt_dec */
- restore_sv:
- sv = *(SV**)ptr;
- DEBUG_S(PerlIO_printf(Perl_debug_log,
- "restore svref: %p %p:%s -> %p:%s\n",
- ptr, sv, SvPEEK(sv), value, SvPEEK(value)));
- *(SV**)ptr = value;
- SvREFCNT_dec(sv);
- PL_localizing = 2;
- SvSETMAGIC(value);
- PL_localizing = 0;
- SvREFCNT_dec(value);
- if (av) /* actually an av, hv or gv */
- SvREFCNT_dec(av);
- break;
case SAVEt_AV: /* array reference */
av = (AV*)SSPOPPTR;
gv = (GV*)SSPOPPTR;
ptr = SSPOPPTR;
*(int*)ptr = (int)SSPOPINT;
break;
- case SAVEt_LONG: /* long reference */
- ptr = SSPOPPTR;
- *(long*)ptr = (long)SSPOPLONG;
- break;
case SAVEt_BOOL: /* bool reference */
ptr = SSPOPPTR;
*(bool*)ptr = (bool)SSPOPBOOL;
ptr = SSPOPPTR;
*(I32*)ptr = (I32)SSPOPINT;
break;
- case SAVEt_I16: /* I16 reference */
- ptr = SSPOPPTR;
- *(I16*)ptr = (I16)SSPOPINT;
- break;
- case SAVEt_I8: /* I8 reference */
- ptr = SSPOPPTR;
- *(I8*)ptr = (I8)SSPOPINT;
- break;
- case SAVEt_IV: /* IV reference */
- ptr = SSPOPPTR;
- *(IV*)ptr = (IV)SSPOPIV;
- break;
case SAVEt_SPTR: /* SV* reference */
ptr = SSPOPPTR;
*(SV**)ptr = (SV*)SSPOPPTR;
ptr = SSPOPPTR;
*(AV**)ptr = (AV*)SSPOPPTR;
break;
- case SAVEt_NSTAB:
- gv = (GV*)SSPOPPTR;
- (void)sv_clear((SV*)gv);
- break;
case SAVEt_GP: /* scalar reference */
ptr = SSPOPPTR;
gv = (GV*)SSPOPPTR;
SvREFCNT_dec(hv);
Safefree(ptr);
break;
- case SAVEt_DESTRUCTOR:
- ptr = SSPOPPTR;
- (*SSPOPDPTR)(ptr);
- break;
case SAVEt_DESTRUCTOR_X:
ptr = SSPOPPTR;
(*SSPOPDXPTR)(aTHX_ ptr);
SvFLAGS(sv) |= val;
}
break;
+ /* These are only saved in mathoms.c */
+ case SAVEt_SVREF: /* scalar reference */
+ value = (SV*)SSPOPPTR;
+ ptr = SSPOPPTR;
+ av = NULL; /* what to refcnt_dec */
+ goto restore_sv;
+ case SAVEt_LONG: /* long reference */
+ ptr = SSPOPPTR;
+ *(long*)ptr = (long)SSPOPLONG;
+ break;
+ case SAVEt_I16: /* I16 reference */
+ ptr = SSPOPPTR;
+ *(I16*)ptr = (I16)SSPOPINT;
+ break;
+ case SAVEt_I8: /* I8 reference */
+ ptr = SSPOPPTR;
+ *(I8*)ptr = (I8)SSPOPINT;
+ break;
+ case SAVEt_IV: /* IV reference */
+ ptr = SSPOPPTR;
+ *(IV*)ptr = (IV)SSPOPIV;
+ break;
+ case SAVEt_NSTAB:
+ gv = (GV*)SSPOPPTR;
+ (void)sv_clear((SV*)gv);
+ break;
+ case SAVEt_DESTRUCTOR:
+ ptr = SSPOPPTR;
+ (*SSPOPDPTR)(ptr);
+ break;
default:
Perl_croak(aTHX_ "panic: leave_scope inconsistency");
}