3 # Copyright (c) 1996, 1997, 1998 Malcolm Beattie
5 # You may distribute under the terms of either the GNU General Public
6 # License or the Artistic License, as specified in the README file.
10 @B::ISA = qw(Exporter);
12 # If B is loaded without imports, we do not want to unnecessarily pollute the stash with Exporter.
14 return unless scalar @_ > 1; # Called as a method call.
16 B->export_to_level(1, @_);
19 # walkoptree_slow comes from B.pm (you are there),
20 # walkoptree comes from B.xs
26 # Our BOOT code needs $VERSION set, and will append to @EXPORT_OK.
27 # Want our constants loaded before the compiler meets OPf_KIDS below, as
28 # the combination of having the constant stay a Proxy Constant Subroutine
29 # and its value being inlined saves a little over .5K
35 push @B::EXPORT_OK, (qw(minus_c ppname save_BEGINs
36 class peekop cast_I32 cstring cchar hash threadsv_names
37 main_root main_start main_cv svref_2object opnumber
38 sub_generation amagic_generation perlstring
39 walkoptree_slow walkoptree walkoptree_exec walksymtable
40 parents comppadlist sv_undef compile_stats timing_info
41 begin_av init_av check_av end_av regex_padav dowarn
42 defstash curstash warnhook diehook inc_gv @optype
43 @specialsv_name unitcheck_av safename));
45 @B::SV::ISA = 'B::OBJECT';
46 @B::NULL::ISA = 'B::SV';
47 @B::PV::ISA = 'B::SV';
48 @B::IV::ISA = 'B::SV';
49 @B::NV::ISA = 'B::SV';
50 # RV is eliminated with 5.11.0, but effectively is a specialisation of IV now.
51 @B::RV::ISA = 'B::IV';
52 @B::PVIV::ISA = qw(B::PV B::IV);
53 @B::PVNV::ISA = qw(B::PVIV B::NV);
54 @B::PVMG::ISA = 'B::PVNV';
55 @B::REGEXP::ISA = 'B::PVMG';
56 @B::INVLIST::ISA = 'B::PV';
57 @B::PVLV::ISA = 'B::GV';
58 @B::BM::ISA = 'B::GV';
59 @B::AV::ISA = 'B::PVMG';
60 @B::GV::ISA = 'B::PVMG';
61 @B::HV::ISA = 'B::PVMG';
62 @B::CV::ISA = 'B::PVMG';
63 @B::IO::ISA = 'B::PVMG';
64 @B::FM::ISA = 'B::CV';
66 @B::OP::ISA = 'B::OBJECT';
67 @B::UNOP::ISA = 'B::OP';
68 @B::UNOP_AUX::ISA = 'B::UNOP';
69 @B::BINOP::ISA = 'B::UNOP';
70 @B::LOGOP::ISA = 'B::UNOP';
71 @B::LISTOP::ISA = 'B::BINOP';
72 @B::SVOP::ISA = 'B::OP';
73 @B::PADOP::ISA = 'B::OP';
74 @B::PVOP::ISA = 'B::OP';
75 @B::LOOP::ISA = 'B::LISTOP';
76 @B::PMOP::ISA = 'B::LISTOP';
77 @B::COP::ISA = 'B::OP';
78 @B::METHOP::ISA = 'B::OP';
80 @B::SPECIAL::ISA = 'B::OBJECT';
82 our @optype = qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP
84 # bytecode.pl contained the following comment:
85 # Nullsv *must* come first in the following so that the condition
86 # ($$sv == 0) can continue to be used to test (sv == Nullsv).
87 our @specialsv_name = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no
88 (SV*)pWARN_ALL (SV*)pWARN_NONE (SV*)pWARN_STD
92 # Stop "-w" from complaining about the lack of a real B::OBJECT class
97 safename(shift()->NAME);
103 # The regex below corresponds to the isCONTROLVAR macro
107 or $name =~ s/^([\cA-\cZ\c\\c[\c]\c_\c^])/
108 "^" . chr( utf8::unicode_to_native( 64 ^ ord($1) ))/e;
110 # When we say unicode_to_native we really mean ascii_to_native,
111 # which matters iff this is a non-ASCII platform (EBCDIC). '\c?' would
112 # not have to be special cased, except for non-ASCII.
117 sub B::IV::int_value {
119 return (($self->FLAGS() & SVf_IVisUV()) ? $self->UVX : $self->IV);
122 sub B::NULL::as_string() {""}
123 *B::IV::as_string = *B::IV::as_string = \*B::IV::int_value;
124 *B::PV::as_string = *B::PV::as_string = \*B::PV::PV;
126 # The input typemap checking makes no distinction between different SV types,
127 # so the XS body will generate the same C code, despite the different XS
128 # "types". So there is no change in behaviour from doing "newXS" like this,
129 # compared with the old approach of having a (near) duplicate XS body.
130 # We should fix the typemap checking.
133 *B::IV::RV = *B::IV::RV = \*B::PV::RV;
140 my ($class, $value) = @_;
142 walkoptree_debug($value);
152 sub parents { \@parents }
157 return sprintf("%s (0x%x) %s", class($op), $$op, $op->name);
160 sub walkoptree_slow {
161 my($op, $method, $level) = @_;
162 $op_count++; # just for statistics
164 warn(sprintf("walkoptree: %d. %s\n", $level, peekop($op))) if $debug;
165 $op->$method($level) if $op->can($method);
166 if ($$op && ($op->flags & OPf_KIDS)) {
168 unshift(@parents, $op);
169 for ($kid = $op->first; $$kid; $kid = $kid->sibling) {
170 walkoptree_slow($kid, $method, $level + 1);
174 if (class($op) eq 'PMOP'
175 && ref($op->pmreplroot)
176 && ${$op->pmreplroot}
177 && $op->pmreplroot->isa( 'B::OP' ))
179 unshift(@parents, $op);
180 walkoptree_slow($op->pmreplroot, $method, $level + 1);
186 return "Total number of OPs processed: $op_count\n";
190 my ($sec, $min, $hr) = localtime;
191 my ($user, $sys) = times;
192 sprintf("%02d:%02d:%02d user=$user sys=$sys",
193 $hr, $min, $sec, $user, $sys);
203 my ($obj, $value) = @_;
204 # warn(sprintf("savesym: sym_%x => %s\n", $$obj, $value)); # debug
205 $symtable{sprintf("sym_%x", $$obj)} = $value;
210 return $symtable{sprintf("sym_%x", $$obj)};
213 sub walkoptree_exec {
214 my ($op, $method, $level) = @_;
217 my $prefix = " " x $level;
218 for (; $$op; $op = $op->next) {
221 print $prefix, "goto $sym\n";
224 savesym($op, sprintf("%s (0x%lx)", class($op), $$op));
225 $op->$method($level);
228 /^(d?or(assign)?|and(assign)?|mapwhile|grepwhile|entertry|range|cond_expr)$/)
230 print $prefix, uc($1), " => {\n";
231 walkoptree_exec($op->other, $method, $level + 1);
232 print $prefix, "}\n";
233 } elsif ($ppname eq "match" || $ppname eq "subst") {
234 my $pmreplstart = $op->pmreplstart;
236 print $prefix, "PMREPLSTART => {\n";
237 walkoptree_exec($pmreplstart, $method, $level + 1);
238 print $prefix, "}\n";
240 } elsif ($ppname eq "substcont") {
241 print $prefix, "SUBSTCONT => {\n";
242 walkoptree_exec($op->other->pmreplstart, $method, $level + 1);
243 print $prefix, "}\n";
245 } elsif ($ppname eq "enterloop") {
246 print $prefix, "REDO => {\n";
247 walkoptree_exec($op->redoop, $method, $level + 1);
248 print $prefix, "}\n", $prefix, "NEXT => {\n";
249 walkoptree_exec($op->nextop, $method, $level + 1);
250 print $prefix, "}\n", $prefix, "LAST => {\n";
251 walkoptree_exec($op->lastop, $method, $level + 1);
252 print $prefix, "}\n";
253 } elsif ($ppname eq "subst") {
254 my $replstart = $op->pmreplstart;
256 print $prefix, "SUBST => {\n";
257 walkoptree_exec($replstart, $method, $level + 1);
258 print $prefix, "}\n";
265 my ($symref, $method, $recurse, $prefix) = @_;
269 $prefix = '' unless defined $prefix;
270 foreach my $sym ( sort keys %$symref ) {
271 my $dummy = $symref->{$sym}; # Copying the glob and incrementing
272 # the GPs refcnt clears cached methods
273 $fullname = "*main::".$prefix.$sym;
275 $sym = $prefix . $sym;
276 if (svref_2object(\*$sym)->NAME ne "main::" && $sym ne "<none>::" && &$recurse($sym)) {
277 walksymtable(\%$fullname, $method, $recurse, $sym);
280 svref_2object(\*$fullname)->$method();
291 B - The Perl Compiler Backend
299 The C<B> module supplies classes which allow a Perl program to delve
300 into its own innards. It is the module used to implement the
301 "backends" of the Perl compiler. Usage of the compiler does not
302 require knowledge of this module: see the F<O> module for the
303 user-visible part. The C<B> module is of use to those who want to
304 write new compiler backends. This documentation assumes that the
305 reader knows a fair amount about perl's internals including such
306 things as SVs, OPs and the internal symbol table and syntax tree
311 The C<B> module contains a set of utility functions for querying the
312 current state of the Perl interpreter; typically these functions
313 return objects from the B::SV and B::OP classes, or their derived
314 classes. These classes in turn define methods for querying the
315 resulting objects about their own internal state.
317 =head1 Utility Functions
319 The C<B> module exports a variety of functions: some are simple
320 utility functions, others provide a Perl program with a way to
321 get an initial "handle" on an internal object.
323 =head2 Functions Returning C<B::SV>, C<B::AV>, C<B::HV>, and C<B::CV> objects
325 For descriptions of the class hierarchy of these objects and the
326 methods that can be called on them, see below, L<"OVERVIEW OF
327 CLASSES"> and L<"SV-RELATED CLASSES">.
333 Returns the SV object corresponding to the C variable C<sv_undef>.
337 Returns the SV object corresponding to the C variable C<sv_yes>.
341 Returns the SV object corresponding to the C variable C<sv_no>.
343 =item svref_2object(SVREF)
345 Takes a reference to any Perl value, and turns the referred-to value
346 into an object in the appropriate B::OP-derived or B::SV-derived
347 class. Apart from functions such as C<main_root>, this is the primary
348 way to get an initial "handle" on an internal perl data structure
349 which can then be followed with the other access methods.
351 The returned object will only be valid as long as the underlying OPs
352 and SVs continue to exist. Do not attempt to use the object after the
353 underlying structures are freed.
355 =item amagic_generation
357 Returns the SV object corresponding to the C variable C<amagic_generation>.
358 As of Perl 5.18, this is just an alias to C<PL_na>, so its value is
363 Returns the AV object (i.e. in class B::AV) representing INIT blocks.
367 Returns the AV object (i.e. in class B::AV) representing CHECK blocks.
371 Returns the AV object (i.e. in class B::AV) representing UNITCHECK blocks.
375 Returns the AV object (i.e. in class B::AV) representing BEGIN blocks.
379 Returns the AV object (i.e. in class B::AV) representing END blocks.
383 Returns the PADLIST object (i.e. in class B::PADLIST) of the global
384 comppadlist. In Perl 5.16 and earlier it returns an AV object (class
389 Only when perl was compiled with ithreads.
393 Return the (faked) CV corresponding to the main part of the Perl
398 =head2 Functions for Examining the Symbol Table
402 =item walksymtable(SYMREF, METHOD, RECURSE, PREFIX)
404 Walk the symbol table starting at SYMREF and call METHOD on each
405 symbol (a B::GV object) visited. When the walk reaches package
406 symbols (such as "Foo::") it invokes RECURSE, passing in the symbol
407 name, and only recurses into the package if that sub returns true.
409 PREFIX is the name of the SYMREF you're walking.
413 # Walk CGI's symbol table calling print_subs on each symbol.
414 # Recurse only into CGI::Util::
415 walksymtable(\%CGI::, 'print_subs',
416 sub { $_[0] eq 'CGI::Util::' }, 'CGI::');
418 print_subs() is a B::GV method you have declared. Also see L<"B::GV
423 =head2 Functions Returning C<B::OP> objects or for walking op trees
425 For descriptions of the class hierarchy of these objects and the
426 methods that can be called on them, see below, L<"OVERVIEW OF
427 CLASSES"> and L<"OP-RELATED CLASSES">.
433 Returns the root op (i.e. an object in the appropriate B::OP-derived
434 class) of the main part of the Perl program.
438 Returns the starting op of the main part of the Perl program.
440 =item walkoptree(OP, METHOD)
442 Does a tree-walk of the syntax tree based at OP and calls METHOD on
443 each op it visits. Each node is visited before its children. If
444 C<walkoptree_debug> (see below) has been called to turn debugging on then
445 the method C<walkoptree_debug> is called on each op before METHOD is
448 =item walkoptree_debug(DEBUG)
450 Returns the current debugging flag for C<walkoptree>. If the optional
451 DEBUG argument is non-zero, it sets the debugging flag to that. See
452 the description of C<walkoptree> above for what the debugging flag
457 =head2 Miscellaneous Utility Functions
463 Return the PP function name (e.g. "pp_add") of op number OPNUM.
467 Returns a string in the form "0x..." representing the value of the
468 internal hash function used by perl on string STR.
472 Casts I to the internal I32 type used by that perl.
476 Does the equivalent of the C<-c> command-line option. Obviously, this
477 is only useful in a BEGIN block or else the flag is set too late.
481 Returns a double-quote-surrounded escaped version of STR which can
482 be used as a string in C source code.
484 =item perlstring(STR)
486 Returns a double-quote-surrounded escaped version of STR which can
487 be used as a string in Perl source code.
491 This function returns the string with the first character modified if it
492 is a control character. It converts it to ^X format first, so that "\cG"
493 becomes "^G". This is used internally by L<B::GV::SAFENAME|/SAFENAME>, but
494 you can call it directly.
498 Returns the class of an object without the part of the classname
499 preceding the first C<"::">. This is used to turn C<"B::UNOP"> into
500 C<"UNOP"> for example.
504 This used to provide support for the old 5.005 threading module. It now
509 =head2 Exported utility variables
515 my $op_type = $optype[$op_type_num];
517 A simple mapping of the op type number to its type (like 'COP' or 'BINOP').
519 =item @specialsv_name
521 my $sv_name = $specialsv_name[$sv_index];
523 Certain SV types are considered 'special'. They're represented by
524 B::SPECIAL and are referred to by a number from the specialsv_list.
525 This array maps that number back to the name of the SV (like 'Nullsv'
531 =head1 OVERVIEW OF CLASSES
533 The C structures used by Perl's internals to hold SV and OP
534 information (PVIV, AV, HV, ..., OP, SVOP, UNOP, ...) are modelled on a
535 class hierarchy and the C<B> module gives access to them via a true
536 object hierarchy. Structure fields which point to other objects
537 (whether types of SV or types of OP) are represented by the C<B>
538 module as Perl objects of the appropriate class.
540 The bulk of the C<B> module is the methods for accessing fields of
543 Note that all access is read-only. You cannot modify the internals by
544 using this module. Also, note that the B::OP and B::SV objects created
545 by this module are only valid for as long as the underlying objects
546 exist; their creation doesn't increase the reference counts of the
547 underlying objects. Trying to access the fields of a freed object will
548 give incomprehensible results, or worse.
550 =head2 SV-RELATED CLASSES
552 B::IV, B::NV, B::PV, B::PVIV, B::PVNV, B::PVMG,
553 B::PVLV, B::AV, B::HV, B::CV, B::GV, B::FM, B::IO. These classes
554 correspond in the obvious way to the underlying C structures of similar names.
555 The inheritance hierarchy mimics the underlying C "inheritance":
559 +------------+------------+
573 +-------+-------+---+---+-------+-------+
575 B::AV B::GV B::HV B::CV B::IO B::REGEXP
581 Access methods correspond to the underlying C macros for field access,
582 usually with the leading "class indication" prefix removed (Sv, Av,
583 Hv, ...). The leading prefix is only left in cases where its removal
584 would cause a clash in method name. For example, C<GvREFCNT> stays
585 as-is since its abbreviation would clash with the "superclass" method
586 C<REFCNT> (corresponding to the C function C<SvREFCNT>).
598 Returns a reference to the regular scalar corresponding to this
599 B::SV object. In other words, this method is the inverse operation
600 to the svref_2object() subroutine. This scalar and other data it points
601 at should be considered read-only: modifying them is neither safe nor
602 guaranteed to have a sensible effect.
612 Returns the value of the IV, I<interpreted as
613 a signed integer>. This will be misleading
614 if C<FLAGS & SVf_IVisUV>. Perhaps you want the
615 C<int_value> method instead?
623 This method returns the value of the IV as an integer.
624 It differs from C<IV> in that it returns the correct
625 value regardless of whether it's stored signed or
642 =item COP_SEQ_RANGE_LOW
644 =item COP_SEQ_RANGE_HIGH
646 These last two are only valid for pad name SVs. They only existed in the
647 B::NV class before Perl 5.22. In 5.22 they were moved to the B::PADNAME
666 This method is the one you usually want. It constructs a
667 string using the length and offset information in the struct:
668 for ordinary scalars it will return the string that you'd see
669 from Perl, even if it contains null characters.
673 Same as B::RV::RV, except that it will die() if the PV isn't
678 This method is less often useful. It assumes that the string
679 stored in the struct is null-terminated, and disregards the
682 It is the appropriate method to use if you need to get the name
683 of a lexical variable from a padname array. Lexical variable names
684 are always stored with a null terminator, and the length field
685 (CUR) is overloaded for other purposes and can't be relied on here.
689 This method returns the internal length field, which consists of the number
690 of internal bytes, not necessarily the number of logical characters.
694 This method returns the number of bytes allocated (via malloc) for storing
695 the string. This is 0 if the scalar does not "own" the string.
699 =head2 B::PVMG Methods
709 =head2 B::MAGIC Methods
717 Only valid on r-magic, returns the string that generated the regexp.
727 Will die() if called on r-magic.
733 Only valid on r-magic, returns the integer value of the REGEX stored
738 =head2 B::PVLV Methods
766 =head2 B::REGEXP Methods
778 The last two were added in Perl 5.22.
788 This method returns TRUE if the GP field of the GV is NULL.
794 This method returns the name of the glob, but if the first
795 character of the name is a control character, then it converts
796 it to ^X first, so that *^G would return "^G" rather than "\cG".
798 It's useful if you want to print out the name of a variable.
799 If you restrict yourself to globs which exist at compile-time
800 then the result ought to be unambiguous, because code like
801 C<${"^G"} = 1> is compiled as two ops - a constant string and
802 a dereference (rv2gv) - so that the glob is created at runtime.
804 If you're working with globs at runtime, and need to disambiguate
805 *^G from *{"^G"}, then you should use the raw NAME method.
837 This last one is present only in perl 5.22.0 and higher.
843 B::IO objects derive from IO objects and you will get more information from
844 the IO object itself.
848 $gvio = B::svref_2object(\*main::stdin)->IO;
849 $IO = $gvio->object_2svref();
878 A character symbolizing the type of IO Handle.
891 \0 closed internal handle
897 Takes one argument ( 'stdin' | 'stdout' | 'stderr' ) and returns true
898 if the IoIFP of the object is equal to the handle whose name was
899 passed as argument; i.e., $io->IsSTD('stderr') is true if
900 IoIFP($io) == PerlIO_stderr().
916 Like C<ARRAY>, but takes an index as an argument to get only one element,
917 rather than a list of all of them.
939 Returns a B::PADLIST object.
949 For constant subroutines, returns the constant SV returned by the subroutine.
957 Returns the name of a lexical sub, otherwise C<undef>.
979 =head2 OP-RELATED CLASSES
981 C<B::OP>, C<B::UNOP>, C<B::UNOP_AUX>, C<B::BINOP>, C<B::LOGOP>,
982 C<B::LISTOP>, C<B::PMOP>, C<B::SVOP>, C<B::PADOP>, C<B::PVOP>, C<B::LOOP>,
983 C<B::COP>, C<B::METHOP>.
985 These classes correspond in the obvious way to the underlying C
986 structures of similar names. The inheritance hierarchy mimics the
987 underlying C "inheritance":
991 +----------+---------+--------+-------+---------+
993 B::UNOP B::SVOP B::PADOP B::COP B::PVOP B::METHOP
997 B::BINOP B::LOGOP B::UNOP_AUX
1006 Access methods correspond to the underlying C structure field names,
1007 with the leading "class indication" prefix (C<"op_">) removed.
1009 =head2 B::OP Methods
1011 These methods get the values of similarly named fields within the OP
1012 data structure. See top of C<op.h> for more info.
1022 Returns the OP's parent. If it has no parent, or if your perl wasn't built
1023 with C<-DPERL_OP_PARENT>, returns NULL.
1025 Note that the global variable C<$B::OP::does_parent> is undefined on older
1026 perls that don't support the C<parent> method, is defined but false on
1027 perls that support the method but were built without C<-DPERL_OP_PARENT>,
1028 and is true otherwise.
1032 This returns the op name as a string (e.g. "add", "rv2av").
1036 This returns the function name as a string (e.g. "PL_ppaddr[OP_ADD]",
1037 "PL_ppaddr[OP_RV2AV]").
1041 This returns the op description from the global C PL_op_desc array
1042 (e.g. "addition" "array deref").
1058 =head2 B::UNOP Method
1066 =head2 B::UNOP_AUX Methods (since 5.22)
1072 This returns a list of the elements of the op's aux data structure,
1073 or a null list if there is no aux. What will be returned depends on the
1074 object's type, but will typically be a collection of C<B::IV>, C<B::GV>,
1075 etc. objects. C<cv> is the C<B::CV> object representing the sub that the
1076 op is contained within.
1080 This returns a textual representation of the object (likely to b useful
1081 for deparsing and debugging), or an empty string if the op type doesn't
1082 support this. C<cv> is the C<B::CV> object representing the sub that the
1083 op is contained within.
1087 =head2 B::BINOP Method
1095 =head2 B::LOGOP Method
1103 =head2 B::LISTOP Method
1111 =head2 B::PMOP Methods
1125 Only when perl was compiled with ithreads.
1133 Added in perl 5.22, this method returns the B::REGEXP associated with the
1134 op. While PMOPs do not actually have C<pmregexp> fields under threaded
1135 builds, this method returns the regexp under threads nonetheless, for
1140 =head2 B::SVOP Methods
1150 =head2 B::PADOP Method
1158 =head2 B::PVOP Method
1166 =head2 B::LOOP Methods
1178 =head2 B::COP Methods
1180 The C<B::COP> class is used for "nextstate" and "dbstate" ops. As of Perl
1181 5.22, it is also used for "null" ops that started out as COPs.
1191 =item stashoff (threaded only)
1209 =head2 B::METHOP Methods (Since Perl 5.22)
1219 =head2 PAD-RELATED CLASSES
1221 Perl 5.18 introduced a new class, B::PADLIST, returned by B::CV's
1224 Perl 5.22 introduced the B::PADNAMELIST and B::PADNAME classes.
1226 =head2 B::PADLIST Methods
1234 A list of pads. The first one is a B::PADNAMELIST containing the names.
1235 The rest are currently B::AV objects, but that could
1236 change in future versions.
1240 Like C<ARRAY>, but takes an index as an argument to get only one element,
1241 rather than a list of all of them.
1245 This method, introduced in 5.22, returns the B::PADNAMELIST. It is
1246 equivalent to C<ARRAYelt> with a 0 argument.
1252 This method, introduced in 5.22, returns an ID shared by clones of the same
1257 This method, also added in 5.22, returns the ID of the outer padlist.
1261 =head2 B::PADNAMELIST Methods
1271 These two methods return the pad names, using B::SPECIAL objects for null
1272 pointers and B::PADNAME objects otherwise.
1278 =head2 B::PADNAME Methods
1292 For backward-compatibility, if the PADNAMEt_OUTER flag is set, the FLAGS
1293 method adds the SVf_FAKE flag, too.
1297 A B::HV object representing the stash for a typed lexical.
1301 A backward-compatibility alias for TYPE.
1305 A B::HV object representing the stash for 'our' variables.
1309 The prototype CV for a 'my' sub.
1311 =item COP_SEQ_RANGE_LOW
1313 =item COP_SEQ_RANGE_HIGH
1315 Sequence numbers representing the scope within which a lexical is visible.
1316 Meaningless if PADNAMEt_OUTER is set.
1318 =item PARENT_PAD_INDEX
1320 Only meaningful if PADNAMEt_OUTER is set.
1322 =item PARENT_FAKELEX_FLAGS
1324 Only meaningful if PADNAMEt_OUTER is set.
1330 Although the optree is read-only, there is an overlay facility that allows
1331 you to override what values the various B::*OP methods return for a
1332 particular op. C<$B::overlay> should be set to reference a two-deep hash:
1333 indexed by OP address, then method name. Whenever a an op method is
1334 called, the value in the hash is returned if it exists. This facility is
1335 used by B::Deparse to "undo" some optimisations. For example:
1338 local $B::overlay = {};
1340 if ($op->name eq "foo") {
1341 $B::overlay->{$$op} = {
1343 next => $op->next->next,
1347 $op->name # returns "bar"
1348 $op->next # returns the next op but one
1353 Malcolm Beattie, C<mbeattie@sable.ox.ac.uk>