| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/Operator.pm |
| Statements | Executed 73422 statements in 61.1ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 10907 | 5 | 2 | 64.2ms | 300ms | PPI::Token::Operator::__TOKENIZER__on_char |
| 1 | 1 | 1 | 33µs | 33µs | PPI::Token::Operator::BEGIN@46 |
| 31 | 2 | 1 | 26µs | 26µs | PPI::Token::Operator::CORE:match (opcode) |
| 1 | 1 | 1 | 11µs | 25µs | PPI::Token::Operator::BEGIN@42 |
| 1 | 1 | 1 | 6µs | 42µs | PPI::Token::Operator::BEGIN@45 |
| 1 | 1 | 1 | 3µs | 3µs | PPI::Token::Operator::BEGIN@43 |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package PPI::Token::Operator; | ||||
| 2 | |||||
| 3 | =pod | ||||
| 4 | |||||
| 5 | =head1 NAME | ||||
| 6 | |||||
| 7 | PPI::Token::Operator - Token class for operators | ||||
| 8 | |||||
| 9 | =head1 INHERITANCE | ||||
| 10 | |||||
| 11 | PPI::Token::Operator | ||||
| 12 | isa PPI::Token | ||||
| 13 | isa PPI::Element | ||||
| 14 | |||||
| 15 | =head1 SYNOPSIS | ||||
| 16 | |||||
| 17 | # This is the list of valid operators | ||||
| 18 | ++ -- ** ! ~ + - | ||||
| 19 | =~ !~ * / % x | ||||
| 20 | << >> lt gt le ge cmp ~~ | ||||
| 21 | == != <=> . .. ... , | ||||
| 22 | & | ^ && || // | ||||
| 23 | ? : = += -= *= .= //= | ||||
| 24 | < > <= >= <> => -> | ||||
| 25 | and or dor not eq ne | ||||
| 26 | |||||
| 27 | =head1 DESCRIPTION | ||||
| 28 | |||||
| 29 | All operators in PPI are created as C<PPI::Token::Operator> objects, | ||||
| 30 | including the ones that may superficially look like a L<PPI::Token::Word> | ||||
| 31 | object. | ||||
| 32 | |||||
| 33 | =head1 METHODS | ||||
| 34 | |||||
| 35 | There are no additional methods beyond those provided by the parent | ||||
| 36 | L<PPI::Token> and L<PPI::Element> classes. | ||||
| 37 | |||||
| 38 | Got any ideas for methods? Submit a report to rt.cpan.org! | ||||
| 39 | |||||
| 40 | =cut | ||||
| 41 | |||||
| 42 | 2 | 17µs | 2 | 38µs | # spent 25µs (11+14) within PPI::Token::Operator::BEGIN@42 which was called:
# once (11µs+14µs) by PPI::Token::BEGIN@66 at line 42 # spent 25µs making 1 call to PPI::Token::Operator::BEGIN@42
# spent 14µs making 1 call to strict::import |
| 43 | 2 | 18µs | 1 | 3µs | # spent 3µs within PPI::Token::Operator::BEGIN@43 which was called:
# once (3µs+0s) by PPI::Token::BEGIN@66 at line 43 # spent 3µs making 1 call to PPI::Token::Operator::BEGIN@43 |
| 44 | |||||
| 45 | 2 | 59µs | 2 | 77µs | # spent 42µs (6+36) within PPI::Token::Operator::BEGIN@45 which was called:
# once (6µs+36µs) by PPI::Token::BEGIN@66 at line 45 # spent 42µs making 1 call to PPI::Token::Operator::BEGIN@45
# spent 36µs making 1 call to vars::import |
| 46 | # spent 33µs within PPI::Token::Operator::BEGIN@46 which was called:
# once (33µs+0s) by PPI::Token::BEGIN@66 at line 66 | ||||
| 47 | 1 | 400ns | $VERSION = '1.215'; | ||
| 48 | 1 | 4µs | @ISA = 'PPI::Token'; | ||
| 49 | |||||
| 50 | # Build the operator index | ||||
| 51 | ### NOTE - This is accessed several times explicitly | ||||
| 52 | ### in PPI::Token::Word. Do not rename this | ||||
| 53 | ### without also correcting them. | ||||
| 54 | 1 | 29µs | %OPERATOR = map { $_ => 1 } ( | ||
| 55 | qw{ | ||||
| 56 | -> ++ -- ** ! ~ + - | ||||
| 57 | =~ !~ * / % x . << >> | ||||
| 58 | < > <= >= lt gt le ge | ||||
| 59 | == != <=> eq ne cmp ~~ | ||||
| 60 | & | ^ && || // .. ... | ||||
| 61 | ? : = += -= *= .= /= //= | ||||
| 62 | => <> | ||||
| 63 | and or xor not | ||||
| 64 | }, ',' # Avoids "comma in qw{}" warning | ||||
| 65 | ); | ||||
| 66 | 1 | 176µs | 1 | 33µs | } # spent 33µs making 1 call to PPI::Token::Operator::BEGIN@46 |
| 67 | |||||
| - - | |||||
| 72 | ##################################################################### | ||||
| 73 | # Tokenizer Methods | ||||
| 74 | |||||
| 75 | # spent 300ms (64.2+236) within PPI::Token::Operator::__TOKENIZER__on_char which was called 10907 times, avg 28µs/call:
# 10634 times (63.4ms+236ms) by PPI::Tokenizer::_process_next_char at line 554 of PPI/Tokenizer.pm, avg 28µs/call
# 139 times (396µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 248 of PPI/Token/Unknown.pm, avg 3µs/call
# 108 times (310µs+9µs) by PPI::Token::Unknown::__TOKENIZER__on_char at line 272 of PPI/Token/Unknown.pm, avg 3µs/call
# 25 times (180µs+145µs) by PPI::Token::Unknown::__TOKENIZER__on_char at line 295 of PPI/Token/Unknown.pm, avg 13µs/call
# once (7µs+5µs) by PPI::Token::Unknown::__TOKENIZER__on_char at line 222 of PPI/Token/Unknown.pm | ||||
| 76 | 10907 | 1.59ms | my $t = $_[1]; | ||
| 77 | 10907 | 4.97ms | my $char = substr( $t->{line}, $t->{line_cursor}, 1 ); | ||
| 78 | |||||
| 79 | # Are we still an operator if we add the next character | ||||
| 80 | 10907 | 3.87ms | my $content = $t->{token}->{content}; | ||
| 81 | 10907 | 20.9ms | return 1 if $OPERATOR{ $content . $char }; | ||
| 82 | |||||
| 83 | # Handle the special case of a .1234 decimal number | ||||
| 84 | 7438 | 1.19ms | if ( $content eq '.' ) { | ||
| 85 | 30 | 104µs | 30 | 24µs | if ( $char =~ /^[0-9]$/ ) { # spent 24µs making 30 calls to PPI::Token::Operator::CORE:match, avg 803ns/call |
| 86 | # This is a decimal number | ||||
| 87 | $t->{class} = $t->{token}->set_class('Number::Float'); | ||||
| 88 | return $t->{class}->__TOKENIZER__on_char( $t ); | ||||
| 89 | } | ||||
| 90 | } | ||||
| 91 | |||||
| 92 | # Handle the special case if we might be a here-doc | ||||
| 93 | 7438 | 908µs | if ( $content eq '<<' ) { | ||
| 94 | 1 | 900ns | my $line = substr( $t->{line}, $t->{line_cursor} ); | ||
| 95 | # Either <<FOO or << 'FOO' or <<\FOO | ||||
| 96 | ### Is the zero-width look-ahead assertion really | ||||
| 97 | ### supposed to be there? | ||||
| 98 | 1 | 6µs | 1 | 1µs | if ( $line =~ /^(?: (?!\d)\w | \s*['"`] | \\\w ) /x ) { # spent 1µs making 1 call to PPI::Token::Operator::CORE:match |
| 99 | # This is a here-doc. | ||||
| 100 | # Change the class and move to the HereDoc's own __TOKENIZER__on_char method. | ||||
| 101 | 1 | 6µs | 1 | 9µs | $t->{class} = $t->{token}->set_class('HereDoc'); # spent 9µs making 1 call to PPI::Token::set_class |
| 102 | 1 | 6µs | 1 | 138µs | return $t->{class}->__TOKENIZER__on_char( $t ); # spent 138µs making 1 call to PPI::Token::HereDoc::__TOKENIZER__on_char |
| 103 | } | ||||
| 104 | } | ||||
| 105 | |||||
| 106 | # Handle the special case of the null Readline | ||||
| 107 | 7437 | 646µs | if ( $content eq '<>' ) { | ||
| 108 | $t->{class} = $t->{token}->set_class('QuoteLike::Readline'); | ||||
| 109 | } | ||||
| 110 | |||||
| 111 | # Finalize normally | ||||
| 112 | 7437 | 26.6ms | 14874 | 236ms | $t->_finalize_token->__TOKENIZER__on_char( $t ); # spent 219ms making 7437 calls to PPI::Token::Whitespace::__TOKENIZER__on_char, avg 29µs/call
# spent 16.8ms making 7437 calls to PPI::Tokenizer::_finalize_token, avg 2µs/call |
| 113 | } | ||||
| 114 | |||||
| 115 | 1 | 2µs | 1; | ||
| 116 | |||||
| 117 | =pod | ||||
| 118 | |||||
| 119 | =head1 SUPPORT | ||||
| 120 | |||||
| 121 | See the L<support section|PPI/SUPPORT> in the main module. | ||||
| 122 | |||||
| 123 | =head1 AUTHOR | ||||
| 124 | |||||
| 125 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||
| 126 | |||||
| 127 | =head1 COPYRIGHT | ||||
| 128 | |||||
| 129 | Copyright 2001 - 2011 Adam Kennedy. | ||||
| 130 | |||||
| 131 | This program is free software; you can redistribute | ||||
| 132 | it and/or modify it under the same terms as Perl itself. | ||||
| 133 | |||||
| 134 | The full text of the license can be found in the | ||||
| 135 | LICENSE file included with this module. | ||||
| 136 | |||||
| 137 | =cut | ||||
sub PPI::Token::Operator::CORE:match; # opcode |