From 24c33697796a1556af3f58e15fc4fb6b0d1538dc Mon Sep 17 00:00:00 2001 From: "Paul \"LeoNerd\" Evans" Date: Sat, 4 Feb 2023 00:27:00 +0000 Subject: Create a specific SV type for object instances --- dump.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) (limited to 'dump.c') diff --git a/dump.c b/dump.c index 6209e1ac5b..62f41b4392 100644 --- a/dump.c +++ b/dump.c @@ -45,7 +45,8 @@ static const char* const svtypenames[SVt_LAST] = { "PVHV", "PVCV", "PVFM", - "PVIO" + "PVIO", + "PVOBJ", }; @@ -65,7 +66,8 @@ static const char* const svshorttypenames[SVt_LAST] = { "HV", "CV", "FM", - "IO" + "IO", + "OBJ", }; struct flag_to_name { @@ -2004,8 +2006,7 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo /* Dump general SV fields */ - if ((type >= SVt_PVIV && type != SVt_PVAV && type != SVt_PVHV - && type != SVt_PVCV && type != SVt_PVFM && type != SVt_PVIO + if ((type >= SVt_PVIV && type <= SVt_PVLV && type != SVt_REGEXP && !isGV_with_GP(sv) && !SvVALID(sv)) || (type == SVt_IV && !SvROK(sv))) { if (SvIsUV(sv) @@ -2016,9 +2017,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo (void)PerlIO_putc(file, '\n'); } - if ((type >= SVt_PVNV && type != SVt_PVAV && type != SVt_PVHV - && type != SVt_PVCV && type != SVt_PVFM && type != SVt_REGEXP - && type != SVt_PVIO && !isGV_with_GP(sv) && !SvVALID(sv)) + if ((type >= SVt_PVNV && type <= SVt_PVLV + && type != SVt_REGEXP && !isGV_with_GP(sv) && !SvVALID(sv)) || type == SVt_NV) { DECLARATION_FOR_LC_NUMERIC_MANIPULATION; STORE_LC_NUMERIC_SET_STANDARD(); @@ -2704,6 +2704,29 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo maxnest, dumpops, pvlim); } break; + case SVt_PVOBJ: + Perl_dump_indent(aTHX_ level, file, " MAXFIELD = %" IVdf "\n", + (IV)ObjectMAXFIELD(sv)); + Perl_dump_indent(aTHX_ level, file, " FIELDS = 0x%" UVxf "\n", + PTR2UV(ObjectFIELDS(sv))); + if (nest < maxnest && ObjectFIELDS(sv)) { + SSize_t count; + SV **svp = ObjectFIELDS(sv); + PADNAME **pname = PadnamelistARRAY(HvAUX(SvSTASH(sv))->xhv_class_fields); + for (count = 0; + count <= ObjectMAXFIELD(sv) && count < maxnest; + count++, svp++) + { + SV *const field = *svp; + PADNAME *pn = pname[count]; + + Perl_dump_indent(aTHX_ level + 1, file, "Field No. %" IVdf " (%s)\n", + (IV)count, PadnamePV(pn)); + + do_sv_dump(level+1, file, field, nest+1, maxnest, dumpops, pvlim); + } + } + break; } SvREFCNT_dec_NN(d); } -- cgit v1.2.1