← Index
NYTProf Performance Profile   « line view »
For /Users/timbo/perl5/perlbrew/perls/perl-5.18.2/bin/perlcritic
  Run on Sat Mar 19 22:12:22 2016
Reported on Sat Mar 19 22:14:13 2016

Filename/Users/timbo/perl5/perlbrew/perls/perl-5.18.2/lib/site_perl/5.18.2/PPIx/Regexp/Token/Code.pm
StatementsExecuted 16 statements in 396µs
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
11114µs26µsPPIx::Regexp::Token::Code::::BEGIN@44PPIx::Regexp::Token::Code::BEGIN@44
1118µs12µsPPIx::Regexp::Token::Code::::BEGIN@45PPIx::Regexp::Token::Code::BEGIN@45
1117µs56µsPPIx::Regexp::Token::Code::::BEGIN@47PPIx::Regexp::Token::Code::BEGIN@47
1116µs25µsPPIx::Regexp::Token::Code::::BEGIN@51PPIx::Regexp::Token::Code::BEGIN@51
1116µs26µsPPIx::Regexp::Token::Code::::BEGIN@50PPIx::Regexp::Token::Code::BEGIN@50
1114µs4µsPPIx::Regexp::Token::Code::::BEGIN@49PPIx::Regexp::Token::Code::BEGIN@49
0000s0sPPIx::Regexp::Token::Code::::__PPIX_TOKENIZER__regexpPPIx::Regexp::Token::Code::__PPIX_TOKENIZER__regexp
0000s0sPPIx::Regexp::Token::Code::::__PPIX_TOKEN__post_makePPIx::Regexp::Token::Code::__PPIX_TOKEN__post_make
0000s0sPPIx::Regexp::Token::Code::::_newPPIx::Regexp::Token::Code::_new
0000s0sPPIx::Regexp::Token::Code::::contentPPIx::Regexp::Token::Code::content
0000s0sPPIx::Regexp::Token::Code::::perl_version_introducedPPIx::Regexp::Token::Code::perl_version_introduced
0000s0sPPIx::Regexp::Token::Code::::ppiPPIx::Regexp::Token::Code::ppi
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1=head1 NAME
2
3PPIx::Regexp::Token::Code - Represent a chunk of Perl embedded in a regular expression.
4
5=head1 SYNOPSIS
6
7 use PPIx::Regexp::Dumper;
8 PPIx::Regexp::Dumper->new(
9 'qr{(?{print "hello sailor\n"})}smx')->print;
10
11=head1 INHERITANCE
12
13C<PPIx::Regexp::Token::Code> is a
14L<PPIx::Regexp::Token|PPIx::Regexp::Token>.
15
16C<PPIx::Regexp::Token::Code> is the parent of
17L<PPIx::Regexp::Token::Interpolation|PPIx::Regexp::Token::Interpolation>.
18
19=head1 DESCRIPTION
20
21This class represents a chunk of Perl code embedded in a regular
22expression. Specifically, it results from parsing things like
23
24 (?{ code })
25 (??{ code })
26
27or from the replacement side of an s///e. Technically, interpolations
28are also code, but they parse differently and therefore end up in a
29different token.
30
31This token may not appear inside a regex set (i.e. C<(?[ ... ])>. If
32found, it will become a C<PPIx::Regexp::Token::Unknown>.
33
34=head1 METHODS
35
36This class provides the following public methods. Methods not documented
37here are private, and unsupported in the sense that the author reserves
38the right to change or remove them without notice.
39
40=cut
41
42package PPIx::Regexp::Token::Code;
43
44220µs239µs
# spent 26µs (14+12) within PPIx::Regexp::Token::Code::BEGIN@44 which was called: # once (14µs+12µs) by PPIx::Regexp::Tokenizer::BEGIN@20 at line 44
use strict;
# spent 26µs making 1 call to PPIx::Regexp::Token::Code::BEGIN@44 # spent 12µs making 1 call to strict::import
45221µs217µs
# spent 12µs (8+5) within PPIx::Regexp::Token::Code::BEGIN@45 which was called: # once (8µs+5µs) by PPIx::Regexp::Tokenizer::BEGIN@20 at line 45
use warnings;
# spent 12µs making 1 call to PPIx::Regexp::Token::Code::BEGIN@45 # spent 5µs making 1 call to warnings::import
46
47220µs2104µs
# spent 56µs (7+49) within PPIx::Regexp::Token::Code::BEGIN@47 which was called: # once (7µs+49µs) by PPIx::Regexp::Tokenizer::BEGIN@20 at line 47
use base qw{ PPIx::Regexp::Token };
# spent 56µs making 1 call to PPIx::Regexp::Token::Code::BEGIN@47 # spent 49µs making 1 call to base::import
48
49219µs14µs
# spent 4µs within PPIx::Regexp::Token::Code::BEGIN@49 which was called: # once (4µs+0s) by PPIx::Regexp::Tokenizer::BEGIN@20 at line 49
use PPI::Document;
# spent 4µs making 1 call to PPIx::Regexp::Token::Code::BEGIN@49
50224µs245µs
# spent 26µs (6+19) within PPIx::Regexp::Token::Code::BEGIN@50 which was called: # once (6µs+19µs) by PPIx::Regexp::Tokenizer::BEGIN@20 at line 50
use PPIx::Regexp::Constant qw{ COOKIE_REGEX_SET };
# spent 26µs making 1 call to PPIx::Regexp::Token::Code::BEGIN@50 # spent 19µs making 1 call to Exporter::import
512287µs244µs
# spent 25µs (6+19) within PPIx::Regexp::Token::Code::BEGIN@51 which was called: # once (6µs+19µs) by PPIx::Regexp::Tokenizer::BEGIN@20 at line 51
use PPIx::Regexp::Util qw{ __instance };
# spent 25µs making 1 call to PPIx::Regexp::Token::Code::BEGIN@51 # spent 19µs making 1 call to Exporter::import
52
531600nsour $VERSION = '0.036';
54
55sub _new {
56 my ( $class, $content ) = @_;
57 ref $class and $class = ref $class;
58
59 my $self = {};
60 if ( __instance( $content, 'PPI::Document' ) ) {
61 $self->{ppi} = $content;
62 } elsif ( ref $content ) {
63 return;
64 } else {
65 $self->{content} = $content;
66 }
67 bless $self, $class;
68 return $self;
69}
70
71sub content {
72 my ( $self ) = @_;
73 if ( exists $self->{content} ) {
74 return $self->{content};
75 } elsif ( exists $self->{ppi} ) {
76 return ( $self->{content} = $self->{ppi}->content() );
77 } else {
78 return;
79 }
80}
81
82sub perl_version_introduced {
83 my ( $self ) = @_;
84 return $self->{perl_version_introduced};
85}
86
87=head2 ppi
88
89This convenience method returns the L<PPI::Document|PPI::Document>
90representing the content. This document should be considered read only.
91
92=cut
93
94sub ppi {
95 my ( $self ) = @_;
96 if ( exists $self->{ppi} ) {
97 return $self->{ppi};
98 } elsif ( exists $self->{content} ) {
99 return ( $self->{ppi} = PPI::Document->new(
100 \($self->{content}), readonly => 1 ) );
101 } else {
102 return;
103 }
104}
105
106# Return true if the token can be quantified, and false otherwise
107# sub can_be_quantified { return };
108
109{
110
11122µs my %default = (
112 perl_version_introduced => '5.005', # When (?{...}) introduced.
113 );
114
115 sub __PPIX_TOKEN__post_make {
116 my ( $self, $tokenizer, $arg ) = @_;
117
118 $self->__impose_defaults( $arg, \%default );
119
120 # If we're manufacturing objects directly (which is UNSUPPORTED,
121 # but used in t/version.t) we may not have a $tokenizer.
122 $tokenizer
123 and $tokenizer->cookie( COOKIE_REGEX_SET )
124 and $self->__error( 'Code token not valid in Regex set' );
125
126 return;
127 }
128
129}
130
131sub __PPIX_TOKENIZER__regexp {
132 my ( $class, $tokenizer, $character ) = @_;
133
134 $character eq '{' or return;
135
136 my $offset = $tokenizer->find_matching_delimiter()
137 or return;
138
139 return $offset + 1; # to include the closing delimiter.
140}
141
14213µs1;
143
144__END__