B - The Perl Compiler |
B
B - The Perl Compiler
use B;
The B
module supplies classes which allow a Perl program to delve
into its own innards. It is the module used to implement the
``backends'' of the Perl compiler. Usage of the compiler does not
require knowledge of this module: see the O module for the
user-visible part. The B
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
of a program.
The C structures used by Perl's internals to hold SV and OP
information (PVIV, AV, HV, ..., OP, SVOP, UNOP, ...) are modelled on a
class hierarchy and the B
module gives access to them via a true
object hierarchy. Structure fields which point to other objects
(whether types of SV or types of OP) are represented by the B
module as Perl objects of the appropriate class. The bulk of the B
module is the methods for accessing fields of these structures. Note
that all access is read-only: you cannot modify the internals by
using this module.
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 ``inheritance''. Access
methods correspond to the underlying C macros for field access,
usually with the leading ``class indication'' 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, GvREFCNT
stays
as-is since its abbreviation would clash with the ``superclass'' method
REFCNT
(corresponding to the C function SvREFCNT
).
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 ``inheritance''. Access methods correspond to the underlying C structre field names, with the leading ``class indication'' prefix removed (op_).
B
The B
module exports a variety of functions: some are simple
utility functions, others provide a Perl program with a way to
get an initial ``handle'' on an internal object.
sv_undef
.
sv_yes
.
sv_no
.
amagic_generation
.
walkoptree_debug
(q.v.) has been called to turn debugging on then
the method walkoptree_debug
is called on each op before METHOD is
called.
walkoptree_debug(DEBUG)
walkoptree
. If the optional
DEBUG argument is non-zero, it sets the debugging flag to that. See
the description of walkoptree
above for what the debugging flag
does.
svref_2object(SV)
main_root
, this is the primary way to get an initial
``handle'' on a internal perl data structure which can then be followed
with the other access methods.
ppname(OPNUM)
hash(STR)
cast_I32(I)
-c
command-line option. Obviously, this
is only useful in a BEGIN block or else the flag is set too late.
cstring(STR)
class(OBJ)
Malcolm Beattie, mbeattie@sable.ox.ac.uk
B - The Perl Compiler |