Suppress Sys::Syslog diag msg (repost)
[p5sagit/p5-mst-13.2.git] / ext / B / B.pm
index fa3c218..fdf79ae 100644 (file)
@@ -7,7 +7,7 @@
 #
 package B;
 
-our $VERSION = '1.09';
+our $VERSION = '1.16';
 
 use XSLoader ();
 require Exporter;
@@ -18,12 +18,13 @@ require Exporter;
 @EXPORT_OK = qw(minus_c ppname save_BEGINs
                class peekop cast_I32 cstring cchar hash threadsv_names
                main_root main_start main_cv svref_2object opnumber
-               amagic_generation perlstring
+               sub_generation amagic_generation perlstring
                walkoptree_slow walkoptree walkoptree_exec walksymtable
                parents comppadlist sv_undef compile_stats timing_info
-               begin_av init_av check_av end_av regex_padav dowarn
-               defstash curstash warnhook diehook inc_gv
+               begin_av init_av check_av end_av regex_padav dowarn defstash
+               curstash warnhook diehook inc_gv @optype @specialsv_name
                );
+push @EXPORT_OK, qw(unitcheck_av) if $] > 5.009;
 
 sub OPf_KIDS ();
 use strict;
@@ -60,6 +61,13 @@ use strict;
 
 @B::SPECIAL::ISA = 'B::OBJECT';
 
+@B::optype = qw(OP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP LOOP COP);
+# bytecode.pl contained the following comment:
+# Nullsv *must* come first in the following so that the condition
+# ($$sv == 0) can continue to be used to test (sv == Nullsv).
+@B::specialsv_name = qw(Nullsv &PL_sv_undef &PL_sv_yes &PL_sv_no
+                       (SV*)pWARN_ALL (SV*)pWARN_NONE (SV*)pWARN_STD);
+
 {
     # Stop "-w" from complaining about the lack of a real B::OBJECT class
     package B::OBJECT;
@@ -119,7 +127,7 @@ sub walkoptree_slow {
     $op_count++; # just for statistics
     $level ||= 0;
     warn(sprintf("walkoptree: %d. %s\n", $level, peekop($op))) if $debug;
-    $op->$method($level);
+    $op->$method($level) if $op->can($method);
     if ($$op && ($op->flags & OPf_KIDS)) {
        my $kid;
        unshift(@parents, $op);
@@ -128,7 +136,11 @@ sub walkoptree_slow {
        }
        shift @parents;
     }
-    if (class($op) eq 'PMOP' && ref($op->pmreplroot) && ${$op->pmreplroot}) {
+    if (class($op) eq 'PMOP'
+       && ref($op->pmreplroot)
+       && ${$op->pmreplroot}
+       && $op->pmreplroot->isa( 'B::OP' ))
+    {
        unshift(@parents, $op);
        walkoptree_slow($op->pmreplroot, $method, $level + 1);
        shift @parents;
@@ -384,6 +396,10 @@ Returns the AV object (i.e. in class B::AV) representing INIT blocks.
 
 Returns the AV object (i.e. in class B::AV) representing CHECK blocks.
 
+=item unitcheck_av
+
+Returns the AV object (i.e. in class B::AV) representing UNITCHECK blocks.
+
 =item begin_av
 
 Returns the AV object (i.e. in class B::AV) representing BEGIN blocks.
@@ -511,7 +527,26 @@ per-thread threadsv variables.
 
 =back
 
+=head2 Exported utility variabiles
+
+=over 4
+
+=item @optype
 
+  my $op_type = $optype[$op_type_num];
+
+A simple mapping of the op type number to its type (like 'COP' or 'BINOP').
+
+=item @specialsv_name
+
+  my $sv_name = $specialsv_name[$sv_index];
+
+Certain SV types are considered 'special'.  They're represented by
+B::SPECIAL and are referred to by a number from the specialsv_list.
+This array maps that number back to the name of the SV (like 'Nullsv'
+or '&PL_sv_undef').
+
+=back
 
 
 =head1 OVERVIEW OF CLASSES
@@ -848,8 +883,6 @@ IoIFP($io) == PerlIO_stdin() ).
 
 =item MAX
 
-=item OFF
-
 =item ARRAY
 
 =item ARRAYelt
@@ -857,8 +890,16 @@ IoIFP($io) == PerlIO_stdin() ).
 Like C<ARRAY>, but takes an index as an argument to get only one element,
 rather than a list of all of them.
 
+=item OFF
+
+This method is deprecated if running under Perl 5.8, and is no longer present
+if running under Perl 5.9
+
 =item AvFLAGS
 
+This method returns the AV specific flags. In Perl 5.9 these are now stored
+in with the main SV flags, so this method is no longer present.
+
 =back
 
 =head2 B::CV Methods
@@ -909,9 +950,12 @@ For constant subroutines, returns the constant SV returned by the subroutine.
 
 =item NAME
 
+=item ARRAY
+
 =item PMROOT
 
-=item ARRAY
+This method is not present if running under Perl 5.9, as the PMROOT
+information is no longer stored directly in the hash.
 
 =back
 
@@ -926,9 +970,9 @@ underlying C "inheritance":
 
                                  B::OP
                                    |
-                   +---------------+--------+--------+
-                   |               |        |        |
-                B::UNOP          B::SVOP B::PADOP  B::COP
+                   +---------------+--------+--------+-------+
+                   |               |        |        |       |
+                B::UNOP          B::SVOP B::PADOP  B::COP  B::PVOP
                  ,'  `-.
                 /       `--.
            B::BINOP     B::LOGOP
@@ -973,8 +1017,6 @@ This returns the op description from the global C PL_op_desc array
 
 =item opt
 
-=item static
-
 =item flags
 
 =item private
@@ -1029,9 +1071,7 @@ This returns the op description from the global C PL_op_desc array
 
 =item pmflags
 
-=item pmdynflags
-
-=item pmpermflags
+=item extflags
 
 =item precomp
 
@@ -1101,6 +1141,8 @@ Only when perl was compiled with ithreads.
 
 =item io
 
+=item hints
+
 =back