Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / man / man3 / B::Concise.3
CommitLineData
920dae64
AT
1.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2.\"
3.\" Standard preamble:
4.\" ========================================================================
5.de Sh \" Subsection heading
6.br
7.if t .Sp
8.ne 5
9.PP
10\fB\\$1\fR
11.PP
12..
13.de Sp \" Vertical space (when we can't use .PP)
14.if t .sp .5v
15.if n .sp
16..
17.de Vb \" Begin verbatim text
18.ft CW
19.nf
20.ne \\$1
21..
22.de Ve \" End verbatim text
23.ft R
24.fi
25..
26.\" Set up some character translations and predefined strings. \*(-- will
27.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28.\" double quote, and \*(R" will give a right double quote. | will give a
29.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
30.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
31.\" expand to `' in nroff, nothing in troff, for use with C<>.
32.tr \(*W-|\(bv\*(Tr
33.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34.ie n \{\
35. ds -- \(*W-
36. ds PI pi
37. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
39. ds L" ""
40. ds R" ""
41. ds C` ""
42. ds C' ""
43'br\}
44.el\{\
45. ds -- \|\(em\|
46. ds PI \(*p
47. ds L" ``
48. ds R" ''
49'br\}
50.\"
51.\" If the F register is turned on, we'll generate index entries on stderr for
52.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53.\" entries marked with X<> in POD. Of course, you'll have to process the
54.\" output yourself in some meaningful fashion.
55.if \nF \{\
56. de IX
57. tm Index:\\$1\t\\n%\t"\\$2"
58..
59. nr % 0
60. rr F
61.\}
62.\"
63.\" For nroff, turn off justification. Always turn off hyphenation; it makes
64.\" way too many mistakes in technical documents.
65.hy 0
66.if n .na
67.\"
68.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69.\" Fear. Run. Save yourself. No user-serviceable parts.
70. \" fudge factors for nroff and troff
71.if n \{\
72. ds #H 0
73. ds #V .8m
74. ds #F .3m
75. ds #[ \f1
76. ds #] \fP
77.\}
78.if t \{\
79. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80. ds #V .6m
81. ds #F 0
82. ds #[ \&
83. ds #] \&
84.\}
85. \" simple accents for nroff and troff
86.if n \{\
87. ds ' \&
88. ds ` \&
89. ds ^ \&
90. ds , \&
91. ds ~ ~
92. ds /
93.\}
94.if t \{\
95. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101.\}
102. \" troff and (daisy-wheel) nroff accents
103.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110.ds ae a\h'-(\w'a'u*4/10)'e
111.ds Ae A\h'-(\w'A'u*4/10)'E
112. \" corrections for vroff
113.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115. \" for low resolution devices (crt and lpr)
116.if \n(.H>23 .if \n(.V>19 \
117\{\
118. ds : e
119. ds 8 ss
120. ds o a
121. ds d- d\h'-1'\(ga
122. ds D- D\h'-1'\(hy
123. ds th \o'bp'
124. ds Th \o'LP'
125. ds ae ae
126. ds Ae AE
127.\}
128.rm #[ #] #H #V #F C
129.\" ========================================================================
130.\"
131.IX Title "B::Concise 3"
132.TH B::Concise 3 "2001-09-21" "perl v5.8.8" "Perl Programmers Reference Guide"
133.SH "NAME"
134B::Concise \- Walk Perl syntax tree, printing concise info about ops
135.SH "SYNOPSIS"
136.IX Header "SYNOPSIS"
137.Vb 1
138\& perl -MO=Concise[,OPTIONS] foo.pl
139.Ve
140.PP
141.Vb 1
142\& use B::Concise qw(set_style add_callback);
143.Ve
144.SH "DESCRIPTION"
145.IX Header "DESCRIPTION"
146This compiler backend prints the internal OPs of a Perl program's syntax
147tree in one of several space-efficient text formats suitable for debugging
148the inner workings of perl or other compiler backends. It can print OPs in
149the order they appear in the \s-1OP\s0 tree, in the order they will execute, or
150in a text approximation to their tree structure, and the format of the
151information displayed is customizable. Its function is similar to that of
152perl's \fB\-Dx\fR debugging flag or the \fBB::Terse\fR module, but it is more
153sophisticated and flexible.
154.SH "EXAMPLE"
155.IX Header "EXAMPLE"
156Here's an example of 2 outputs (aka 'renderings'), using the
157\&\-exec and \-basic (i.e. default) formatting conventions on the same code
158snippet.
159.PP
160.Vb 9
161\& % perl -MO=Concise,-exec -e '$a = $b + 42'
162\& 1 <0> enter
163\& 2 <;> nextstate(main 1 -e:1) v
164\& 3 <#> gvsv[*b] s
165\& 4 <$> const[IV 42] s
166\& * 5 <2> add[t3] sK/2
167\& 6 <#> gvsv[*a] s
168\& 7 <2> sassign vKS/2
169\& 8 <@> leave[1 ref] vKP/REFC
170.Ve
171.PP
172Each line corresponds to an opcode. The opcode marked with '*' is used
173in a few examples below.
174.PP
175The 1st column is the op's sequence number, starting at 1, and is
176displayed in base 36 by default. This rendering is in \-exec (i.e.
177execution) order.
178.PP
179The symbol between angle brackets indicates the op's type, for
180example; <2> is a \s-1BINOP\s0, <@> a \s-1LISTOP\s0, and <#> is a \s-1PADOP\s0, which is
181used in threaded perls. (see \*(L"\s-1OP\s0 class abbreviations\*(R").
182.PP
183The opname, as in \fB'add[t1]'\fR, which may be followed by op-specific
184information in parentheses or brackets (ex \fB'[t1]'\fR).
185.PP
186The op-flags (ex \fB'sK/2'\fR) follow, and are described in (\*(L"\s-1OP\s0 flags abbreviations\*(R").
187.PP
188.Vb 11
189\& % perl -MO=Concise -e '$a = $b + 42'
190\& 8 <@> leave[1 ref] vKP/REFC ->(end)
191\& 1 <0> enter ->2
192\& 2 <;> nextstate(main 1 -e:1) v ->3
193\& 7 <2> sassign vKS/2 ->8
194\& * 5 <2> add[t1] sK/2 ->6
195\& - <1> ex-rv2sv sK/1 ->4
196\& 3 <$> gvsv(*b) s ->4
197\& 4 <$> const(IV 42) s ->5
198\& - <1> ex-rv2sv sKRM*/1 ->7
199\& 6 <$> gvsv(*a) s ->7
200.Ve
201.PP
202The default rendering is top\-down, so they're not in execution order.
203This form reflects the way the stack is used to parse and evaluate
204expressions; the add operates on the two terms below it in the tree.
205.PP
206Nullops appear as \f(CW\*(C`ex\-opname\*(C'\fR, where \fIopname\fR is an op that has been
207optimized away by perl. They're displayed with a sequence-number of
208\&'\-', because they are not executed (they don't appear in previous
209example), they're printed here because they reflect the parse.
210.PP
211The arrow points to the sequence number of the next op; they're not
212displayed in \-exec mode, for obvious reasons.
213.PP
214Note that because this rendering was done on a non-threaded perl, the
215PADOPs in the previous examples are now SVOPs, and some (but not all)
216of the square brackets have been replaced by round ones. This is a
217subtle feature to provide some visual distinction between renderings
218on threaded and un-threaded perls.
219.SH "OPTIONS"
220.IX Header "OPTIONS"
221Arguments that don't start with a hyphen are taken to be the names of
222subroutines to print the OPs of; if no such functions are specified,
223the main body of the program (outside any subroutines, and not
224including use'd or require'd files) is rendered. Passing \f(CW\*(C`BEGIN\*(C'\fR,
225\&\f(CW\*(C`CHECK\*(C'\fR, \f(CW\*(C`INIT\*(C'\fR, or \f(CW\*(C`END\*(C'\fR will cause all of the corresponding
226special blocks to be printed.
227.PP
228Options affect how things are rendered (ie printed). They're presented
229here by their visual effect, 1st being strongest. They're grouped
230according to how they interrelate; within each group the options are
231mutually exclusive (unless otherwise stated).
232.Sh "Options for Opcode Ordering"
233.IX Subsection "Options for Opcode Ordering"
234These options control the 'vertical display' of opcodes. The display
235\&'order' is also called 'mode' elsewhere in this document.
236.IP "\fB\-basic\fR" 4
237.IX Item "-basic"
238Print OPs in the order they appear in the \s-1OP\s0 tree (a preorder
239traversal, starting at the root). The indentation of each \s-1OP\s0 shows its
240level in the tree, and the '\->' at the end of the line indicates the
241next opcode in execution order. This mode is the default, so the flag
242is included simply for completeness.
243.IP "\fB\-exec\fR" 4
244.IX Item "-exec"
245Print OPs in the order they would normally execute (for the majority
246of constructs this is a postorder traversal of the tree, ending at the
247root). In most cases the \s-1OP\s0 that usually follows a given \s-1OP\s0 will
248appear directly below it; alternate paths are shown by indentation. In
249cases like loops when control jumps out of a linear path, a 'goto'
250line is generated.
251.IP "\fB\-tree\fR" 4
252.IX Item "-tree"
253Print OPs in a text approximation of a tree, with the root of the tree
254at the left and 'left\-to\-right' order of children transformed into
255\&'top\-to\-bottom'. Because this mode grows both to the right and down,
256it isn't suitable for large programs (unless you have a very wide
257terminal).
258.Sh "Options for Line-Style"
259.IX Subsection "Options for Line-Style"
260These options select the line-style (or just style) used to render
261each opcode, and dictates what info is actually printed into each line.
262.IP "\fB\-concise\fR" 4
263.IX Item "-concise"
264Use the author's favorite set of formatting conventions. This is the
265default, of course.
266.IP "\fB\-terse\fR" 4
267.IX Item "-terse"
268Use formatting conventions that emulate the output of \fBB::Terse\fR. The
269basic mode is almost indistinguishable from the real \fBB::Terse\fR, and the
270exec mode looks very similar, but is in a more logical order and lacks
271curly brackets. \fBB::Terse\fR doesn't have a tree mode, so the tree mode
272is only vaguely reminiscent of \fBB::Terse\fR.
273.IP "\fB\-linenoise\fR" 4
274.IX Item "-linenoise"
275Use formatting conventions in which the name of each \s-1OP\s0, rather than being
276written out in full, is represented by a one\- or two-character abbreviation.
277This is mainly a joke.
278.IP "\fB\-debug\fR" 4
279.IX Item "-debug"
280Use formatting conventions reminiscent of \fBB::Debug\fR; these aren't
281very concise at all.
282.IP "\fB\-env\fR" 4
283.IX Item "-env"
284Use formatting conventions read from the environment variables
285\&\f(CW\*(C`B_CONCISE_FORMAT\*(C'\fR, \f(CW\*(C`B_CONCISE_GOTO_FORMAT\*(C'\fR, and \f(CW\*(C`B_CONCISE_TREE_FORMAT\*(C'\fR.
286.Sh "Options for tree-specific formatting"
287.IX Subsection "Options for tree-specific formatting"
288.IP "\fB\-compact\fR" 4
289.IX Item "-compact"
290Use a tree format in which the minimum amount of space is used for the
291lines connecting nodes (one character in most cases). This squeezes out
292a few precious columns of screen real estate.
293.IP "\fB\-loose\fR" 4
294.IX Item "-loose"
295Use a tree format that uses longer edges to separate \s-1OP\s0 nodes. This format
296tends to look better than the compact one, especially in \s-1ASCII\s0, and is
297the default.
298.IP "\fB\-vt\fR" 4
299.IX Item "-vt"
300Use tree connecting characters drawn from the \s-1VT100\s0 line-drawing set.
301This looks better if your terminal supports it.
302.IP "\fB\-ascii\fR" 4
303.IX Item "-ascii"
304Draw the tree with standard \s-1ASCII\s0 characters like \f(CW\*(C`+\*(C'\fR and \f(CW\*(C`|\*(C'\fR. These don't
305look as clean as the \s-1VT100\s0 characters, but they'll work with almost any
306terminal (or the horizontal scrolling mode of \fIless\fR\|(1)) and are suitable
307for text documentation or email. This is the default.
308.PP
309These are pairwise exclusive, i.e. compact or loose, vt or ascii.
310.Sh "Options controlling sequence numbering"
311.IX Subsection "Options controlling sequence numbering"
312.IP "\fB\-base\fR\fIn\fR" 4
313.IX Item "-basen"
314Print \s-1OP\s0 sequence numbers in base \fIn\fR. If \fIn\fR is greater than 10, the
315digit for 11 will be 'a', and so on. If \fIn\fR is greater than 36, the digit
316for 37 will be 'A', and so on until 62. Values greater than 62 are not
317currently supported. The default is 36.
318.IP "\fB\-bigendian\fR" 4
319.IX Item "-bigendian"
320Print sequence numbers with the most significant digit first. This is the
321usual convention for Arabic numerals, and the default.
322.IP "\fB\-littleendian\fR" 4
323.IX Item "-littleendian"
324Print seqence numbers with the least significant digit first. This is
325obviously mutually exclusive with bigendian.
326.Sh "Other options"
327.IX Subsection "Other options"
328These are pairwise exclusive.
329.IP "\fB\-main\fR" 4
330.IX Item "-main"
331Include the main program in the output, even if subroutines were also
332specified. This rendering is normally suppressed when a subroutine
333name or reference is given.
334.IP "\fB\-nomain\fR" 4
335.IX Item "-nomain"
336This restores the default behavior after you've changed it with '\-main'
337(it's not normally needed). If no subroutine name/ref is given, main is
338rendered, regardless of this flag.
339.IP "\fB\-nobanner\fR" 4
340.IX Item "-nobanner"
341Renderings usually include a banner line identifying the function name
342or stringified subref. This suppresses the printing of the banner.
343.Sp
344\&\s-1TBC:\s0 Remove the stringified coderef; while it provides a 'cookie' for
345each function rendered, the cookies used should be 1,2,3.. not a
346random hex\-address. It also complicates string comparison of two
347different trees.
348.IP "\fB\-banner\fR" 4
349.IX Item "-banner"
350restores default banner behavior.
351.IP "\fB\-banneris\fR => subref" 4
352.IX Item "-banneris => subref"
353\&\s-1TBC:\s0 a hookpoint (and an option to set it) for a user-supplied
354function to produce a banner appropriate for users needs. It's not
355ideal, because the rendering-state variables, which are a natural
356candidate for use in concise.t, are unavailable to the user.
357.Sh "Option Stickiness"
358.IX Subsection "Option Stickiness"
359If you invoke Concise more than once in a program, you should know that
360the options are 'sticky'. This means that the options you provide in
361the first call will be remembered for the 2nd call, unless you
362re-specify or change them.
363.SH "ABBREVIATIONS"
364.IX Header "ABBREVIATIONS"
365The concise style uses symbols to convey maximum info with minimal
366clutter (like hex addresses). With just a little practice, you can
367start to see the flowers, not just the branches, in the trees.
368.Sh "\s-1OP\s0 class abbreviations"
369.IX Subsection "OP class abbreviations"
370These symbols appear before the op\-name, and indicate the
371B:: namespace that represents the ops in your Perl code.
372.PP
373.Vb 11
374\& 0 OP (aka BASEOP) An OP with no children
375\& 1 UNOP An OP with one child
376\& 2 BINOP An OP with two children
377\& | LOGOP A control branch OP
378\& @ LISTOP An OP that could have lots of children
379\& / PMOP An OP with a regular expression
380\& $ SVOP An OP with an SV
381\& " PVOP An OP with a string
382\& { LOOP An OP that holds pointers for a loop
383\& ; COP An OP that marks the start of a statement
384\& # PADOP An OP with a GV on the pad
385.Ve
386.Sh "\s-1OP\s0 flags abbreviations"
387.IX Subsection "OP flags abbreviations"
388\&\s-1OP\s0 flags are either public or private. The public flags alter the
389behavior of each opcode in consistent ways, and are represented by 0
390or more single characters.
391.PP
392.Vb 12
393\& v OPf_WANT_VOID Want nothing (void context)
394\& s OPf_WANT_SCALAR Want single value (scalar context)
395\& l OPf_WANT_LIST Want list of any length (list context)
396\& Want is unknown
397\& K OPf_KIDS There is a firstborn child.
398\& P OPf_PARENS This operator was parenthesized.
399\& (Or block needs explicit scope entry.)
400\& R OPf_REF Certified reference.
401\& (Return container, not containee).
402\& M OPf_MOD Will modify (lvalue).
403\& S OPf_STACKED Some arg is arriving on the stack.
404\& * OPf_SPECIAL Do something weird for this op (see op.h)
405.Ve
406.PP
407Private flags, if any are set for an opcode, are displayed after a '/'
408.PP
409.Vb 2
410\& 8 <@> leave[1 ref] vKP/REFC ->(end)
411\& 7 <2> sassign vKS/2 ->8
412.Ve
413.PP
414They're opcode specific, and occur less often than the public ones, so
415they're represented by short mnemonics instead of single\-chars; see
416\&\fIop.h\fR for gory details, or try this quick 2\-liner:
417.PP
418.Vb 2
419\& $> perl -MB::Concise -de 1
420\& DB<1> |x \e%B::Concise::priv
421.Ve
422.SH "FORMATTING SPECIFICATIONS"
423.IX Header "FORMATTING SPECIFICATIONS"
424For each line-style ('concise', 'terse', 'linenoise', etc.) there are
4253 format-specs which control how OPs are rendered.
426.PP
427The first is the 'default' format, which is used in both basic and exec
428modes to print all opcodes. The 2nd, goto\-format, is used in exec
429mode when branches are encountered. They're not real opcodes, and are
430inserted to look like a closing curly brace. The tree-format is tree
431specific.
432.PP
433When a line is rendered, the correct format-spec is copied and scanned
434for the following items; data is substituted in, and other
435manipulations like basic indenting are done, for each opcode rendered.
436.PP
437There are 3 kinds of items that may be populated; special patterns,
438#vars, and literal text, which is copied verbatim. (Yes, it's a set
439of s///g steps.)
440.Sh "Special Patterns"
441.IX Subsection "Special Patterns"
442These items are the primitives used to perform indenting, and to
443select text from amongst alternatives.
444.IP "\fB(x(\fR\fIexec_text\fR\fB;\fR\fIbasic_text\fR\fB)x)\fR" 4
445.IX Item "(x(exec_text;basic_text)x)"
446Generates \fIexec_text\fR in exec mode, or \fIbasic_text\fR in basic mode.
447.IP "\fB(*(\fR\fItext\fR\fB)*)\fR" 4
448.IX Item "(*(text)*)"
449Generates one copy of \fItext\fR for each indentation level.
450.IP "\fB(*(\fR\fItext1\fR\fB;\fR\fItext2\fR\fB)*)\fR" 4
451.IX Item "(*(text1;text2)*)"
452Generates one fewer copies of \fItext1\fR than the indentation level, followed
453by one copy of \fItext2\fR if the indentation level is more than 0.
454.IP "\fB(?(\fR\fItext1\fR\fB#\fR\fIvar\fR\fIText2\fR\fB)?)\fR" 4
455.IX Item "(?(text1#varText2)?)"
456If the value of \fIvar\fR is true (not empty or zero), generates the
457value of \fIvar\fR surrounded by \fItext1\fR and \fIText2\fR, otherwise
458nothing.
459.IP "\fB~\fR" 4
460.IX Item "~"
461Any number of tildes and surrounding whitespace will be collapsed to
462a single space.
463.Sh "# Variables"
464.IX Subsection "# Variables"
465These #vars represent opcode properties that you may want as part of
466your rendering. The '#' is intended as a private sigil; a #var's
467value is interpolated into the style\-line, much like \*(L"read \f(CW$this\fR\*(R".
468.PP
469These vars take 3 forms:
470.IP "\fB#\fR\fIvar\fR" 4
471.IX Item "#var"
472A property named 'var' is assumed to exist for the opcodes, and is
473interpolated into the rendering.
474.IP "\fB#\fR\fIvar\fR\fIN\fR" 4
475.IX Item "#varN"
476Generates the value of \fIvar\fR, left justified to fill \fIN\fR spaces.
477Note that this means while you can have properties 'foo' and 'foo2',
478you cannot render 'foo2', but you could with 'foo2a'. You would be
479wise not to rely on this behavior going forward ;\-)
480.IP "\fB#\fR\fIVar\fR" 4
481.IX Item "#Var"
482This ucfirst form of #var generates a tag-value form of itself for
483display; it converts '#Var' into a 'Var => #var' style, which is then
484handled as described above. (Imp\-note: #Vars cannot be used for
485conditional\-fills, because the => #var transform is done after the check
486for #Var's value).
487.PP
488The following variables are 'defined' by B::Concise; when they are
489used in a style, their respective values are plugged into the
490rendering of each opcode.
491.PP
492Only some of these are used by the standard styles, the others are
493provided for you to delve into optree mechanics, should you wish to
494add a new style (see \*(L"add_style\*(R" below) that uses them. You can
495also add new ones using \*(L"add_callback\*(R".
496.IP "\fB#addr\fR" 4
497.IX Item "#addr"
498The address of the \s-1OP\s0, in hexadecimal.
499.IP "\fB#arg\fR" 4
500.IX Item "#arg"
501The OP-specific information of the \s-1OP\s0 (such as the \s-1SV\s0 for an \s-1SVOP\s0, the
502non-local exit pointers for a \s-1LOOP\s0, etc.) enclosed in parentheses.
503.IP "\fB#class\fR" 4
504.IX Item "#class"
505The B\-determined class of the \s-1OP\s0, in all caps.
506.IP "\fB#classsym\fR" 4
507.IX Item "#classsym"
508A single symbol abbreviating the class of the \s-1OP\s0.
509.IP "\fB#coplabel\fR" 4
510.IX Item "#coplabel"
511The label of the statement or block the \s-1OP\s0 is the start of, if any.
512.IP "\fB#exname\fR" 4
513.IX Item "#exname"
514The name of the \s-1OP\s0, or 'ex\-foo' if the \s-1OP\s0 is a null that used to be a foo.
515.IP "\fB#extarg\fR" 4
516.IX Item "#extarg"
517The target of the \s-1OP\s0, or nothing for a nulled \s-1OP\s0.
518.IP "\fB#firstaddr\fR" 4
519.IX Item "#firstaddr"
520The address of the \s-1OP\s0's first child, in hexadecimal.
521.IP "\fB#flags\fR" 4
522.IX Item "#flags"
523The \s-1OP\s0's flags, abbreviated as a series of symbols.
524.IP "\fB#flagval\fR" 4
525.IX Item "#flagval"
526The numeric value of the \s-1OP\s0's flags.
527.IP "\fB#hyphseq\fR" 4
528.IX Item "#hyphseq"
529The sequence number of the \s-1OP\s0, or a hyphen if it doesn't have one.
530.IP "\fB#label\fR" 4
531.IX Item "#label"
532\&'\s-1NEXT\s0', '\s-1LAST\s0', or '\s-1REDO\s0' if the \s-1OP\s0 is a target of one of those in exec
533mode, or empty otherwise.
534.IP "\fB#lastaddr\fR" 4
535.IX Item "#lastaddr"
536The address of the \s-1OP\s0's last child, in hexadecimal.
537.IP "\fB#name\fR" 4
538.IX Item "#name"
539The \s-1OP\s0's name.
540.IP "\fB#NAME\fR" 4
541.IX Item "#NAME"
542The \s-1OP\s0's name, in all caps.
543.IP "\fB#next\fR" 4
544.IX Item "#next"
545The sequence number of the \s-1OP\s0's next \s-1OP\s0.
546.IP "\fB#nextaddr\fR" 4
547.IX Item "#nextaddr"
548The address of the \s-1OP\s0's next \s-1OP\s0, in hexadecimal.
549.IP "\fB#noise\fR" 4
550.IX Item "#noise"
551A one\- or two-character abbreviation for the \s-1OP\s0's name.
552.IP "\fB#private\fR" 4
553.IX Item "#private"
554The \s-1OP\s0's private flags, rendered with abbreviated names if possible.
555.IP "\fB#privval\fR" 4
556.IX Item "#privval"
557The numeric value of the \s-1OP\s0's private flags.
558.IP "\fB#seq\fR" 4
559.IX Item "#seq"
560The sequence number of the \s-1OP\s0. Note that this is a sequence number
561generated by B::Concise.
562.IP "\fB#seqnum\fR" 4
563.IX Item "#seqnum"
5645.8.x and earlier only. 5.9 and later do not provide this.
565.Sp
566The real sequence number of the \s-1OP\s0, as a regular number and not adjusted
567to be relative to the start of the real program. (This will generally be
568a fairly large number because all of \fBB::Concise\fR is compiled before
569your program is).
570.IP "\fB#opt\fR" 4
571.IX Item "#opt"
572Whether or not the op has been optimised by the peephole optimiser.
573.Sp
574Only available in 5.9 and later.
575.IP "\fB#static\fR" 4
576.IX Item "#static"
577Whether or not the op is statically defined. This flag is used by the
578B::C compiler backend and indicates that the op should not be freed.
579.Sp
580Only available in 5.9 and later.
581.IP "\fB#sibaddr\fR" 4
582.IX Item "#sibaddr"
583The address of the \s-1OP\s0's next youngest sibling, in hexadecimal.
584.IP "\fB#svaddr\fR" 4
585.IX Item "#svaddr"
586The address of the \s-1OP\s0's \s-1SV\s0, if it has an \s-1SV\s0, in hexadecimal.
587.IP "\fB#svclass\fR" 4
588.IX Item "#svclass"
589The class of the \s-1OP\s0's \s-1SV\s0, if it has one, in all caps (e.g., '\s-1IV\s0').
590.IP "\fB#svval\fR" 4
591.IX Item "#svval"
592The value of the \s-1OP\s0's \s-1SV\s0, if it has one, in a short human-readable format.
593.IP "\fB#targ\fR" 4
594.IX Item "#targ"
595The numeric value of the \s-1OP\s0's targ.
596.IP "\fB#targarg\fR" 4
597.IX Item "#targarg"
598The name of the variable the \s-1OP\s0's targ refers to, if any, otherwise the
599letter t followed by the \s-1OP\s0's targ in decimal.
600.IP "\fB#targarglife\fR" 4
601.IX Item "#targarglife"
602Same as \fB#targarg\fR, but followed by the \s-1COP\s0 sequence numbers that delimit
603the variable's lifetime (or 'end' for a variable in an open scope) for a
604variable.
605.IP "\fB#typenum\fR" 4
606.IX Item "#typenum"
607The numeric value of the \s-1OP\s0's type, in decimal.
608.SH "Using B::Concise outside of the O framework"
609.IX Header "Using B::Concise outside of the O framework"
610The common (and original) usage of B::Concise was for command-line
611renderings of simple code, as given in \s-1EXAMPLE\s0. But you can also use
612\&\fBB::Concise\fR from your code, and call \fIcompile()\fR directly, and
613repeatedly. By doing so, you can avoid the compile-time only
614operation of O.pm, and even use the debugger to step through
615\&\fIB::Concise::compile()\fR itself.
616.PP
617Once you're doing this, you may alter Concise output by adding new
618rendering styles, and by optionally adding callback routines which
619populate new variables, if such were referenced from those (just
620added) styles.
621.Sh "Example: Altering Concise Renderings"
622.IX Subsection "Example: Altering Concise Renderings"
623.Vb 9
624\& use B::Concise qw(set_style add_callback);
625\& add_style($yourStyleName => $defaultfmt, $gotofmt, $treefmt);
626\& add_callback
627\& ( sub {
628\& my ($h, $op, $format, $level, $stylename) = @_;
629\& $h->{variable} = some_func($op);
630\& });
631\& $walker = B::Concise::compile(@options,@subnames,@subrefs);
632\& $walker->();
633.Ve
634.Sh "\fIset_style()\fP"
635.IX Subsection "set_style()"
636\&\fBset_style\fR accepts 3 arguments, and updates the three format-specs
637comprising a line-style (basic\-exec, goto, tree). It has one minor
638drawback though; it doesn't register the style under a new name. This
639can become an issue if you render more than once and switch styles.
640Thus you may prefer to use \fIadd_style()\fR and/or \fIset_style_standard()\fR
641instead.
642.Sh "set_style_standard($name)"
643.IX Subsection "set_style_standard($name)"
644This restores one of the standard line\-styles: \f(CW\*(C`terse\*(C'\fR, \f(CW\*(C`concise\*(C'\fR,
645\&\f(CW\*(C`linenoise\*(C'\fR, \f(CW\*(C`debug\*(C'\fR, \f(CW\*(C`env\*(C'\fR, into effect. It also accepts style
646names previously defined with \fIadd_style()\fR.
647.Sh "\fIadd_style()\fP"
648.IX Subsection "add_style()"
649This subroutine accepts a new style name and three style arguments as
650above, and creates, registers, and selects the newly named style. It is
651an error to re-add a style; call \fIset_style_standard()\fR to switch between
652several styles.
653.Sh "\fIadd_callback()\fP"
654.IX Subsection "add_callback()"
655If your newly minted styles refer to any new #variables, you'll need
656to define a callback subroutine that will populate (or modify) those
657variables. They are then available for use in the style you've
658chosen.
659.PP
660The callbacks are called for each opcode visited by Concise, in the
661same order as they are added. Each subroutine is passed five
662parameters.
663.PP
664.Vb 6
665\& 1. A hashref, containing the variable names and values which are
666\& populated into the report-line for the op
667\& 2. the op, as a B<B::OP> object
668\& 3. a reference to the format string
669\& 4. the formatting (indent) level
670\& 5. the selected stylename
671.Ve
672.PP
673To define your own variables, simply add them to the hash, or change
674existing values if you need to. The level and format are passed in as
675references to scalars, but it is unlikely that they will need to be
676changed or even used.
677.Sh "Running \fIB::Concise::compile()\fP"
678.IX Subsection "Running B::Concise::compile()"
679\&\fBcompile\fR accepts options as described above in \*(L"\s-1OPTIONS\s0\*(R", and
680arguments, which are either coderefs, or subroutine names.
681.PP
682It constructs and returns a \f(CW$treewalker\fR coderef, which when invoked,
683traverses, or walks, and renders the optrees of the given arguments to
684\&\s-1STDOUT\s0. You can reuse this, and can change the rendering style used
685each time; thereafter the coderef renders in the new style.
686.PP
687\&\fBwalk_output\fR lets you change the print destination from \s-1STDOUT\s0 to
688another open filehandle, or into a string passed as a ref (unless
689you've built perl with \-Uuseperlio).
690.PP
691.Vb 7
692\& my $walker = B::Concise::compile('-terse','aFuncName', \e&aSubRef); # 1
693\& walk_output(\emy $buf);
694\& $walker->(); # 1 renders -terse
695\& set_style_standard('concise'); # 2
696\& $walker->(); # 2 renders -concise
697\& $walker->(@new); # 3 renders whatever
698\& print "3 different renderings: terse, concise, and @new: $buf\en";
699.Ve
700.PP
701When \f(CW$walker\fR is called, it traverses the subroutines supplied when it
702was created, and renders them using the current style. You can change
703the style afterwards in several different ways:
704.PP
705.Vb 3
706\& 1. call C<compile>, altering style or mode/order
707\& 2. call C<set_style_standard>
708\& 3. call $walker, passing @new options
709.Ve
710.PP
711Passing new options to the \f(CW$walker\fR is the easiest way to change
712amongst any pre-defined styles (the ones you add are automatically
713recognized as options), and is the only way to alter rendering order
714without calling compile again. Note however that rendering state is
715still shared amongst multiple \f(CW$walker\fR objects, so they must still be
716used in a coordinated manner.
717.Sh "\fIB::Concise::reset_sequence()\fP"
718.IX Subsection "B::Concise::reset_sequence()"
719This function (not exported) lets you reset the sequence numbers (note
720that they're numbered arbitrarily, their goal being to be human
721readable). Its purpose is mostly to support testing, i.e. to compare
722the concise output from two identical anonymous subroutines (but
723different instances). Without the reset, B::Concise, seeing that
724they're separate optrees, generates different sequence numbers in
725the output.
726.Sh "Errors"
727.IX Subsection "Errors"
728Errors in rendering (non\-existent function\-name, non-existent coderef)
729are written to the \s-1STDOUT\s0, or wherever you've set it via
730\&\fIwalk_output()\fR.
731.PP
732Errors using the various *style* calls, and bad args to \fIwalk_output()\fR,
733result in \fIdie()\fR. Use an eval if you wish to catch these errors and
734continue processing.
735.SH "AUTHOR"
736.IX Header "AUTHOR"
737Stephen McCamant, <smcc@CSUA.Berkeley.EDU>.