| Filename | /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPI/Token/Number/Hex.pm |
| Statements | Executed 9 statements in 218µs |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 12µs | 23µs | PPI::Token::Number::Hex::BEGIN@29 |
| 1 | 1 | 1 | 9µs | 9µs | PPI::Token::Number::Hex::BEGIN@33 |
| 1 | 1 | 1 | 6µs | 34µs | PPI::Token::Number::Hex::BEGIN@32 |
| 1 | 1 | 1 | 3µs | 3µs | PPI::Token::Number::Hex::BEGIN@30 |
| 0 | 0 | 0 | 0s | 0s | PPI::Token::Number::Hex::__TOKENIZER__on_char |
| 0 | 0 | 0 | 0s | 0s | PPI::Token::Number::Hex::literal |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package PPI::Token::Number::Hex; | ||||
| 2 | |||||
| 3 | =pod | ||||
| 4 | |||||
| 5 | =head1 NAME | ||||
| 6 | |||||
| 7 | PPI::Token::Number::Hex - Token class for a binary number | ||||
| 8 | |||||
| 9 | =head1 SYNOPSIS | ||||
| 10 | |||||
| 11 | $n = 0x1234; # hexadecimal integer | ||||
| 12 | |||||
| 13 | =head1 INHERITANCE | ||||
| 14 | |||||
| 15 | PPI::Token::Number::Hex | ||||
| 16 | isa PPI::Token::Number | ||||
| 17 | isa PPI::Token | ||||
| 18 | isa PPI::Element | ||||
| 19 | |||||
| 20 | =head1 DESCRIPTION | ||||
| 21 | |||||
| 22 | The C<PPI::Token::Number::Hex> class is used for tokens that | ||||
| 23 | represent base-16 numbers. | ||||
| 24 | |||||
| 25 | =head1 METHODS | ||||
| 26 | |||||
| 27 | =cut | ||||
| 28 | |||||
| 29 | 2 | 19µs | 2 | 35µs | # spent 23µs (12+11) within PPI::Token::Number::Hex::BEGIN@29 which was called:
# once (12µs+11µs) by PPI::Token::BEGIN@45 at line 29 # spent 23µs making 1 call to PPI::Token::Number::Hex::BEGIN@29
# spent 12µs making 1 call to strict::import |
| 30 | 2 | 18µs | 1 | 3µs | # spent 3µs within PPI::Token::Number::Hex::BEGIN@30 which was called:
# once (3µs+0s) by PPI::Token::BEGIN@45 at line 30 # spent 3µs making 1 call to PPI::Token::Number::Hex::BEGIN@30 |
| 31 | |||||
| 32 | 2 | 31µs | 2 | 61µs | # spent 34µs (6+27) within PPI::Token::Number::Hex::BEGIN@32 which was called:
# once (6µs+27µs) by PPI::Token::BEGIN@45 at line 32 # spent 34µs making 1 call to PPI::Token::Number::Hex::BEGIN@32
# spent 27µs making 1 call to vars::import |
| 33 | # spent 9µs within PPI::Token::Number::Hex::BEGIN@33 which was called:
# once (9µs+0s) by PPI::Token::BEGIN@45 at line 36 | ||||
| 34 | 1 | 300ns | $VERSION = '1.215'; | ||
| 35 | 1 | 9µs | @ISA = 'PPI::Token::Number'; | ||
| 36 | 1 | 139µs | 1 | 9µs | } # spent 9µs making 1 call to PPI::Token::Number::Hex::BEGIN@33 |
| 37 | |||||
| 38 | =pod | ||||
| 39 | |||||
| 40 | =head2 base | ||||
| 41 | |||||
| 42 | Returns the base for the number: 16. | ||||
| 43 | |||||
| 44 | =cut | ||||
| 45 | |||||
| 46 | sub base () { 16 } | ||||
| 47 | |||||
| 48 | =pod | ||||
| 49 | |||||
| 50 | =head2 literal | ||||
| 51 | |||||
| 52 | Return the numeric value of this token. | ||||
| 53 | |||||
| 54 | =cut | ||||
| 55 | |||||
| 56 | sub literal { | ||||
| 57 | my $self = shift; | ||||
| 58 | my $str = $self->_literal; | ||||
| 59 | my $neg = $str =~ s/^\-//; | ||||
| 60 | my $val = hex $str; | ||||
| 61 | return $neg ? -$val : $val; | ||||
| 62 | } | ||||
| 63 | |||||
| - - | |||||
| 68 | ##################################################################### | ||||
| 69 | # Tokenizer Methods | ||||
| 70 | |||||
| 71 | sub __TOKENIZER__on_char { | ||||
| 72 | my $class = shift; | ||||
| 73 | my $t = shift; | ||||
| 74 | my $char = substr( $t->{line}, $t->{line_cursor}, 1 ); | ||||
| 75 | |||||
| 76 | # Allow underscores straight through | ||||
| 77 | return 1 if $char eq '_'; | ||||
| 78 | |||||
| 79 | if ( $char =~ /[\da-f]/ ) { | ||||
| 80 | return 1; | ||||
| 81 | } | ||||
| 82 | |||||
| 83 | # Doesn't fit a special case, or is after the end of the token | ||||
| 84 | # End of token. | ||||
| 85 | $t->_finalize_token->__TOKENIZER__on_char( $t ); | ||||
| 86 | } | ||||
| 87 | |||||
| 88 | 1 | 2µs | 1; | ||
| 89 | |||||
| 90 | =pod | ||||
| 91 | |||||
| 92 | =head1 SUPPORT | ||||
| 93 | |||||
| 94 | See the L<support section|PPI/SUPPORT> in the main module. | ||||
| 95 | |||||
| 96 | =head1 AUTHOR | ||||
| 97 | |||||
| 98 | Chris Dolan E<lt>cdolan@cpan.orgE<gt> | ||||
| 99 | |||||
| 100 | =head1 COPYRIGHT | ||||
| 101 | |||||
| 102 | Copyright 2006 Chris Dolan. | ||||
| 103 | |||||
| 104 | This program is free software; you can redistribute | ||||
| 105 | it and/or modify it under the same terms as Perl itself. | ||||
| 106 | |||||
| 107 | The full text of the license can be found in the | ||||
| 108 | LICENSE file included with this module. | ||||
| 109 | |||||
| 110 | =cut |