The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

#include "EXTERN.h" #define PERL_IN_DUMP_C #include "perl.h" #include "regcomp.h"

static const char* const svtypenames[SVt_LAST] = { "NULL", "IV", "NV", "PV", "INVLIST", "PVIV", "PVNV", "PVMG", "REGEXP", "PVGV", "PVLV", "PVAV", "PVHV", "PVCV", "PVFM", "PVIO" };

static const char* const svshorttypenames[SVt_LAST] = { "UNDEF", "IV", "NV", "PV", "INVLST", "PVIV", "PVNV", "PVMG", "REGEXP", "GV", "PVLV", "AV", "HV", "CV", "FM", "IO" };

struct flag_to_name { U32 flag; const char *name; };

static void S_append_flags(pTHX_ SV *sv, U32 flags, const struct flag_to_name *start, const struct flag_to_name *const end) { do { if (flags & start->flag) sv_catpv(sv, start->name); } while (++start < end); }

#define append_flags(sv, f, flags) \ S_append_flags(aTHX_ (sv), (f), (flags), C_ARRAY_END(flags))

#define generic_pv_escape(sv,s,len,utf8) pv_escape( (sv), (s), (len), \ (len) * (4+UTF8_MAXBYTES) + 1, NULL, \ PERL_PV_ESCAPE_NONASCII | PERL_PV_ESCAPE_DWIM \ | ((utf8) ? PERL_PV_ESCAPE_UNI : 0) )

/* =for apidoc pv_escape

Escapes at most the first count chars of pv and puts the results into dsv such that the size of the escaped string will not exceed max chars and will not contain any incomplete escape sequences. The number of bytes escaped will be returned in the STRLEN *escaped parameter if it is not null. When the dsv parameter is null no escaping actually occurs, but the number of bytes that would be escaped were it not null will be calculated.

If flags contains PERL_PV_ESCAPE_QUOTE then any double quotes in the string will also be escaped.

Normally the SV will be cleared before the escaped string is prepared, but when PERL_PV_ESCAPE_NOCLEAR is set this will not occur.

If PERL_PV_ESCAPE_UNI is set then the input string is treated as UTF-8 if PERL_PV_ESCAPE_UNI_DETECT is set then the input string is scanned using is_utf8_string() to determine if it is UTF-8.

If PERL_PV_ESCAPE_ALL is set then all input chars will be output using \x01F1 style escapes, otherwise if PERL_PV_ESCAPE_NONASCII is set, only non-ASCII chars will be escaped using this style; otherwise, only chars above 255 will be so escaped; other non printable chars will use octal or common escaped patterns like \n. Otherwise, if PERL_PV_ESCAPE_NOBACKSLASH then all chars below 255 will be treated as printable and will be output as literals.

If PERL_PV_ESCAPE_FIRSTCHAR is set then only the first char of the string will be escaped, regardless of max. If the output is to be in hex, then it will be returned as a plain hex sequence. Thus the output will either be a single char, an octal escape sequence, a special escape like \n or a hex value.

If PERL_PV_ESCAPE_RE is set then the escape char used will be a "%" and not a "\\". This is because regexes very often contain backslashed sequences, whereas "%" is not a particularly common character in patterns.

Returns a pointer to the escaped text as held by dsv.

Converts a string into something presentable, handling escaping via pv_escape() and supporting quoting and ellipses.

If the PERL_PV_PRETTY_QUOTE flag is set then the result will be double quoted with any double quotes in the string escaped. Otherwise if the PERL_PV_PRETTY_LTGT flag is set then the result be wrapped in angle brackets.

If the PERL_PV_PRETTY_ELLIPSES flag is set and not all characters in string were output then an ellipsis ... will be appended to the string. Note that this happens AFTER it has been quoted.

If start_color is non-null then it will be inserted after the opening quote (if there is one) but before the escaped text. If end_color is non-null then it will be inserted after the escaped text but before any quotes or ellipses.

Returns a pointer to the prettified text as held by dsv.

Similar to

  pv_escape(dsv,pv,cur,pvlim,PERL_PV_ESCAPE_QUOTE);

except that an additional "\0" will be appended to the string when len > cur and pv[cur] is "\0".

Note that the final string may be up to 7 chars longer than pvlim.

Dumps the entire optree of the current program starting at PL_main_root to STDERR. Also dumps the optrees for all visible subroutines in PL_defstash.

Dumps the optrees for all visible subroutines in stash.

Dumps the optree starting at OP o to STDERR.

Dumps the contents of an SV to the STDERR filehandle.

For an example of its output, see Devel::Peek.

Given an op, determine what type of struct it has been allocated as. Returns one of the OPclass enums, such as OPclass_LISTOP.