Linux SoftwareProgrammingLibrariesB::Utils 0.30

B::Utils 0.30


B::Utils is a helper functions for op tree manipulation. SYNOPSIS use B::Utils; These functions make it easier to manipu
Developer:   Simon Cozens
      more software by author →
Price:  0.00
License:   Perl Artistic License
File size:   43K
Language:   
OS:   
Rating:   0 /5 (0 votes)
Your vote:  
enlarge screenshot


B::Utils is a helper functions for op tree manipulation.

SYNOPSIS

use B::Utils;


These functions make it easier to manipulate the op tree.

FUNCTIONS

all_starts

all_roots

Returns a hash of all of the starting ops or root ops of optrees, keyed to subroutine name; the optree for main program is simply keyed to __MAIN__.

Note: Certain "dangerous" stashes are not scanned for subroutines: the list of such stashes can be found in @B::Utils::bad_stashes. Feel free to examine and/or modify this to suit your needs. The intention is that a simple program which uses no modules other than B and B::Utils would show no addition symbols.

This does not return the details of ops in anonymous subroutines compiled at compile time. For instance, given

$a = sub { ... };

the subroutine will not appear in the hash. This is just as well, since they're anonymous... If you want to get at them, use...

anon_subs()

This returns an array of hash references. Each element has the keys "start" and "root". These are the starting and root ops of all of the anonymous subroutines in the program.

$op->oldname

Returns the name of the op, even if it is currently optimized to null. This helps you understand the stucture of the op tree.

$op->kids

Returns an array of all this op's non-null children, in order.

$op->first
$op->last
$op->other

Normally if you call first, last or other on anything which is not an UNOP, BINOP or LOGOP respectivly it will die. This leads to lots of code like:

$op->first if $op->can('first');

B::Utils provides every op with first, last and other methods which will simply return nothing if it isn't relevent.

$op->parent

Returns the parent node in the op tree, if possible. Currently "possible" means "if the tree has already been optimized"; that is, if we're during a CHECK block. (and hence, if we have valid next pointers.)

In the future, it may be possible to search for the parent before we have the next pointers in place, but it'll take me a while to figure out how to do that.

$op->previous

Like $op->next, but not quite.

walkoptree_simple($op, &callback, [$data])

The B module provides various functions to walk the op tree, but they're all rather difficult to use, requiring you to inject methods into the B::OP class. This is a very simple op tree walker with more expected semantics.

The &callback is called at each op with the op itself passed in as the first argument and any additional $data as the second.

All the walk functions set $B::Utils::file and $B::Utils::line to the appropriate values of file and line number in the program being examined. Since only COPs contain this information it may be unavailable in the first few callback calls.

walkoptree_filtered($op, &filter, &callback, [$data])

This is much the same as walkoptree_simple, but will only call the callback if the filter returns true. The filter is passed the op in question as a parameter; the opgrep function is fantastic for building your own filters.

walkallops_simple(&callback, [$data])

This combines walkoptree_simple with all_roots and anon_subs to examine every op in the program. $B::Utils::sub is set to the subroutine name if you're in a subroutine, __MAIN__ if you're in the main program and __ANON__ if you're in an anonymous subroutine.

walkallops_filtered(&filter, &callback, [$data])

Same as above, but filtered.

Requirements:
  • Perl
    tags callback data  walkoptree simple  the program  next pointers  the first  file and  and anon  the filter  data this  filter callback  the parent  returns the  main program  

    Download B::Utils 0.30


     http://mirrors.evolva.ro/CPAN/authors/id/M/MB/MBARBON/Module-Info-0.30.tar.gz


    Authors software

    Acme::OneHundredNotOut 100 (by Simon Cozens)
    Acme::OneHundredNotOut is a raise of the bat, a tip of the hat.

    I have just released my 100th module to CPAN, the first time that

    Email::Store 0.24 (by Simon Cozens)
    Email::Store is a framework for database-backed email storage.

    SYNOPSIS

    use Email::Store 'dbi:mysql:mailstore';
    Email::Sto

    B::Flags 0.01 (by Simon Cozens)
    B::Flags is a Perl module that provides a friendlier flags for B.

    SYNOPSIS

    use B::Flags;
    print B::main_root->flagspv;
    p

    B::Utils 0.30 (by Simon Cozens)
    B::Utils is a helper functions for op tree manipulation.

    SYNOPSIS

    use B::Utils;


    These functions make it easier to manipu

    B::Generate 1.06 (by Simon Cozens)
    B::Generate is a Perl module which you can create your own op trees.


    SYNOPSIS

    use B::Generate;
    # Do nothing, slowly.


    Similar software

    B::Utils 0.30 (by Simon Cozens)
    B::Utils is a helper functions for op tree manipulation.

    SYNOPSIS

    use B::Utils;


    These functions make it easier to manipu

    XML::Filter::DOMFilter::LibXML 0.02 (by Petr Pajas)
    XML::Filter::DOMFilter::LibXML is a SAX Filter allowing DOM processing of selected subtrees.

    SYNOPSIS

    use XML::LibXML;
    use

    Gtk2::Helper 1.122 (by Jorn Reder)
    Gtk2::Helper is a Perl module for convenience functions for the Gtk2 module.

    SYNOPSIS

    use Gtk2::Helper;

    # Handle I/O wat

    Class::Std::Utils 0.0.2 (by Damian Conway)
    Class::Std::Utils is a Perl module for utility subroutines for building "inside-out" objects.

    SYNOPSIS

    use Class::Std::Util

    My Own Dialup Utils 1.0 (by Davide Rao)
    My Own Dialup Utils is a Linux-oriented textual dialup toolkit with support for MS callback and iptables.

    It is intended to be flexi

    Term::Query 2.0 (by Alan K. Stebbens)
    Term::Query is a table-driven query routine.

    SYNOPSIS

    use Term::Query
    qw( query query_table query_table_set_defaults query_tab

    B::Generate 1.06 (by Simon Cozens)
    B::Generate is a Perl module which you can create your own op trees.


    SYNOPSIS

    use B::Generate;
    # Do nothing, slowly.

    Template::Tutorial 2.15 (by Andy Wardley)
    Template::Tutorial are template toolkit tutorials.

    This section includes tutorials on using the Template Toolkit

    XML::SimpleObject 0.53 (by Dan Brian)
    XML::SimpleObject is a Perl extension allowing a simple object representation of a parsed XML::Parser tree.

    SYNOPSIS

    use XML:

    Net::Abuse::Utils 0.05 (by Michael Greb)


    Other software in this category

    zlib 1.2.3 (by Jean-loup Gailly)
    zlib is designed to be a free, general-purpose, legally unencumbered, lossless data-compression library for use on virtually any comp

    libjpeg v6b (by Independent JPEG Group)
    libjpeg is a library for handling the JPEG (JFIF) image format

    OpenSSL 0.9.7c (by The OpenSSL Project Team)
    The OpenSSL Project is a collaborative effort to develop a robust, commercial-grade, full-featured, and Open Source toolkit implement

    libxml2 2.6.27 (by DV)
    Libxml2 is the XML C parser and toolkit developed for the Gnome project (but usable outside of the Gnome platform), libxml2 library i

    GNU C library 2.4 (by Andreas Jaeger)
    GNU C library (glibc) is one of the most important components of GNU Hurd and most modern Linux distributions.

    GNU C library is us

  •     search


    Featured Software

    jEdit 4.3 pre8
    jEdit is an Open Source text editor written in Java

    Opera 9.02
    Surf the Internet in a safer, faster, and easier way with Opera browser

    GNU Aspell 0.60.4
    GNU Aspell is a Free and Open Source spell checker designed to eventually replace Ispell


    Subscribe in Rojo
    Google Reader
    Add to My Yahoo!

    Add to My AOL
    Subscribe with Bloglines
    Subscribe in NewsGator Online
    Add 'nixbit linux software' to Newsburst from CNET News.com
    del.icio.us nixbit linux software


    Top tags