summaryrefslogtreecommitdiff
path: root/dump.c
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2023-02-04 00:27:00 +0000
committerPaul "LeoNerd" Evans <leonerd@leonerd.org.uk>2023-02-10 12:07:02 +0000
commit24c33697796a1556af3f58e15fc4fb6b0d1538dc (patch)
treef747d7bdf730b423528f6d960db2465f9c708d4e /dump.c
parent99b497aa90ed7db99d29a301b47c91fba65c9cb3 (diff)
downloadperl-24c33697796a1556af3f58e15fc4fb6b0d1538dc.tar.gz
Create a specific SV type for object instances
Diffstat (limited to 'dump.c')
-rw-r--r--dump.c37
1 files changed, 30 insertions, 7 deletions
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);
}