+
+/* Like Perl_dump_indent(), but specifically for ops: adds a vertical bar
+ * for each indent level as appropriate.
+ *
+ * bar contains bits indicating which indent columns should have a
+ * vertical bar displayed. Bit 0 is the RH-most column. If there are more
+ * levels than bits in bar, then the first few indents are displayed
+ * without a bar.
+ *
+ * The start of a new op is signalled by passing a value for level which
+ * has been negated and offset by 1 (so that level 0 is passed as -1 and
+ * can thus be distinguished from -0); in this case, emit a suitably
+ * indented blank line, then on the next line, display the op's sequence
+ * number, and make the final indent an '+----'.
+ *
+ * e.g.
+ *
+ * | FOO # level = 1, bar = 0b1
+ * | | # level =-2-1, bar = 0b11
+ * 1234 | +---BAR
+ * | BAZ # level = 2, bar = 0b10
+ */
+
+static void
+S_opdump_indent(pTHX_ const OP *o, I32 level, UV bar, PerlIO *file,
+ const char* pat, ...)
+{
+ va_list args;
+ I32 i;
+ bool newop = (level < 0);
+
+ va_start(args, pat);
+
+ /* start displaying a new op? */
+ if (newop) {
+ UV seq = sequence_num(o);
+
+ level = -level - 1;
+
+ /* output preceding blank line */
+ PerlIO_puts(file, " ");
+ for (i = level-1; i >= 0; i--)
+ PerlIO_puts(file, ( i == 0
+ || (i < UVSIZE*8 && (bar & ((UV)1 << i)))
+ )
+ ? "| " : " ");
+ PerlIO_puts(file, "\n");
+
+ /* output sequence number */
+ if (seq)
+ PerlIO_printf(file, "%-4" UVuf " ", seq);
+ else
+ PerlIO_puts(file, "???? ");
+
+ }
+ else
+ PerlIO_printf(file, " ");
+
+ for (i = level-1; i >= 0; i--)
+ PerlIO_puts(file,
+ (i == 0 && newop) ? "+--"
+ : (bar & (1 << i)) ? "| "
+ : " ");
+ PerlIO_vprintf(file, pat, args);
+ va_end(args);
+}
+
+
+/* display a link field (e.g. op_next) in the format
+ * ====> sequence_number [opname 0x123456]
+ */
+
+static void
+S_opdump_link(pTHX_ const OP *base, const OP *o, PerlIO *file)
+{
+ PerlIO_puts(file, " ===> ");
+ if (o == base)
+ PerlIO_puts(file, "[SELF]\n");
+ else if (o)
+ PerlIO_printf(file, "%" UVuf " [%s 0x%" UVxf "]\n",
+ sequence_num(o), OP_NAME(o), PTR2UV(o));
+ else
+ PerlIO_puts(file, "[0x0]\n");
+}
+