You are viewing the version of this documentation from Perl 5.39.1. This is a development version of Perl.

CONTENTS

NAME

B - The Perl Compiler Backend

SYNOPSIS

use B;

DESCRIPTION

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.

OVERVIEW

The B module contains a set of utility functions for querying the current state of the Perl interpreter; typically these functions return objects from the B::SV and B::OP classes, or their derived classes. These classes in turn define methods for querying the resulting objects about their own internal state.

Utility Functions

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.

Functions Returning B::SV, B::AV, B::HV, and B::CV objects

For descriptions of the class hierarchy of these objects and the methods that can be called on them, see below, "OVERVIEW OF CLASSES" and "SV-RELATED CLASSES".

sv_undef

Returns the SV object corresponding to the C variable sv_undef.

sv_yes

Returns the SV object corresponding to the C variable sv_yes.

sv_no

Returns the SV object corresponding to the C variable sv_no.

svref_2object(SVREF)

Takes a reference to any Perl value, and turns the referred-to value into an object in the appropriate B::OP-derived or B::SV-derived class. Apart from functions such as main_root, this is the primary way to get an initial "handle" on an internal perl data structure which can then be followed with the other access methods.

The returned object will only be valid as long as the underlying OPs and SVs continue to exist. Do not attempt to use the object after the underlying structures are freed.

amagic_generation

Returns the SV object corresponding to the C variable amagic_generation. As of Perl 5.18, this is just an alias to PL_na, so its value is meaningless.