| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/Unknown.pm |
| Statements | Executed 58731 statements in 95.8ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 8180 | 1 | 1 | 83.0ms | 201ms | PPI::Token::Unknown::__TOKENIZER__on_char |
| 8844 | 14 | 1 | 8.85ms | 8.85ms | PPI::Token::Unknown::CORE:match (opcode) |
| 25 | 1 | 1 | 345µs | 1.04ms | PPI::Token::Unknown::__TOKENIZER__is_an_attribute |
| 108 | 3 | 1 | 280µs | 280µs | PPI::Token::Unknown::CORE:regcomp (opcode) |
| 1 | 1 | 1 | 14µs | 16µs | PPI::Token::Unknown::BEGIN@35 |
| 1 | 1 | 1 | 11µs | 22µs | PPI::Token::Unknown::BEGIN@30 |
| 1 | 1 | 1 | 6µs | 45µs | PPI::Token::Unknown::BEGIN@34 |
| 1 | 1 | 1 | 3µs | 3µs | PPI::Token::Unknown::BEGIN@31 |
| 1 | 1 | 1 | 2µs | 2µs | PPI::Token::Unknown::BEGIN@32 |
| 1 | 1 | 1 | 2µs | 2µs | PPI::Token::Unknown::CORE:qr (opcode) |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package PPI::Token::Unknown; | ||||
| 2 | |||||
| 3 | =pod | ||||
| 4 | |||||
| 5 | =head1 NAME | ||||
| 6 | |||||
| 7 | PPI::Token::Unknown - Token of unknown or as-yet undetermined type | ||||
| 8 | |||||
| 9 | =head1 INHERITANCE | ||||
| 10 | |||||
| 11 | PPI::Token::Unknown | ||||
| 12 | isa PPI::Token | ||||
| 13 | isa PPI::Element | ||||
| 14 | |||||
| 15 | =head1 DESCRIPTION | ||||
| 16 | |||||
| 17 | Object of the type C<PPI::Token::Unknown> exist primarily inside the | ||||
| 18 | tokenizer, where they are temporarily brought into existing for a very | ||||
| 19 | short time to represent a token that could be one of a number of types. | ||||
| 20 | |||||
| 21 | Generally, they only exist for a character or two, after which they are | ||||
| 22 | resolved and converted into the correct type. For an object of this type | ||||
| 23 | to survive the parsing process is considered a major bug. | ||||
| 24 | |||||
| 25 | Please report any C<PPI::Token::Unknown> you encounter in a L<PPI::Document> | ||||
| 26 | object as a bug. | ||||
| 27 | |||||
| 28 | =cut | ||||
| 29 | |||||
| 30 | 2 | 18µs | 2 | 33µs | # spent 22µs (11+11) within PPI::Token::Unknown::BEGIN@30 which was called:
# once (11µs+11µs) by PPI::Token::Magic::BEGIN@46 at line 30 # spent 22µs making 1 call to PPI::Token::Unknown::BEGIN@30
# spent 11µs making 1 call to strict::import |
| 31 | 2 | 15µs | 1 | 3µs | # spent 3µs within PPI::Token::Unknown::BEGIN@31 which was called:
# once (3µs+0s) by PPI::Token::Magic::BEGIN@46 at line 31 # spent 3µs making 1 call to PPI::Token::Unknown::BEGIN@31 |
| 32 | 2 | 21µs | 1 | 2µs | # spent 2µs within PPI::Token::Unknown::BEGIN@32 which was called:
# once (2µs+0s) by PPI::Token::Magic::BEGIN@46 at line 32 # spent 2µs making 1 call to PPI::Token::Unknown::BEGIN@32 |
| 33 | |||||
| 34 | 2 | 52µs | 2 | 83µs | # spent 45µs (6+39) within PPI::Token::Unknown::BEGIN@34 which was called:
# once (6µs+39µs) by PPI::Token::Magic::BEGIN@46 at line 34 # spent 45µs making 1 call to PPI::Token::Unknown::BEGIN@34
# spent 39µs making 1 call to vars::import |
| 35 | # spent 16µs (14+2) within PPI::Token::Unknown::BEGIN@35 which was called:
# once (14µs+2µs) by PPI::Token::Magic::BEGIN@46 at line 39 | ||||
| 36 | 1 | 300ns | $VERSION = '1.215'; | ||
| 37 | 1 | 5µs | @ISA = 'PPI::Token'; | ||
| 38 | 1 | 9µs | 1 | 2µs | $CURLY_SYMBOL = qr{^\^[[:upper:]_]\w+\}}; # spent 2µs making 1 call to PPI::Token::Unknown::CORE:qr |
| 39 | 1 | 948µs | 1 | 16µs | } # spent 16µs making 1 call to PPI::Token::Unknown::BEGIN@35 |
| 40 | |||||
| - - | |||||
| 45 | ##################################################################### | ||||
| 46 | # Tokenizer Methods | ||||
| 47 | |||||
| 48 | # spent 201ms (83.0+118) within PPI::Token::Unknown::__TOKENIZER__on_char which was called 8180 times, avg 25µs/call:
# 8180 times (83.0ms+118ms) by PPI::Tokenizer::_process_next_char at line 554 of PPI/Tokenizer.pm, avg 25µs/call | ||||
| 49 | 8180 | 1.45ms | my $t = $_[1]; # Tokenizer object | ||
| 50 | 8180 | 4.02ms | my $c = $t->{token}->{content}; # Current token | ||
| 51 | 8180 | 3.54ms | my $char = substr( $t->{line}, $t->{line_cursor}, 1 ); # Current character | ||
| 52 | |||||
| 53 | # Now, we split on the different values of the current content | ||||
| 54 | 8180 | 3.65ms | if ( $c eq '*' ) { | ||
| 55 | 2 | 9µs | 2 | 3µs | if ( $char =~ /(?:(?!\d)\w|\:)/ ) { # spent 3µs making 2 calls to PPI::Token::Unknown::CORE:match, avg 1µs/call |
| 56 | # Symbol (unless the thing before it is a number | ||||
| 57 | 2 | 3µs | 2 | 20µs | my $tokens = $t->_previous_significant_tokens(1); # spent 20µs making 2 calls to PPI::Tokenizer::_previous_significant_tokens, avg 10µs/call |
| 58 | 2 | 600ns | my $p0 = $tokens->[0]; | ||
| 59 | 2 | 19µs | 4 | 5µs | if ( $p0 and ! $p0->isa('PPI::Token::Number') ) { # spent 4µs making 2 calls to UNIVERSAL::isa, avg 2µs/call
# spent 2µs making 2 calls to PPI::Util::TRUE, avg 750ns/call |
| 60 | 2 | 4µs | 2 | 20µs | $t->{class} = $t->{token}->set_class( 'Symbol' ); # spent 20µs making 2 calls to PPI::Token::set_class, avg 10µs/call |
| 61 | 2 | 5µs | return 1; | ||
| 62 | } | ||||
| 63 | } | ||||
| 64 | |||||
| 65 | if ( $char eq '{' ) { | ||||
| 66 | # Get rest of line | ||||
| 67 | my $rest = substr( $t->{line}, $t->{line_cursor} + 1 ); | ||||
| 68 | if ( $rest =~ m/$CURLY_SYMBOL/ ) { | ||||
| 69 | # control-character symbol (e.g. *{^_Foo}) | ||||
| 70 | $t->{class} = $t->{token}->set_class( 'Magic' ); | ||||
| 71 | return 1; | ||||
| 72 | } else { | ||||
| 73 | # Obvious GLOB cast | ||||
| 74 | $t->{class} = $t->{token}->set_class( 'Cast' ); | ||||
| 75 | return $t->_finalize_token->__TOKENIZER__on_char( $t ); | ||||
| 76 | } | ||||
| 77 | } | ||||
| 78 | |||||
| 79 | if ( $char eq '$' ) { | ||||
| 80 | # Operator/operand-sensitive, multiple or GLOB cast | ||||
| 81 | my $_class = undef; | ||||
| 82 | my $tokens = $t->_previous_significant_tokens(1); | ||||
| 83 | my $p0 = $tokens->[0]; | ||||
| 84 | if ( $p0 ) { | ||||
| 85 | # Is it a token or a number | ||||
| 86 | if ( $p0->isa('PPI::Token::Symbol') ) { | ||||
| 87 | $_class = 'Operator'; | ||||
| 88 | } elsif ( $p0->isa('PPI::Token::Number') ) { | ||||
| 89 | $_class = 'Operator'; | ||||
| 90 | } elsif ( | ||||
| 91 | $p0->isa('PPI::Token::Structure') | ||||
| 92 | and | ||||
| 93 | $p0->content =~ /^(?:\)|\])$/ | ||||
| 94 | ) { | ||||
| 95 | $_class = 'Operator'; | ||||
| 96 | } else { | ||||
| 97 | ### This is pretty weak, there's | ||||
| 98 | ### room for a dozen more tests | ||||
| 99 | ### before going with a default. | ||||
| 100 | ### Or even better, a proper | ||||
| 101 | ### operator/operand method :( | ||||
| 102 | $_class = 'Cast'; | ||||
| 103 | } | ||||
| 104 | } else { | ||||
| 105 | # Nothing before it, must be glob cast | ||||
| 106 | $_class = 'Cast'; | ||||
| 107 | } | ||||
| 108 | |||||
| 109 | # Set class and rerun | ||||
| 110 | $t->{class} = $t->{token}->set_class( $_class ); | ||||
| 111 | return $t->_finalize_token->__TOKENIZER__on_char( $t ); | ||||
| 112 | } | ||||
| 113 | |||||
| 114 | if ( $char eq '*' || $char eq '=' ) { | ||||
| 115 | # Power operator '**' or mult-assign '*=' | ||||
| 116 | $t->{class} = $t->{token}->set_class( 'Operator' ); | ||||
| 117 | return 1; | ||||
| 118 | } | ||||
| 119 | |||||
| 120 | $t->{class} = $t->{token}->set_class( 'Operator' ); | ||||
| 121 | return $t->_finalize_token->__TOKENIZER__on_char( $t ); | ||||
| 122 | |||||
| - - | |||||
| 125 | } elsif ( $c eq '$' ) { | ||||
| 126 | 6837 | 25.7ms | 6837 | 7.28ms | if ( $char =~ /[a-z_]/i ) { # spent 7.28ms making 6837 calls to PPI::Token::Unknown::CORE:match, avg 1µs/call |
| 127 | # Symbol | ||||
| 128 | 6802 | 12.5ms | 6802 | 87.5ms | $t->{class} = $t->{token}->set_class( 'Symbol' ); # spent 87.5ms making 6802 calls to PPI::Token::set_class, avg 13µs/call |
| 129 | 6802 | 30.7ms | return 1; | ||
| 130 | } | ||||
| 131 | |||||
| 132 | 35 | 28µs | if ( $PPI::Token::Magic::magic{ $c . $char } ) { | ||
| 133 | # Magic variable | ||||
| 134 | 34 | 64µs | 34 | 319µs | $t->{class} = $t->{token}->set_class( 'Magic' ); # spent 319µs making 34 calls to PPI::Token::set_class, avg 9µs/call |
| 135 | 34 | 65µs | return 1; | ||
| 136 | } | ||||
| 137 | |||||
| 138 | 1 | 600ns | if ( $char eq '{' ) { | ||
| 139 | # Get rest of line | ||||
| 140 | 1 | 1µs | my $rest = substr( $t->{line}, $t->{line_cursor} + 1 ); | ||
| 141 | 1 | 9µs | 2 | 2µs | if ( $rest =~ m/$CURLY_SYMBOL/ ) { # spent 1µs making 1 call to PPI::Token::Unknown::CORE:regcomp
# spent 700ns making 1 call to PPI::Token::Unknown::CORE:match |
| 142 | # control-character symbol (e.g. ${^MATCH}) | ||||
| 143 | $t->{class} = $t->{token}->set_class( 'Magic' ); | ||||
| 144 | return 1; | ||||
| 145 | } | ||||
| 146 | } | ||||
| 147 | |||||
| 148 | # Must be a cast | ||||
| 149 | 1 | 2µs | 1 | 8µs | $t->{class} = $t->{token}->set_class( 'Cast' ); # spent 8µs making 1 call to PPI::Token::set_class |
| 150 | 1 | 4µs | 2 | 22µs | return $t->_finalize_token->__TOKENIZER__on_char( $t ); # spent 19µs making 1 call to PPI::Token::Whitespace::__TOKENIZER__on_char
# spent 2µs making 1 call to PPI::Tokenizer::_finalize_token |
| 151 | |||||
| - - | |||||
| 154 | } elsif ( $c eq '@' ) { | ||||
| 155 | 888 | 2.78ms | 888 | 890µs | if ( $char =~ /[\w:]/ ) { # spent 890µs making 888 calls to PPI::Token::Unknown::CORE:match, avg 1µs/call |
| 156 | # Symbol | ||||
| 157 | 803 | 1.55ms | 803 | 7.07ms | $t->{class} = $t->{token}->set_class( 'Symbol' ); # spent 7.07ms making 803 calls to PPI::Token::set_class, avg 9µs/call |
| 158 | 803 | 1.57ms | return 1; | ||
| 159 | } | ||||
| 160 | |||||
| 161 | 85 | 76µs | if ( $PPI::Token::Magic::magic{ $c . $char } ) { | ||
| 162 | # Magic variable | ||||
| 163 | $t->{class} = $t->{token}->set_class( 'Magic' ); | ||||
| 164 | return 1; | ||||
| 165 | } | ||||
| 166 | |||||
| 167 | 85 | 51µs | if ( $char eq '{' ) { | ||
| 168 | # Get rest of line | ||||
| 169 | 85 | 73µs | my $rest = substr( $t->{line}, $t->{line_cursor} + 1 ); | ||
| 170 | 85 | 671µs | 170 | 290µs | if ( $rest =~ m/$CURLY_SYMBOL/ ) { # spent 233µs making 85 calls to PPI::Token::Unknown::CORE:regcomp, avg 3µs/call
# spent 57µs making 85 calls to PPI::Token::Unknown::CORE:match, avg 674ns/call |
| 171 | # control-character symbol (e.g. @{^_Foo}) | ||||
| 172 | $t->{class} = $t->{token}->set_class( 'Magic' ); | ||||
| 173 | return 1; | ||||
| 174 | } | ||||
| 175 | } | ||||
| 176 | |||||
| 177 | # Must be a cast | ||||
| 178 | 85 | 188µs | 85 | 792µs | $t->{class} = $t->{token}->set_class( 'Cast' ); # spent 792µs making 85 calls to PPI::Token::set_class, avg 9µs/call |
| 179 | 85 | 358µs | 170 | 2.00ms | return $t->_finalize_token->__TOKENIZER__on_char( $t ); # spent 1.79ms making 85 calls to PPI::Token::Whitespace::__TOKENIZER__on_char, avg 21µs/call
# spent 215µs making 85 calls to PPI::Tokenizer::_finalize_token, avg 3µs/call |
| 180 | |||||
| - - | |||||
| 183 | } elsif ( $c eq '%' ) { | ||||
| 184 | # Is it a number? | ||||
| 185 | 142 | 436µs | 142 | 99µs | if ( $char =~ /\d/ ) { # spent 99µs making 142 calls to PPI::Token::Unknown::CORE:match, avg 695ns/call |
| 186 | # This is %2 (modulus number) | ||||
| 187 | $t->{class} = $t->{token}->set_class( 'Operator' ); | ||||
| 188 | return $t->_finalize_token->__TOKENIZER__on_char( $t ); | ||||
| 189 | } | ||||
| 190 | |||||
| 191 | # Is it a magic variable? | ||||
| 192 | 142 | 129µs | if ( $char eq '^' || $PPI::Token::Magic::magic{ $c . $char } ) { | ||
| 193 | $t->{class} = $t->{token}->set_class( 'Magic' ); | ||||
| 194 | return 1; | ||||
| 195 | } | ||||
| 196 | |||||
| 197 | # Is it a symbol? | ||||
| 198 | 142 | 378µs | 142 | 120µs | if ( $char =~ /[\w:]/ ) { # spent 120µs making 142 calls to PPI::Token::Unknown::CORE:match, avg 843ns/call |
| 199 | 119 | 277µs | 119 | 1.15ms | $t->{class} = $t->{token}->set_class( 'Symbol' ); # spent 1.15ms making 119 calls to PPI::Token::set_class, avg 10µs/call |
| 200 | 119 | 247µs | return 1; | ||
| 201 | } | ||||
| 202 | |||||
| 203 | 23 | 10µs | if ( $char eq '{' ) { | ||
| 204 | # Get rest of line | ||||
| 205 | 22 | 21µs | my $rest = substr( $t->{line}, $t->{line_cursor} + 1 ); | ||
| 206 | 22 | 157µs | 44 | 61µs | if ( $rest =~ m/$CURLY_SYMBOL/ ) { # spent 46µs making 22 calls to PPI::Token::Unknown::CORE:regcomp, avg 2µs/call
# spent 15µs making 22 calls to PPI::Token::Unknown::CORE:match, avg 677ns/call |
| 207 | # control-character symbol (e.g. @{^_Foo}) | ||||
| 208 | $t->{class} = $t->{token}->set_class( 'Magic' ); | ||||
| 209 | return 1; | ||||
| 210 | } | ||||
| 211 | } | ||||
| 212 | |||||
| 213 | 23 | 58µs | 23 | 17µs | if ( $char =~ /[\$@%*{]/ ) { # spent 17µs making 23 calls to PPI::Token::Unknown::CORE:match, avg 752ns/call |
| 214 | # It's a cast | ||||
| 215 | 22 | 46µs | 22 | 183µs | $t->{class} = $t->{token}->set_class( 'Cast' ); # spent 183µs making 22 calls to PPI::Token::set_class, avg 8µs/call |
| 216 | 22 | 95µs | 44 | 483µs | return $t->_finalize_token->__TOKENIZER__on_char( $t ); # spent 429µs making 22 calls to PPI::Token::Whitespace::__TOKENIZER__on_char, avg 20µs/call
# spent 54µs making 22 calls to PPI::Tokenizer::_finalize_token, avg 2µs/call |
| 217 | |||||
| 218 | } | ||||
| 219 | |||||
| 220 | # Probably the mod operator | ||||
| 221 | 1 | 2µs | 1 | 8µs | $t->{class} = $t->{token}->set_class( 'Operator' ); # spent 8µs making 1 call to PPI::Token::set_class |
| 222 | 1 | 3µs | 1 | 12µs | return $t->{class}->__TOKENIZER__on_char( $t ); # spent 12µs making 1 call to PPI::Token::Operator::__TOKENIZER__on_char |
| 223 | |||||
| - - | |||||
| 226 | } elsif ( $c eq '&' ) { | ||||
| 227 | # Is it a number? | ||||
| 228 | 167 | 493µs | 167 | 118µs | if ( $char =~ /\d/ ) { # spent 118µs making 167 calls to PPI::Token::Unknown::CORE:match, avg 707ns/call |
| 229 | # This is &2 (bitwise-and number) | ||||
| 230 | $t->{class} = $t->{token}->set_class( 'Operator' ); | ||||
| 231 | return $t->_finalize_token->__TOKENIZER__on_char( $t ); | ||||
| 232 | } | ||||
| 233 | |||||
| 234 | # Is it a symbol | ||||
| 235 | 167 | 360µs | 167 | 87µs | if ( $char =~ /[\w:]/ ) { # spent 87µs making 167 calls to PPI::Token::Unknown::CORE:match, avg 522ns/call |
| 236 | 28 | 57µs | 28 | 263µs | $t->{class} = $t->{token}->set_class( 'Symbol' ); # spent 263µs making 28 calls to PPI::Token::set_class, avg 9µs/call |
| 237 | 28 | 56µs | return 1; | ||
| 238 | } | ||||
| 239 | |||||
| 240 | 139 | 246µs | 139 | 49µs | if ( $char =~ /[\$@%{]/ ) { # spent 49µs making 139 calls to PPI::Token::Unknown::CORE:match, avg 351ns/call |
| 241 | # The ampersand is a cast | ||||
| 242 | $t->{class} = $t->{token}->set_class( 'Cast' ); | ||||
| 243 | return $t->_finalize_token->__TOKENIZER__on_char( $t ); | ||||
| 244 | } | ||||
| 245 | |||||
| 246 | # Probably the binary and operator | ||||
| 247 | 139 | 301µs | 139 | 5.50ms | $t->{class} = $t->{token}->set_class( 'Operator' ); # spent 5.50ms making 139 calls to PPI::Token::set_class, avg 40µs/call |
| 248 | 139 | 479µs | 139 | 396µs | return $t->{class}->__TOKENIZER__on_char( $t ); # spent 396µs making 139 calls to PPI::Token::Operator::__TOKENIZER__on_char, avg 3µs/call |
| 249 | |||||
| - - | |||||
| 252 | } elsif ( $c eq '-' ) { | ||||
| 253 | 119 | 326µs | 119 | 78µs | if ( $char =~ /\d/o ) { # spent 78µs making 119 calls to PPI::Token::Unknown::CORE:match, avg 660ns/call |
| 254 | # Number | ||||
| 255 | 9 | 19µs | 9 | 78µs | $t->{class} = $t->{token}->set_class( 'Number' ); # spent 78µs making 9 calls to PPI::Token::set_class, avg 9µs/call |
| 256 | 9 | 18µs | return 1; | ||
| 257 | } | ||||
| 258 | |||||
| 259 | 110 | 31µs | if ( $char eq '.' ) { | ||
| 260 | # Number::Float | ||||
| 261 | $t->{class} = $t->{token}->set_class( 'Number::Float' ); | ||||
| 262 | return 1; | ||||
| 263 | } | ||||
| 264 | |||||
| 265 | 110 | 205µs | 110 | 42µs | if ( $char =~ /[a-zA-Z]/ ) { # spent 42µs making 110 calls to PPI::Token::Unknown::CORE:match, avg 382ns/call |
| 266 | 2 | 3µs | 2 | 16µs | $t->{class} = $t->{token}->set_class( 'DashedWord' ); # spent 16µs making 2 calls to PPI::Token::set_class, avg 8µs/call |
| 267 | 2 | 4µs | return 1; | ||
| 268 | } | ||||
| 269 | |||||
| 270 | # The numeric negative operator | ||||
| 271 | 108 | 222µs | 108 | 952µs | $t->{class} = $t->{token}->set_class( 'Operator' ); # spent 952µs making 108 calls to PPI::Token::set_class, avg 9µs/call |
| 272 | 108 | 372µs | 108 | 319µs | return $t->{class}->__TOKENIZER__on_char( $t ); # spent 319µs making 108 calls to PPI::Token::Operator::__TOKENIZER__on_char, avg 3µs/call |
| 273 | |||||
| - - | |||||
| 276 | } elsif ( $c eq ':' ) { | ||||
| 277 | 25 | 8µs | if ( $char eq ':' ) { | ||
| 278 | # ::foo style bareword | ||||
| 279 | $t->{class} = $t->{token}->set_class( 'Word' ); | ||||
| 280 | return 1; | ||||
| 281 | } | ||||
| 282 | |||||
| 283 | # Now, : acts very very differently in different contexts. | ||||
| 284 | # Mainly, we need to find out if this is a subroutine attribute. | ||||
| 285 | # We'll leave a hint in the token to indicate that, if it is. | ||||
| 286 | 25 | 50µs | 25 | 1.04ms | if ( $_[0]->__TOKENIZER__is_an_attribute( $t ) ) { # spent 1.04ms making 25 calls to PPI::Token::Unknown::__TOKENIZER__is_an_attribute, avg 42µs/call |
| 287 | # This : is an attribute indicator | ||||
| 288 | $t->{class} = $t->{token}->set_class( 'Operator' ); | ||||
| 289 | $t->{token}->{_attribute} = 1; | ||||
| 290 | return $t->_finalize_token->__TOKENIZER__on_char( $t ); | ||||
| 291 | } | ||||
| 292 | |||||
| 293 | # It MIGHT be a label, but its probably the ?: trinary operator | ||||
| 294 | 25 | 54µs | 25 | 212µs | $t->{class} = $t->{token}->set_class( 'Operator' ); # spent 212µs making 25 calls to PPI::Token::set_class, avg 8µs/call |
| 295 | 25 | 75µs | 25 | 325µs | return $t->{class}->__TOKENIZER__on_char( $t ); # spent 325µs making 25 calls to PPI::Token::Operator::__TOKENIZER__on_char, avg 13µs/call |
| 296 | } | ||||
| 297 | |||||
| 298 | # erm... | ||||
| 299 | PPI::Exception->throw('Unknown value in PPI::Token::Unknown token'); | ||||
| 300 | } | ||||
| 301 | |||||
| 302 | # Are we at a location where a ':' would indicate a subroutine attribute | ||||
| 303 | # spent 1.04ms (345µs+694µs) within PPI::Token::Unknown::__TOKENIZER__is_an_attribute which was called 25 times, avg 42µs/call:
# 25 times (345µs+694µs) by PPI::Token::Unknown::__TOKENIZER__on_char at line 286, avg 42µs/call | ||||
| 304 | 25 | 10µs | my $t = $_[1]; # Tokenizer object | ||
| 305 | 25 | 40µs | 25 | 588µs | my $tokens = $t->_previous_significant_tokens(3); # spent 588µs making 25 calls to PPI::Tokenizer::_previous_significant_tokens, avg 24µs/call |
| 306 | 25 | 11µs | my $p0 = $tokens->[0]; | ||
| 307 | |||||
| 308 | # If we just had another attribute, we are also an attribute | ||||
| 309 | 25 | 113µs | 25 | 44µs | return 1 if $p0->isa('PPI::Token::Attribute'); # spent 44µs making 25 calls to UNIVERSAL::isa, avg 2µs/call |
| 310 | |||||
| 311 | # If we just had a prototype, then we are an attribute | ||||
| 312 | 25 | 98µs | 25 | 36µs | return 1 if $p0->isa('PPI::Token::Prototype'); # spent 36µs making 25 calls to UNIVERSAL::isa, avg 1µs/call |
| 313 | |||||
| 314 | # Other than that, we would need to have had a bareword | ||||
| 315 | 25 | 154µs | 25 | 26µs | return '' unless $p0->isa('PPI::Token::Word'); # spent 26µs making 25 calls to UNIVERSAL::isa, avg 1µs/call |
| 316 | |||||
| 317 | # We could be an anonymous subroutine | ||||
| 318 | if ( $p0->isa('PPI::Token::Word') and $p0->content eq 'sub' ) { | ||||
| 319 | return 1; | ||||
| 320 | } | ||||
| 321 | |||||
| 322 | # Or, we could be a named subroutine | ||||
| 323 | my $p1 = $tokens->[1]; | ||||
| 324 | my $p2 = $tokens->[2]; | ||||
| 325 | if ( | ||||
| 326 | $p1->isa('PPI::Token::Word') | ||||
| 327 | and | ||||
| 328 | $p1->content eq 'sub' | ||||
| 329 | and ( | ||||
| 330 | $p2->isa('PPI::Token::Structure') | ||||
| 331 | or ( | ||||
| 332 | $p2->isa('PPI::Token::Whitespace') | ||||
| 333 | and | ||||
| 334 | $p2->content eq '' | ||||
| 335 | ) | ||||
| 336 | ) | ||||
| 337 | ) { | ||||
| 338 | return 1; | ||||
| 339 | } | ||||
| 340 | |||||
| 341 | # We arn't an attribute | ||||
| 342 | ''; | ||||
| 343 | } | ||||
| 344 | |||||
| 345 | 1 | 2µs | 1; | ||
| 346 | |||||
| 347 | =pod | ||||
| 348 | |||||
| 349 | =head1 SUPPORT | ||||
| 350 | |||||
| 351 | See the L<support section|PPI/SUPPORT> in the main module. | ||||
| 352 | |||||
| 353 | =head1 AUTHOR | ||||
| 354 | |||||
| 355 | Adam Kennedy E<lt>adamk@cpan.orgE<gt> | ||||
| 356 | |||||
| 357 | =head1 COPYRIGHT | ||||
| 358 | |||||
| 359 | Copyright 2001 - 2011 Adam Kennedy. | ||||
| 360 | |||||
| 361 | This program is free software; you can redistribute | ||||
| 362 | it and/or modify it under the same terms as Perl itself. | ||||
| 363 | |||||
| 364 | The full text of the license can be found in the | ||||
| 365 | LICENSE file included with this module. | ||||
| 366 | |||||
| 367 | =cut | ||||
# spent 8.85ms within PPI::Token::Unknown::CORE:match which was called 8844 times, avg 1µs/call:
# 6837 times (7.28ms+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 126, avg 1µs/call
# 888 times (890µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 155, avg 1µs/call
# 167 times (118µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 228, avg 707ns/call
# 167 times (87µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 235, avg 522ns/call
# 142 times (120µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 198, avg 843ns/call
# 142 times (99µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 185, avg 695ns/call
# 139 times (49µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 240, avg 351ns/call
# 119 times (78µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 253, avg 660ns/call
# 110 times (42µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 265, avg 382ns/call
# 85 times (57µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 170, avg 674ns/call
# 23 times (17µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 213, avg 752ns/call
# 22 times (15µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 206, avg 677ns/call
# 2 times (3µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 55, avg 1µs/call
# once (700ns+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 141 | |||||
# spent 2µs within PPI::Token::Unknown::CORE:qr which was called:
# once (2µs+0s) by PPI::Token::Unknown::BEGIN@35 at line 38 | |||||
# spent 280µs within PPI::Token::Unknown::CORE:regcomp which was called 108 times, avg 3µs/call:
# 85 times (233µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 170, avg 3µs/call
# 22 times (46µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 206, avg 2µs/call
# once (1µs+0s) by PPI::Token::Unknown::__TOKENIZER__on_char at line 141 |