.\" Automatically generated by Pod::Man v1.34, Pod::Parser v1.13
.\" ========================================================================
.de Sh \" Subsection heading
.de Sp \" Vertical space (when we can't use .PP)
.de Vb \" Begin verbatim text
.de Ve \" End verbatim text
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. | will give a
.\" real vertical bar. \*(C+ will give a nicer C++. Capital omega is used to
.\" do unbreakable dashes and therefore won't be available. \*(C` and \*(C'
.\" expand to `' in nroff, nothing in troff, for use with C<>.
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
. tm Index:\\$1\t\\n%\t"\\$2"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. \" simple accents for nroff and troff
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
.\" ========================================================================
.TH B 3 "2002-06-01" "perl v5.8.0" "Perl Programmers Reference Guide"
The \f(CW\*(C`B\*(C'\fR module supplies classes which allow a Perl program to delve
into its own innards. It is the module used to implement the
\&\*(L"backends\*(R" of the Perl compiler. Usage of the compiler does not
require knowledge of this module: see the \fIO\fR module for the
user-visible part. The \f(CW\*(C`B\*(C'\fR module is of use to those who want to
write new compiler backends. This documentation assumes that the
reader knows a fair amount about perl's internals including such
things as SVs, OPs and the internal symbol table and syntax tree
.SH "OVERVIEW OF CLASSES"
.IX Header "OVERVIEW OF CLASSES"
The C structures used by Perl's internals to hold \s-1SV\s0 and \s-1OP\s0
information (\s-1PVIV\s0, \s-1AV\s0, \s-1HV\s0, ..., \s-1OP\s0, \s-1SVOP\s0, \s-1UNOP\s0, ...) are modelled on a
class hierarchy and the \f(CW\*(C`B\*(C'\fR module gives access to them via a true
object hierarchy. Structure fields which point to other objects
(whether types of \s-1SV\s0 or types of \s-1OP\s0) are represented by the \f(CW\*(C`B\*(C'\fR
module as Perl objects of the appropriate class. The bulk of the \f(CW\*(C`B\*(C'\fR
module is the methods for accessing fields of these structures. Note
that all access is read\-only: you cannot modify the internals by
.Sh "SV-RELATED \s-1CLASSES\s0"
.IX Subsection "SV-RELATED CLASSES"
B::IV, B::NV, B::RV, B::PV, B::PVIV, B::PVNV, B::PVMG, B::BM, B::PVLV,
B::AV, B::HV, B::CV, B::GV, B::FM, B::IO. These classes correspond in
the obvious way to the underlying C structures of similar names. The
inheritance hierarchy mimics the underlying C \*(L"inheritance\*(R". Access
methods correspond to the underlying C macros for field access,
usually with the leading \*(L"class indication\*(R" prefix removed (Sv, Av,
Hv, ...). The leading prefix is only left in cases where its removal
would cause a clash in method name. For example, \f(CW\*(C`GvREFCNT\*(C'\fR stays
as-is since its abbreviation would clash with the \*(L"superclass\*(R" method
\&\f(CW\*(C`REFCNT\*(C'\fR (corresponding to the C function \f(CW\*(C`SvREFCNT\*(C'\fR).
.Sh "B::SV \s-1METHODS\s0"
.IX Subsection "B::SV METHODS"
.Sh "B::IV \s-1METHODS\s0"
.IX Subsection "B::IV METHODS"
Returns the value of the \s-1IV\s0, \fIinterpreted as
a signed integer\fR. This will be misleading
if \f(CW\*(C`FLAGS & SVf_IVisUV\*(C'\fR. Perhaps you want the
\&\f(CW\*(C`int_value\*(C'\fR method instead?
This method returns the value of the \s-1IV\s0 as an integer.
It differs from \f(CW\*(C`IV\*(C'\fR in that it returns the correct
value regardless of whether it's stored signed or
.Sh "B::NV \s-1METHODS\s0"
.IX Subsection "B::NV METHODS"
.Sh "B::RV \s-1METHODS\s0"
.IX Subsection "B::RV METHODS"
.Sh "B::PV \s-1METHODS\s0"
.IX Subsection "B::PV METHODS"
This method is the one you usually want. It constructs a
string using the length and offset information in the struct:
for ordinary scalars it will return the string that you'd see
from Perl, even if it contains null characters.
Same as B::RV::RV, except that it will \fIdie()\fR if the \s-1PV\s0 isn't
This method is less often useful. It assumes that the string
stored in the struct is null\-terminated, and disregards the
It is the appropriate method to use if you need to get the name
of a lexical variable from a padname array. Lexical variable names
are always stored with a null terminator, and the length field
(SvCUR) is overloaded for other purposes and can't be relied on here.
.Sh "B::PVMG \s-1METHODS\s0"
.IX Subsection "B::PVMG METHODS"
.Sh "B::MAGIC \s-1METHODS\s0"
.IX Subsection "B::MAGIC METHODS"
Only valid on r\-magic, returns the string that generated the regexp.
Will \fIdie()\fR if called on r\-magic.
Only valid on r\-magic, returns the integer value of the \s-1REGEX\s0 stored
.Sh "B::PVLV \s-1METHODS\s0"
.IX Subsection "B::PVLV METHODS"
.Sh "B::BM \s-1METHODS\s0"
.IX Subsection "B::BM METHODS"
.Sh "B::GV \s-1METHODS\s0"
.IX Subsection "B::GV METHODS"
This method returns \s-1TRUE\s0 if the \s-1GP\s0 field of the \s-1GV\s0 is \s-1NULL\s0.
This method returns the name of the glob, but if the first
character of the name is a control character, then it converts
it to ^X first, so that *^G would return \*(L"^G\*(R" rather than \*(L"\ecG\*(R".
It's useful if you want to print out the name of a variable.
If you restrict yourself to globs which exist at compile-time
then the result ought to be unambiguous, because code like
\&\f(CW\*(C`${"^G"} = 1\*(C'\fR is compiled as two ops \- a constant string and
a dereference (rv2gv) \- so that the glob is created at runtime.
If you're working with globs at runtime, and need to disambiguate
*^G from *{\*(L"^G\*(R"}, then you should use the raw \s-1NAME\s0 method.
.Sh "B::IO \s-1METHODS\s0"
.IX Subsection "B::IO METHODS"
.IP "\s-1LINES_LEFT\s0" 4
.IP "\s-1BOTTOM_NAME\s0" 4
.IP "\s-1SUBPROCESS\s0" 4
Takes one arguments ( 'stdin' | 'stdout' | 'stderr' ) and returns true
if the IoIFP of the object is equal to the handle whose name was
passed as argument ( i.e. \f(CW$io\fR\->IsSTD('stderr') is true if
IoIFP($io) == \fIPerlIO_stdin()\fR ).
.Sh "B::AV \s-1METHODS\s0"
.IX Subsection "B::AV METHODS"
.Sh "B::CV \s-1METHODS\s0"
.IX Subsection "B::CV METHODS"
For constant subroutines, returns the constant \s-1SV\s0 returned by the subroutine.
.Sh "B::HV \s-1METHODS\s0"
.IX Subsection "B::HV METHODS"
.Sh "OP-RELATED \s-1CLASSES\s0"
.IX Subsection "OP-RELATED CLASSES"
B::OP, B::UNOP, B::BINOP, B::LOGOP, B::LISTOP, B::PMOP,
B::SVOP, B::PADOP, B::PVOP, B::CVOP, B::LOOP, B::COP.
These classes correspond in
the obvious way to the underlying C structures of similar names. The
inheritance hierarchy mimics the underlying C \*(L"inheritance\*(R". Access
methods correspond to the underlying C structre field names, with the
leading \*(L"class indication\*(R" prefix removed (op_).
.Sh "B::OP \s-1METHODS\s0"
.IX Subsection "B::OP METHODS"
This returns the op name as a string (e.g. \*(L"add\*(R", \*(L"rv2av\*(R").
This returns the function name as a string (e.g. \*(L"PL_ppaddr[\s-1OP_ADD\s0]\*(R",
\&\*(L"PL_ppaddr[\s-1OP_RV2AV\s0]\*(R").
This returns the op description from the global C PL_op_desc array
(e.g. \*(L"addition\*(R" \*(L"array deref\*(R").
.Sh "B::UNOP \s-1METHOD\s0"
.IX Subsection "B::UNOP METHOD"
.Sh "B::BINOP \s-1METHOD\s0"
.IX Subsection "B::BINOP METHOD"
.Sh "B::LOGOP \s-1METHOD\s0"
.IX Subsection "B::LOGOP METHOD"
.Sh "B::LISTOP \s-1METHOD\s0"
.IX Subsection "B::LISTOP METHOD"
.Sh "B::PMOP \s-1METHODS\s0"
.IX Subsection "B::PMOP METHODS"
Only when perl was compiled with ithreads.
.Sh "B::SVOP \s-1METHOD\s0"
.IX Subsection "B::SVOP METHOD"
.Sh "B::PADOP \s-1METHOD\s0"
.IX Subsection "B::PADOP METHOD"
.Sh "B::PVOP \s-1METHOD\s0"
.IX Subsection "B::PVOP METHOD"
.Sh "B::LOOP \s-1METHODS\s0"
.IX Subsection "B::LOOP METHODS"
.Sh "B::COP \s-1METHODS\s0"
.IX Subsection "B::COP METHODS"
.ie n .SH "FUNCTIONS EXPORTED BY ""B"""
.el .SH "FUNCTIONS EXPORTED BY \f(CWB\fP"
.IX Header "FUNCTIONS EXPORTED BY B"
The \f(CW\*(C`B\*(C'\fR module exports a variety of functions: some are simple
utility functions, others provide a Perl program with a way to
get an initial \*(L"handle\*(R" on an internal object.
Return the (faked) \s-1CV\s0 corresponding to the main part of the Perl
Returns the \s-1AV\s0 object (i.e. in class B::AV) representing \s-1INIT\s0 blocks.
Returns the \s-1AV\s0 object (i.e. in class B::AV) representing \s-1BEGIN\s0 blocks.
Returns the \s-1AV\s0 object (i.e. in class B::AV) representing \s-1END\s0 blocks.
Returns the root op (i.e. an object in the appropriate B::OP\-derived
class) of the main part of the Perl program.
Returns the starting op of the main part of the Perl program.
Returns the \s-1AV\s0 object (i.e. in class B::AV) of the global comppadlist.
Only when perl was compiled with ithreads.
Returns the \s-1SV\s0 object corresponding to the C variable \f(CW\*(C`sv_undef\*(C'\fR.
Returns the \s-1SV\s0 object corresponding to the C variable \f(CW\*(C`sv_yes\*(C'\fR.
Returns the \s-1SV\s0 object corresponding to the C variable \f(CW\*(C`sv_no\*(C'\fR.
.IP "amagic_generation" 4
.IX Item "amagic_generation"
Returns the \s-1SV\s0 object corresponding to the C variable \f(CW\*(C`amagic_generation\*(C'\fR.
.IP "walkoptree(\s-1OP\s0, \s-1METHOD\s0)" 4
.IX Item "walkoptree(OP, METHOD)"
Does a tree-walk of the syntax tree based at \s-1OP\s0 and calls \s-1METHOD\s0 on
each op it visits. Each node is visited before its children. If
\&\f(CW\*(C`walkoptree_debug\*(C'\fR (q.v.) has been called to turn debugging on then
the method \f(CW\*(C`walkoptree_debug\*(C'\fR is called on each op before \s-1METHOD\s0 is
.IP "walkoptree_debug(\s-1DEBUG\s0)" 4
.IX Item "walkoptree_debug(DEBUG)"
Returns the current debugging flag for \f(CW\*(C`walkoptree\*(C'\fR. If the optional
\&\s-1DEBUG\s0 argument is non\-zero, it sets the debugging flag to that. See
the description of \f(CW\*(C`walkoptree\*(C'\fR above for what the debugging flag
.IP "walksymtable(\s-1SYMREF\s0, \s-1METHOD\s0, \s-1RECURSE\s0, \s-1PREFIX\s0)" 4
.IX Item "walksymtable(SYMREF, METHOD, RECURSE, PREFIX)"
Walk the symbol table starting at \s-1SYMREF\s0 and call \s-1METHOD\s0 on each
symbol (a B::GV object) visited. When the walk reaches package
symbols (such as \*(L"Foo::\*(R") it invokes \s-1RECURSE\s0, passing in the symbol
name, and only recurses into the package if that sub returns true.
\&\s-1PREFIX\s0 is the name of the \s-1SYMREF\s0 you're walking.
\& # Walk CGI's symbol table calling print_subs on each symbol.
\& # Only recurse into CGI::Util::
\& walksymtable(\e%CGI::, 'print_subs', sub { $_[0] eq 'CGI::Util::' },
\&\fIprint_subs()\fR is a B::GV method you have declared.
.IP "svref_2object(\s-1SV\s0)" 4
.IX Item "svref_2object(SV)"
Takes any Perl variable and turns it into an object in the
appropriate B::OP\-derived or B::SV\-derived class. Apart from functions
such as \f(CW\*(C`main_root\*(C'\fR, this is the primary way to get an initial
\&\*(L"handle\*(R" on an internal perl data structure which can then be followed
with the other access methods.
.IP "ppname(\s-1OPNUM\s0)" 4
Return the \s-1PP\s0 function name (e.g. \*(L"pp_add\*(R") of op number \s-1OPNUM\s0.
Returns a string in the form \*(L"0x...\*(R" representing the value of the
internal hash function used by perl on string \s-1STR\s0.
Casts I to the internal I32 type used by that perl.
Does the equivalent of the \f(CW\*(C`\-c\*(C'\fR command-line option. Obviously, this
is only useful in a \s-1BEGIN\s0 block or else the flag is set too late.
.IP "cstring(\s-1STR\s0)" 4
Returns a double-quote-surrounded escaped version of \s-1STR\s0 which can
be used as a string in C source code.
.IP "perlstring(\s-1STR\s0)" 4
.IX Item "perlstring(STR)"
Returns a double-quote-surrounded escaped version of \s-1STR\s0 which can
be used as a string in Perl source code.
.IP "class(\s-1OBJ\s0)" 4
Returns the class of an object without the part of the classname
preceding the first \*(L"::\*(R". This is used to turn \*(L"B::UNOP\*(R" into
\&\*(L"\s-1UNOP\s0\*(R" for example.
.IX Item "threadsv_names"
In a perl compiled for threads, this returns a list of the special
per-thread threadsv variables.
Malcolm Beattie, \f(CW\*(C`mbeattie@sable.ox.ac.uk\*(C'\fR