| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Statement/Scheduled.pm |
| Statements | Executed 9 statements in 252µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 385µs | 487µs | PPI::Statement::Scheduled::BEGIN@57 |
| 1 | 1 | 1 | 11µs | 23µs | PPI::Statement::Scheduled::BEGIN@56 |
| 1 | 1 | 1 | 9µs | 9µs | PPI::Statement::Scheduled::BEGIN@60 |
| 1 | 1 | 1 | 7µs | 35µs | PPI::Statement::Scheduled::BEGIN@59 |
| 0 | 0 | 0 | 0s | 0s | PPI::Statement::Scheduled::__LEXER__normal |
| 0 | 0 | 0 | 0s | 0s | PPI::Statement::Scheduled::_complete |
| 0 | 0 | 0 | 0s | 0s | PPI::Statement::Scheduled::name |
| 0 | 0 | 0 | 0s | 0s | PPI::Statement::Scheduled::type |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package PPI::Statement::Scheduled; | ||||
| 2 | |||||
| 3 | =pod | ||||
| 4 | |||||
| 5 | =head1 NAME | ||||
| 6 | |||||
| 7 | PPI::Statement::Scheduled - A scheduled code block | ||||
| 8 | |||||
| 9 | =head1 INHERITANCE | ||||
| 10 | |||||
| 11 | PPI::Statement::Scheduled | ||||
| 12 | isa PPI::Statement::Sub | ||||
| 13 | isa PPI::Statement | ||||
| 14 | isa PPI::Node | ||||
| 15 | isa PPI::Element | ||||
| 16 | |||||
| 17 | =head1 DESCRIPTION | ||||
| 18 | |||||
| 19 | A scheduled code block is one that is intended to be run at a specific | ||||
| 20 | time during the loading process. | ||||
| 21 | |||||
| 22 | There are five types of scheduled block: | ||||
| 23 | |||||
| 24 | BEGIN { | ||||
| 25 | # Executes as soon as this block is fully defined | ||||
| 26 | ... | ||||
| 27 | } | ||||
| 28 | |||||
| 29 | CHECK { | ||||
| 30 | # Executes after overall compile-phase in reverse order | ||||
| 31 | ... | ||||
| 32 | } | ||||
| 33 | |||||
| 34 | UNITCHECK { | ||||
| 35 | # Executes after compile-phase of individual module in reverse order | ||||
| 36 | ... | ||||
| 37 | } | ||||
| 38 | |||||
| 39 | INIT { | ||||
| 40 | # Executes just before run-time | ||||
| 41 | ... | ||||
| 42 | } | ||||
| 43 | |||||
| 44 | END { | ||||
| 45 | # Executes as late as possible in reverse order | ||||
| 46 | ... | ||||
| 47 | } | ||||
| 48 | |||||
| 49 | Technically these scheduled blocks are actually subroutines, and in fact | ||||
| 50 | may have 'sub' in front of them. | ||||
| 51 | |||||
| 52 | =head1 METHODS | ||||
| 53 | |||||
| 54 | =cut | ||||
| 55 | |||||
| 56 | 2 | 19µs | 2 | 35µs | # spent 23µs (11+12) within PPI::Statement::Scheduled::BEGIN@56 which was called:
# once (11µs+12µs) by PPI::Statement::BEGIN@170 at line 56 # spent 23µs making 1 call to PPI::Statement::Scheduled::BEGIN@56
# spent 12µs making 1 call to strict::import |
| 57 | 2 | 86µs | 1 | 487µs | # spent 487µs (385+102) within PPI::Statement::Scheduled::BEGIN@57 which was called:
# once (385µs+102µs) by PPI::Statement::BEGIN@170 at line 57 # spent 487µs making 1 call to PPI::Statement::Scheduled::BEGIN@57 |
| 58 | |||||
| 59 | 2 | 28µs | 2 | 63µs | # spent 35µs (7+28) within PPI::Statement::Scheduled::BEGIN@59 which was called:
# once (7µs+28µs) by PPI::Statement::BEGIN@170 at line 59 # spent 35µs making 1 call to PPI::Statement::Scheduled::BEGIN@59
# spent 28µs making 1 call to vars::import |
| 60 | # spent 9µs within PPI::Statement::Scheduled::BEGIN@60 which was called:
# once (9µs+0s) by PPI::Statement::BEGIN@170 at line 63 | ||||
| 61 | 1 | 400ns | $VERSION = '1.215'; | ||
| 62 | 1 | 9µs | @ISA = 'PPI::Statement::Sub'; | ||
| 63 | 1 | 109µs | 1 | 9µs | } # spent 9µs making 1 call to PPI::Statement::Scheduled::BEGIN@60 |
| 64 | |||||
| 65 | sub __LEXER__normal { '' } | ||||
| 66 | |||||
| 67 | sub _complete { | ||||
| 68 | my $child = $_[0]->schild(-1); | ||||
| 69 | return !! ( | ||||
| 70 | defined $child | ||||
| 71 | and | ||||
| 72 | $child->isa('PPI::Structure::Block') | ||||
| 73 | and | ||||
| 74 | $child->complete | ||||
| 75 | ); | ||||
| 76 | } | ||||
| 77 | |||||
| 78 | =pod | ||||
| 79 | |||||
| 80 | =head2 type | ||||
| 81 | |||||
| 82 | The C<type> method returns the type of scheduled block, which should always be | ||||
| 83 | one of C<'BEGIN'>, C<'CHECK'>, C<'UNITCHECK'>, C<'INIT'> or C<'END'>. | ||||
| 84 | |||||
| 85 | =cut | ||||
| 86 | |||||
| 87 | sub type { | ||||
| 88 | my $self = shift; | ||||
| 89 | my @children = $self->schildren or return undef; | ||||
| 90 | $children[0]->content eq 'sub' | ||||
| 91 | ? $children[1]->content | ||||
| 92 | : $children[0]->content; | ||||
| 93 | } | ||||
| 94 | |||||
| 95 | # This is actually the same as Sub->name | ||||
| 96 | sub name { | ||||
| 97 | shift->type(@_); | ||||
| 98 | } | ||||
| 99 | |||||
| 100 | 1 | 2µs | 1; | ||
| 101 | |||||
| 102 | =pod | ||||
| 103 | |||||
| 104 | =head1 TO DO | ||||
| 105 | |||||
| 106 | - Write unit tests for this package | ||||
| 107 | |||||
| 108 | =head1 SUPPORT | ||||
| 109 | |||||
| 110 | See the L<support section|PPI/SUPPORT> in the main module. | ||||
| 111 | |||||
| 112 | =head1 AUTHOR | ||||
| 113 | |||||
| 114 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||
| 115 | |||||
| 116 | =head1 COPYRIGHT | ||||
| 117 | |||||
| 118 | Copyright 2001 - 2011 Adam Kennedy. | ||||
| 119 | |||||
| 120 | This program is free software; you can redistribute | ||||
| 121 | it and/or modify it under the same terms as Perl itself. | ||||
| 122 | |||||
| 123 | The full text of the license can be found in the | ||||
| 124 | LICENSE file included with this module. | ||||
| 125 | |||||
| 126 | =cut |