B::Utils 0.30
Sponsored Links
B::Utils 0.30 Ranking & Summary
File size:
0.043 MB
Platform:
Any Platform
License:
Perl Artistic License
Price:
Downloads:
1208
Date added:
2006-07-04
Publisher:
Simon Cozens
B::Utils 0.30 description
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 theyre 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 ops 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 isnt 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 were 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 itll 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 theyre 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 youre in a subroutine, __MAIN__ if youre in the main program and __ANON__ if youre in an anonymous subroutine.
walkallops_filtered(&filter, &callback, [$data])
Same as above, but filtered.
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 theyre 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 ops 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 isnt 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 were 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 itll 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 theyre 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 youre in a subroutine, __MAIN__ if youre in the main program and __ANON__ if youre in an anonymous subroutine.
walkallops_filtered(&filter, &callback, [$data])
Same as above, but filtered.
B::Utils 0.30 Screenshot
B::Utils 0.30 Keywords
Utils 0.30
Helper Functions
op
tree
functions
first
returns
simple
B::Utils
BUtils
B::Utils 0.30
Libraries
Programming
Bookmark B::Utils 0.30
B::Utils 0.30 Copyright
WareSeeker periodically updates pricing and software information of B::Utils 0.30 full version from the publisher, so some information may be slightly out-of-date. You should confirm all information before relying on it. Software piracy is theft, Using crack, password, serial numbers, registration codes, key generators is illegal and prevent future development of B::Utils 0.30 Edition. Download links are directly from our publisher sites, torrent files or links from rapidshare.com, yousendit.com or megaupload.com are not allowed
Featured Software
Want to place your software product here?
Please contact us for consideration.
Contact WareSeeker.com
Related Information
functions of money
trigonometric functions
functions of the skin
functions of the liver
treehouse tv
functions of public relations
brain functions
first tennessee bank
one tree hill
what are the functions of the liver
functions math
c++ helper functions
liver functions
first choice
tree frogs
functions of the brain
tree man
first coast news
Related Software
IMAP utils software contains a set of simple utilities for managing IMAP emails. Free Download
B::JVM::Utils is a Perl module that contains utility functions for B::JVM. Free Download
CGI::Utils is a Perl module for retrieving information through the Common Gateway Interface and mod_perl. Free Download
Array::Utils module contains small utils for array manipulation. Free Download
Net::Abuse::Utils are routines useful for processing network abuse. Free Download
lisp-cgi-utils is a CGI library for Common Lisp. Free Download
AFS::Utils is a Perl module with shared utility functions for the AFS module bundle. Free Download
Gtk2::Ex::Utils is a Perl module with extra Gtk2 Utilities for working with Gnome2/Gtk2 in Perl. Free Download
Latest Software
Popular Software
Favourite Software