FIT_ARENA(0, sizeof(struct ptr_tbl_ent))
},
+ /* RVs are in the head now. */
+ { 0, 0, 0, SVt_RV, FALSE, NONV, NOARENA, 0 },
+
/* 8 bytes on most ILP32 with IEEE doubles */
{ sizeof(NV), sizeof(NV), 0, SVt_NV, FALSE, HADNV, HASARENA,
FIT_ARENA(0, sizeof(NV)) },
- /* RVs are in the head now. */
- { 0, 0, 0, SVt_RV, FALSE, NONV, NOARENA, 0 },
-
/* 8 bytes on most ILP32 with IEEE doubles */
{ sizeof(xpv_allocated),
copy_length(XPV, xpv_len)
return;
case SVt_RV:
assert(old_type == SVt_NULL);
- SvANY(sv) = &sv->sv_u.svu_rv;
+ SvANY(sv) = (XPVIV*)((char*)&(sv->sv_u.svu_iv) - STRUCT_OFFSET(XPVIV, xiv_iv));
+ /* Could leave this in, but changing it happens to make the next step
+ clearler. The key part is that SvANY(sv) is not NULL:
+ SvANY(sv) = &sv->sv_u.svu_rv;
+ */
SvRV_set(sv, 0);
return;
case SVt_PVHV:
The target created by newSVrv also is, and it can have magic.
However, it never has SvPVX set.
*/
- if (old_type >= SVt_RV) {
+ if (old_type == SVt_RV || old_type >= SVt_PV) {
assert(SvPVX_const(sv) == 0);
}
if (new_type == SVt_PVIO)
IoPAGE_LEN(sv) = 60;
- if (old_type < SVt_RV)
+ if (old_type < SVt_RV || old_type == SVt_NV)
SvPV_set(sv, NULL);
break;
default:
goto undef_sstr;
case SVt_RV:
- if (dtype < SVt_RV)
+ if (dtype < SVt_PV && dtype != SVt_RV)
sv_upgrade(dstr, SVt_RV);
break;
case SVt_PVFM:
sv_upgrade(rv, SVt_RV);
} else if (SvROK(rv)) {
SvREFCNT_dec(SvRV(rv));
- } else if (SvTYPE(rv) < SVt_RV)
+ } else if (SvTYPE(rv) < SVt_RV || SvTYPE(rv) == SVt_NV)
sv_upgrade(rv, SVt_RV);
else if (SvTYPE(rv) > SVt_RV) {
SvPV_free(rv);
SVt_NULL, /* 0 */
SVt_BIND, /* 1 */
SVt_IV, /* 2 */
- SVt_NV, /* 3 */
- SVt_RV, /* 4 */
+ SVt_RV, /* 3 */
+ SVt_NV, /* 4 */
SVt_PV, /* 5 */
SVt_PVIV, /* 6 */
SVt_PVNV, /* 7 */
}))
# define SvRV(sv) \
(*({ SV *const _svi = (SV *) (sv); \
- assert(SvTYPE(_svi) >= SVt_RV); \
+ assert(SvTYPE(_svi) >= SVt_PV || SvTYPE(_svi) == SVt_RV); \
assert(SvTYPE(_svi) != SVt_PVAV); \
assert(SvTYPE(_svi) != SVt_PVHV); \
assert(SvTYPE(_svi) != SVt_PVCV); \
assert(!isGV_with_GP(sv)); \
(((XPVUV*)SvANY(sv))->xuv_uv = (val)); } STMT_END
#define SvRV_set(sv, val) \
- STMT_START { assert(SvTYPE(sv) >= SVt_RV); \
+ STMT_START { assert(SvTYPE(sv) >= SVt_PV || SvTYPE(sv) == SVt_RV); \
assert(SvTYPE(sv) != SVt_PVAV); \
assert(SvTYPE(sv) != SVt_PVHV); \
assert(SvTYPE(sv) != SVt_PVCV); \