| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/DashedWord.pm |
| Statements | Executed 20 statements in 262µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 2 | 1 | 1 | 40µs | 69µs | PPI::Token::DashedWord::__TOKENIZER__on_char |
| 1 | 1 | 1 | 12µs | 24µs | PPI::Token::DashedWord::BEGIN@29 |
| 1 | 1 | 1 | 8µs | 8µs | PPI::Token::DashedWord::BEGIN@33 |
| 1 | 1 | 1 | 7µs | 35µs | PPI::Token::DashedWord::BEGIN@32 |
| 4 | 2 | 1 | 4µs | 4µs | PPI::Token::DashedWord::CORE:match (opcode) |
| 1 | 1 | 1 | 3µs | 3µs | PPI::Token::DashedWord::BEGIN@30 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package PPI::Token::DashedWord; | ||||
| 2 | |||||
| 3 | =pod | ||||
| 4 | |||||
| 5 | =head1 NAME | ||||
| 6 | |||||
| 7 | PPI::Token::DashedWord - A dashed bareword token | ||||
| 8 | |||||
| 9 | =head1 INHERITANCE | ||||
| 10 | |||||
| 11 | PPI::Token::DashedWord | ||||
| 12 | isa PPI::Token | ||||
| 13 | isa PPI::Element | ||||
| 14 | |||||
| 15 | =head1 DESCRIPTION | ||||
| 16 | |||||
| 17 | The "dashed bareword" token represents literal values like C<-foo>. | ||||
| 18 | |||||
| 19 | NOTE: this class is currently unused. All tokens that should be | ||||
| 20 | PPI::Token::DashedWords are just normal PPI::Token::Word instead. | ||||
| 21 | That actually makes sense, since there really is nothing special about | ||||
| 22 | this class except that dashed words cannot be subroutine names or | ||||
| 23 | keywords. As such, this class may be removed from PPI in the future. | ||||
| 24 | |||||
| 25 | =head1 METHODS | ||||
| 26 | |||||
| 27 | =cut | ||||
| 28 | |||||
| 29 | 2 | 20µs | 2 | 36µs | # spent 24µs (12+12) within PPI::Token::DashedWord::BEGIN@29 which was called:
# once (12µs+12µs) by PPI::Token::BEGIN@50 at line 29 # spent 24µs making 1 call to PPI::Token::DashedWord::BEGIN@29
# spent 12µs making 1 call to strict::import |
| 30 | 2 | 19µs | 1 | 3µs | # spent 3µs within PPI::Token::DashedWord::BEGIN@30 which was called:
# once (3µs+0s) by PPI::Token::BEGIN@50 at line 30 # spent 3µs making 1 call to PPI::Token::DashedWord::BEGIN@30 |
| 31 | |||||
| 32 | 2 | 29µs | 2 | 63µs | # spent 35µs (7+28) within PPI::Token::DashedWord::BEGIN@32 which was called:
# once (7µs+28µs) by PPI::Token::BEGIN@50 at line 32 # spent 35µs making 1 call to PPI::Token::DashedWord::BEGIN@32
# spent 28µs making 1 call to vars::import |
| 33 | # spent 8µs within PPI::Token::DashedWord::BEGIN@33 which was called:
# once (8µs+0s) by PPI::Token::BEGIN@50 at line 36 | ||||
| 34 | 1 | 300ns | $VERSION = '1.215'; | ||
| 35 | 1 | 8µs | @ISA = 'PPI::Token'; | ||
| 36 | 1 | 146µs | 1 | 8µs | } # spent 8µs making 1 call to PPI::Token::DashedWord::BEGIN@33 |
| 37 | |||||
| 38 | =pod | ||||
| 39 | |||||
| 40 | =head2 literal | ||||
| 41 | |||||
| 42 | Returns the value of the dashed word as a string. This differs from | ||||
| 43 | C<content> because C<-Foo'Bar> expands to C<-Foo::Bar>. | ||||
| 44 | |||||
| 45 | =begin testing literal 9 | ||||
| 46 | |||||
| 47 | my @pairs = ( | ||||
| 48 | "-foo", '-foo', | ||||
| 49 | "-Foo::Bar", '-Foo::Bar', | ||||
| 50 | "-Foo'Bar", '-Foo::Bar', | ||||
| 51 | ); | ||||
| 52 | while ( @pairs ) { | ||||
| 53 | my $from = shift @pairs; | ||||
| 54 | my $to = shift @pairs; | ||||
| 55 | my $doc = PPI::Document->new( \"( $from => 1 );" ); | ||||
| 56 | isa_ok( $doc, 'PPI::Document' ); | ||||
| 57 | my $word = $doc->find_first('Token::DashedWord'); | ||||
| 58 | SKIP: { | ||||
| 59 | skip( "PPI::Token::DashedWord is deactivated", 2 ); | ||||
| 60 | isa_ok( $word, 'PPI::Token::DashedWord' ); | ||||
| 61 | is( $word && $word->literal, $to, "The source $from becomes $to ok" ); | ||||
| 62 | } | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | =end testing | ||||
| 66 | |||||
| 67 | =cut | ||||
| 68 | |||||
| 69 | 1 | 900ns | *literal = *PPI::Token::Word::literal; | ||
| 70 | |||||
| - - | |||||
| 73 | ##################################################################### | ||||
| 74 | # Tokenizer Methods | ||||
| 75 | |||||
| 76 | # spent 69µs (40+28) within PPI::Token::DashedWord::__TOKENIZER__on_char which was called 2 times, avg 34µs/call:
# 2 times (40µs+28µs) by PPI::Tokenizer::_process_next_char at line 554 of PPI/Tokenizer.pm, avg 34µs/call | ||||
| 77 | 2 | 700ns | my $t = $_[1]; | ||
| 78 | |||||
| 79 | # Suck to the end of the dashed bareword | ||||
| 80 | 2 | 2µs | my $line = substr( $t->{line}, $t->{line_cursor} ); | ||
| 81 | 2 | 10µs | 2 | 2µs | if ( $line =~ /^(\w+)/ ) { # spent 2µs making 2 calls to PPI::Token::DashedWord::CORE:match, avg 800ns/call |
| 82 | $t->{token}->{content} .= $1; | ||||
| 83 | $t->{line_cursor} += length $1; | ||||
| 84 | } | ||||
| 85 | |||||
| 86 | # Are we a file test operator? | ||||
| 87 | 2 | 13µs | 4 | 18µs | if ( $t->{token}->{content} =~ /^\-[rwxoRWXOezsfdlpSbctugkTBMAC]$/ ) { # spent 16µs making 2 calls to PPI::Token::set_class, avg 8µs/call
# spent 2µs making 2 calls to PPI::Token::DashedWord::CORE:match, avg 950ns/call |
| 88 | # File test operator | ||||
| 89 | $t->{class} = $t->{token}->set_class( 'Operator' ); | ||||
| 90 | } else { | ||||
| 91 | # No, normal dashed bareword | ||||
| 92 | $t->{class} = $t->{token}->set_class( 'Word' ); | ||||
| 93 | } | ||||
| 94 | |||||
| 95 | 2 | 10µs | 4 | 9µs | $t->_finalize_token->__TOKENIZER__on_char( $t ); # spent 5µs making 2 calls to PPI::Tokenizer::_finalize_token, avg 2µs/call
# spent 4µs making 2 calls to PPI::Token::Whitespace::__TOKENIZER__on_char, avg 2µs/call |
| 96 | } | ||||
| 97 | |||||
| 98 | 1 | 2µs | 1; | ||
| 99 | |||||
| 100 | =pod | ||||
| 101 | |||||
| 102 | =head1 SUPPORT | ||||
| 103 | |||||
| 104 | See the L<support section|PPI/SUPPORT> in the main module. | ||||
| 105 | |||||
| 106 | =head1 AUTHOR | ||||
| 107 | |||||
| 108 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||
| 109 | |||||
| 110 | =head1 COPYRIGHT | ||||
| 111 | |||||
| 112 | Copyright 2001 - 2011 Adam Kennedy. | ||||
| 113 | |||||
| 114 | This program is free software; you can redistribute | ||||
| 115 | it and/or modify it under the same terms as Perl itself. | ||||
| 116 | |||||
| 117 | The full text of the license can be found in the | ||||
| 118 | LICENSE file included with this module. | ||||
| 119 | |||||
| 120 | =cut | ||||
sub PPI::Token::DashedWord::CORE:match; # opcode |