line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Method::Signatures::Parameter; |
2
|
|
|
|
|
|
|
|
3
|
63
|
|
|
63
|
|
22746
|
use Mouse; |
|
63
|
|
|
|
|
1172068
|
|
|
63
|
|
|
|
|
191
|
|
4
|
63
|
|
|
63
|
|
13877
|
use Carp; |
|
63
|
|
|
|
|
87
|
|
|
63
|
|
|
|
|
3155
|
|
5
|
63
|
|
|
63
|
|
572
|
use Method::Signatures::Utils; |
|
63
|
|
|
|
|
82
|
|
|
63
|
|
|
|
|
7535
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
my $IDENTIFIER = qr{ [^\W\d] \w* }x; |
8
|
|
|
|
|
|
|
my $VARIABLE = qr{ [\$\@%] $IDENTIFIER? }x; |
9
|
|
|
|
|
|
|
my $TYPENAME = qr{ $IDENTIFIER (?: \:\: $IDENTIFIER )* }x; |
10
|
|
|
|
|
|
|
our $PARAMETERIZED; |
11
|
63
|
|
|
63
|
|
251
|
$PARAMETERIZED = do{ use re 'eval'; |
|
63
|
|
|
|
|
68
|
|
|
63
|
|
|
|
|
92510
|
|
12
|
|
|
|
|
|
|
qr{ $TYPENAME (?: \[ (??{$PARAMETERIZED}) \] )? }x; |
13
|
|
|
|
|
|
|
}; |
14
|
|
|
|
|
|
|
my $TYPESPEC = qr{ ^ \s* $PARAMETERIZED (?: \s* \| \s* $PARAMETERIZED )* \s* }x; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has original_code => |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => 'Str', |
19
|
|
|
|
|
|
|
required => 1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Note: Have to preparse with regexes up to traits |
22
|
|
|
|
|
|
|
# because :, ! and ? in sigs confuse PPI |
23
|
|
|
|
|
|
|
has ppi_clean_code => |
24
|
|
|
|
|
|
|
is => 'rw', |
25
|
|
|
|
|
|
|
isa => 'Str', |
26
|
|
|
|
|
|
|
; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has is_yadayada => |
29
|
|
|
|
|
|
|
is => 'ro', |
30
|
|
|
|
|
|
|
isa => 'Bool', |
31
|
|
|
|
|
|
|
lazy => 1, |
32
|
|
|
|
|
|
|
default => sub { |
33
|
|
|
|
|
|
|
my $self = shift; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return $self->original_code =~ m{^ \s* (?:\Q...\E)|(?:@) \s* $}x; |
36
|
|
|
|
|
|
|
}; |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
has is_hash_yadayada => |
39
|
|
|
|
|
|
|
is => 'ro', |
40
|
|
|
|
|
|
|
isa => 'Bool', |
41
|
|
|
|
|
|
|
lazy => 1, |
42
|
|
|
|
|
|
|
default => sub { |
43
|
|
|
|
|
|
|
my $self = shift; |
44
|
|
|
|
|
|
|
return $self->original_code =~ m{^ \s* % \s* $}x; |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has type => |
48
|
|
|
|
|
|
|
is => 'rw', |
49
|
|
|
|
|
|
|
isa => 'Str', |
50
|
|
|
|
|
|
|
default => ''; |
51
|
|
|
|
|
|
|
; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
has is_ref_alias => |
54
|
|
|
|
|
|
|
is => 'rw', |
55
|
|
|
|
|
|
|
isa => 'Bool', |
56
|
|
|
|
|
|
|
default => 0; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has is_named => |
59
|
|
|
|
|
|
|
is => 'rw', |
60
|
|
|
|
|
|
|
isa => 'Bool', |
61
|
|
|
|
|
|
|
; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub is_positional { |
64
|
835
|
|
|
835
|
0
|
617
|
my $self = shift; |
65
|
|
|
|
|
|
|
|
66
|
835
|
|
|
|
|
2375
|
return !$self->is_named; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has variable => |
70
|
|
|
|
|
|
|
is => 'rw', |
71
|
|
|
|
|
|
|
isa => 'Str', |
72
|
|
|
|
|
|
|
default => ''; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has is_placeholder => |
75
|
|
|
|
|
|
|
is => 'rw', |
76
|
|
|
|
|
|
|
isa => 'Bool', |
77
|
|
|
|
|
|
|
default => 0; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has first_line_number => |
80
|
|
|
|
|
|
|
is => 'rw', |
81
|
|
|
|
|
|
|
isa => 'Int'; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
has position => |
84
|
|
|
|
|
|
|
is => 'rw', |
85
|
|
|
|
|
|
|
isa => 'Maybe[Int]', # XXX 0 or positive int |
86
|
|
|
|
|
|
|
trigger => sub { |
87
|
|
|
|
|
|
|
my($self, $new_position, $old_position) = @_; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
if( $self->is_named ) { |
90
|
|
|
|
|
|
|
croak("A named parameter cannot have a position") |
91
|
|
|
|
|
|
|
if defined $new_position and length $new_position; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
else { # positional parameter |
94
|
|
|
|
|
|
|
croak("A positional parameter must have a position") |
95
|
|
|
|
|
|
|
if !(defined $new_position and length $new_position); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
}; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has sigil => |
100
|
|
|
|
|
|
|
is => 'rw', |
101
|
|
|
|
|
|
|
isa => 'Str', # XXX [%$@*] |
102
|
|
|
|
|
|
|
; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
has variable_name => |
105
|
|
|
|
|
|
|
is => 'rw', |
106
|
|
|
|
|
|
|
isa => 'Str', |
107
|
|
|
|
|
|
|
; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
has where => |
110
|
|
|
|
|
|
|
is => 'rw', |
111
|
|
|
|
|
|
|
isa => 'ArrayRef', |
112
|
|
|
|
|
|
|
default => sub { [] }; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub has_where { |
115
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
116
|
|
|
|
|
|
|
|
117
|
0
|
0
|
|
|
|
0
|
return @{$self->where} ? 1 : 0; |
|
0
|
|
|
|
|
0
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
has traits => |
121
|
|
|
|
|
|
|
is => 'rw', |
122
|
|
|
|
|
|
|
isa => 'HashRef[Int]', |
123
|
|
|
|
|
|
|
default => sub { {} }; |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub has_traits { |
126
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
127
|
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
0
|
return keys %{$self->traits} ? 1 : 0; |
|
0
|
|
|
|
|
0
|
|
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
has default => |
132
|
|
|
|
|
|
|
is => 'rw', |
133
|
|
|
|
|
|
|
isa => 'Maybe[Str]' |
134
|
|
|
|
|
|
|
; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
has default_when => |
137
|
|
|
|
|
|
|
is => 'rw', |
138
|
|
|
|
|
|
|
isa => 'Str', |
139
|
|
|
|
|
|
|
; |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
has passed_in => |
142
|
|
|
|
|
|
|
is => 'rw', |
143
|
|
|
|
|
|
|
isa => 'Str', |
144
|
|
|
|
|
|
|
; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
has check_exists => |
147
|
|
|
|
|
|
|
is => 'rw', |
148
|
|
|
|
|
|
|
isa => 'Str' |
149
|
|
|
|
|
|
|
; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
has is_slurpy => |
152
|
|
|
|
|
|
|
is => 'ro', |
153
|
|
|
|
|
|
|
isa => 'Bool', |
154
|
|
|
|
|
|
|
lazy => 1, |
155
|
|
|
|
|
|
|
default => sub { |
156
|
|
|
|
|
|
|
my $self = shift; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
return 0 if $self->is_ref_alias; |
159
|
|
|
|
|
|
|
return 0 if !$self->sigil; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
return $self->sigil =~ m{ ^ [%\@] $ }x; |
162
|
|
|
|
|
|
|
}; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
has is_at_underscore => |
165
|
|
|
|
|
|
|
is => 'ro', |
166
|
|
|
|
|
|
|
isa => 'Bool', |
167
|
|
|
|
|
|
|
lazy => 1, |
168
|
|
|
|
|
|
|
default => sub { |
169
|
|
|
|
|
|
|
my $self = shift; |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
return $self->variable eq '@_'; |
172
|
|
|
|
|
|
|
}; |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
has required_flag => |
175
|
|
|
|
|
|
|
is => 'rw', |
176
|
|
|
|
|
|
|
isa => 'Str', |
177
|
|
|
|
|
|
|
default => ''; |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
has is_required => |
180
|
|
|
|
|
|
|
is => 'rw', |
181
|
|
|
|
|
|
|
isa => 'Bool', |
182
|
|
|
|
|
|
|
; |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# A PPI::Document representing the parameter |
185
|
|
|
|
|
|
|
has ppi_doc => |
186
|
|
|
|
|
|
|
is => 'ro', |
187
|
|
|
|
|
|
|
isa => 'PPI::Document', |
188
|
|
|
|
|
|
|
lazy => 1, |
189
|
|
|
|
|
|
|
default => sub { |
190
|
|
|
|
|
|
|
my $code = $_[0]->ppi_clean_code; |
191
|
|
|
|
|
|
|
return new_ppi_doc(\$code); |
192
|
|
|
|
|
|
|
}; |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
sub is_optional { |
196
|
692
|
|
|
692
|
0
|
489
|
my $self = shift; |
197
|
|
|
|
|
|
|
|
198
|
692
|
|
|
|
|
2067
|
return !$self->is_required; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
sub BUILD { |
202
|
341
|
|
|
341
|
1
|
347
|
my $self = shift; |
203
|
|
|
|
|
|
|
|
204
|
341
|
100
|
|
|
|
910
|
return if $self->is_yadayada; |
205
|
|
|
|
|
|
|
|
206
|
335
|
|
|
|
|
543
|
$self->_preparse_original_code_for_ppi; |
207
|
334
|
|
|
|
|
501
|
$self->_parse_with_ppi; |
208
|
333
|
|
|
|
|
511
|
$self->_init_split_variable; |
209
|
333
|
|
|
|
|
444
|
$self->_init_is_required; |
210
|
|
|
|
|
|
|
|
211
|
333
|
|
|
|
|
734
|
return; |
212
|
|
|
|
|
|
|
} |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
sub _init_is_required { |
216
|
333
|
|
|
333
|
|
282
|
my $self = shift; |
217
|
|
|
|
|
|
|
|
218
|
333
|
|
|
|
|
437
|
$self->is_required( $self->_determine_is_required ); |
219
|
|
|
|
|
|
|
} |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub _determine_is_required { |
223
|
333
|
|
|
333
|
|
264
|
my $self = shift; |
224
|
|
|
|
|
|
|
|
225
|
333
|
100
|
|
|
|
747
|
return 1 if $self->required_flag eq '!'; |
226
|
|
|
|
|
|
|
|
227
|
324
|
100
|
|
|
|
626
|
return 0 if $self->required_flag eq '?'; |
228
|
310
|
100
|
|
|
|
412
|
return 0 if $self->has_default; |
229
|
206
|
100
|
|
|
|
603
|
return 0 if $self->is_named; |
230
|
165
|
100
|
|
|
|
477
|
return 0 if $self->is_slurpy; |
231
|
|
|
|
|
|
|
|
232
|
140
|
|
|
|
|
449
|
return 1; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
sub has_default { |
237
|
310
|
|
|
310
|
0
|
267
|
my $self = shift; |
238
|
|
|
|
|
|
|
|
239
|
310
|
|
|
|
|
983
|
return defined $self->default; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub _parse_with_ppi { |
243
|
334
|
|
|
334
|
|
336
|
my $self = shift; |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
# Nothing to parse. |
246
|
334
|
100
|
|
|
|
852
|
return if $self->ppi_clean_code !~ /\S/; |
247
|
|
|
|
|
|
|
|
248
|
|
|
|
|
|
|
# Replace parameter var so as not to confuse PPI... |
249
|
117
|
|
|
|
|
481
|
$self->ppi_clean_code($self->variable. " " .$self->ppi_clean_code); |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
# Tokenize... |
252
|
117
|
|
|
|
|
350
|
my $components = $self->ppi_doc; |
253
|
117
|
50
|
|
|
|
285
|
my $statement = $components->find_first("PPI::Statement") |
254
|
0
|
|
|
|
|
0
|
or sig_parsing_error("Could not understand parameter specification: @{[$self->ppi_clean_code]}"); |
255
|
117
|
|
|
|
|
16739
|
my $tokens = [ $statement->children ]; |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
# Re-remove parameter var |
258
|
117
|
|
|
|
|
558
|
shift @$tokens; |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# Extract any 'where' constraints... |
261
|
117
|
|
|
|
|
407
|
while ($self->_extract_leading(qr{^ where $}x, $tokens)) { |
262
|
9
|
50
|
|
|
|
105
|
sig_parsing_error("'where' constraint only available under Perl 5.10 or later. Error") |
263
|
|
|
|
|
|
|
if $] < 5.010; |
264
|
9
|
|
|
|
|
10
|
push @{$self->where}, $self->_extract_until(qr{^ (?: where | is | = | //= ) $}x, $tokens); |
|
9
|
|
|
|
|
40
|
|
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
# Extract parameter traits... |
268
|
117
|
|
|
|
|
871
|
while ($self->_extract_leading(qr{^ is $}x, $tokens)) { |
269
|
25
|
|
|
|
|
301
|
$self->traits->{ $self->_extract_leading(qr{^ \S+ $}x, $tokens) }++; |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
# Extract normal default specifier (if any)... |
273
|
117
|
100
|
|
|
|
651
|
if ($self->_extract_leading(qr{^ = $}x, $tokens)) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
274
|
95
|
|
|
|
|
870
|
$self->default( $self->_extract_until(qr{^ when $}x, $tokens) ); |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
# Extract 'when' modifier (if any)... |
277
|
95
|
100
|
|
|
|
252
|
if ($self->_extract_leading(qr{^ when $}x, $tokens)) { |
278
|
44
|
50
|
|
|
|
401
|
sig_parsing_error("'when' modifier on default only available under Perl 5.10 or later. Error") |
279
|
|
|
|
|
|
|
if $] < 5.010; |
280
|
44
|
|
|
|
|
75
|
$self->default_when( join(q{}, @$tokens) ); |
281
|
44
|
|
|
|
|
466
|
$tokens = []; |
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
} |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
# Otherwise, extract undef-default specifier (if any)... |
286
|
|
|
|
|
|
|
elsif ($self->_extract_leading(qr{^ //= $}x, $tokens)) { |
287
|
10
|
50
|
|
|
|
93
|
sig_parsing_error("'//=' defaults only available under Perl 5.10 or later. Error") |
288
|
|
|
|
|
|
|
if $] < 5.010; |
289
|
10
|
|
|
|
|
30
|
$self->default_when('undef'); |
290
|
10
|
|
|
|
|
19
|
$self->default( join(q{}, @$tokens) ); |
291
|
10
|
|
|
|
|
87
|
$tokens = []; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
# Anything left over is an error... |
295
|
|
|
|
|
|
|
elsif (my $trailing = $self->_extract_leading(qr{ \S }x, $tokens)) { |
296
|
1
|
|
|
|
|
13
|
sig_parsing_error("Unexpected extra code after parameter specification: '", |
297
|
|
|
|
|
|
|
$trailing . join(q{}, @$tokens), "'" |
298
|
|
|
|
|
|
|
); |
299
|
|
|
|
|
|
|
} |
300
|
|
|
|
|
|
|
|
301
|
116
|
|
|
|
|
243
|
return; |
302
|
|
|
|
|
|
|
} |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
# Remove leading whitespace + token, if token matches the specified pattern... |
306
|
|
|
|
|
|
|
sub _extract_leading { |
307
|
539
|
|
|
539
|
|
751
|
my ($self, $selector_pat, $tokens) = @_; |
308
|
|
|
|
|
|
|
|
309
|
539
|
|
100
|
|
|
1291
|
while (@$tokens && $tokens->[0]->class eq 'PPI::Token::Whitespace') { |
310
|
159
|
|
|
|
|
985
|
shift @$tokens; |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
|
313
|
539
|
100
|
100
|
|
|
2752
|
return @$tokens && $tokens->[0] =~ $selector_pat |
314
|
|
|
|
|
|
|
? "" . shift @$tokens |
315
|
|
|
|
|
|
|
: undef; |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
|
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
# Remove tokens up to (but excluding) the first that matches the delimiter... |
320
|
|
|
|
|
|
|
sub _extract_until { |
321
|
104
|
|
|
104
|
|
107
|
my ($self, $delimiter_pat, $tokens) = @_; |
322
|
|
|
|
|
|
|
|
323
|
104
|
|
|
|
|
103
|
my $extracted = q{}; |
324
|
|
|
|
|
|
|
|
325
|
104
|
|
|
|
|
174
|
while (@$tokens) { |
326
|
330
|
100
|
|
|
|
1451
|
last if $tokens->[0] =~ $delimiter_pat; |
327
|
|
|
|
|
|
|
|
328
|
280
|
|
|
|
|
1772
|
my $token = shift @$tokens; |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
# Flatten multi-line data structures into a single line which |
331
|
|
|
|
|
|
|
# Devel::Declare can inject. |
332
|
280
|
100
|
|
304
|
|
829
|
$token->prune(sub { !$_[1]->significant }) if $token->isa("PPI::Node"); |
|
304
|
|
|
|
|
4823
|
|
333
|
|
|
|
|
|
|
|
334
|
280
|
|
|
|
|
1030
|
$extracted .= $token; |
335
|
|
|
|
|
|
|
} |
336
|
|
|
|
|
|
|
|
337
|
104
|
|
|
|
|
1068
|
return $extracted; |
338
|
|
|
|
|
|
|
} |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
sub _preparse_original_code_for_ppi { |
342
|
335
|
|
|
335
|
|
295
|
my $self = shift; |
343
|
|
|
|
|
|
|
|
344
|
335
|
|
|
|
|
496
|
my $original_code = $self->original_code; |
345
|
|
|
|
|
|
|
|
346
|
335
|
100
|
|
|
|
31508
|
$self->type($1) if $original_code =~ s{^ ($TYPESPEC) \s+ }{}ox; |
347
|
|
|
|
|
|
|
|
348
|
|
|
|
|
|
|
# Extract ref-alias & named-arg markers, param var, and required/optional marker... |
349
|
335
|
100
|
|
|
|
4058
|
$original_code =~ s{ ^ \s* ([\\:]*) \s* ($VARIABLE) \s* ([!?]?) }{}ox |
350
|
|
|
|
|
|
|
or sig_parsing_error("Could not understand parameter specification: $original_code"); |
351
|
334
|
|
|
|
|
857
|
my ($premod, $var, $postmod) = ($1, $2, $3); |
352
|
|
|
|
|
|
|
|
353
|
334
|
|
|
|
|
635
|
$self->is_ref_alias ($premod =~ m{ \\ }x); |
354
|
334
|
|
|
|
|
521
|
$self->is_named ($premod =~ m{ : }x); |
355
|
334
|
100
|
|
|
|
518
|
$self->required_flag($postmod) if $postmod; |
356
|
|
|
|
|
|
|
|
357
|
334
|
50
|
|
|
|
511
|
if ($var) { |
358
|
334
|
100
|
|
|
|
523
|
if ($var eq '$') { |
359
|
8
|
|
|
|
|
15
|
$self->is_placeholder(1); |
360
|
8
|
|
|
|
|
15
|
$self->variable('$tmp'); |
361
|
|
|
|
|
|
|
} else { |
362
|
326
|
|
|
|
|
648
|
$self->variable($var); |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
} |
365
|
|
|
|
|
|
|
|
366
|
334
|
|
|
|
|
692
|
$self->ppi_clean_code($original_code); |
367
|
|
|
|
|
|
|
|
368
|
334
|
|
|
|
|
496
|
return; |
369
|
|
|
|
|
|
|
} |
370
|
|
|
|
|
|
|
|
371
|
|
|
|
|
|
|
|
372
|
|
|
|
|
|
|
sub _init_split_variable { |
373
|
333
|
|
|
333
|
|
283
|
my $self = shift; |
374
|
|
|
|
|
|
|
|
375
|
333
|
|
|
|
|
885
|
$self->variable =~ /^(.) (.*)/x; |
376
|
|
|
|
|
|
|
|
377
|
333
|
|
|
|
|
1000
|
$self->sigil ($1); |
378
|
333
|
|
|
|
|
760
|
$self->variable_name($2); |
379
|
|
|
|
|
|
|
|
380
|
333
|
|
|
|
|
278
|
return; |
381
|
|
|
|
|
|
|
} |
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
|
384
|
|
|
|
|
|
|
# Check the integrity of one piece of the signature |
385
|
|
|
|
|
|
|
sub check { |
386
|
302
|
|
|
302
|
0
|
305
|
my($self, $signature) = @_; |
387
|
|
|
|
|
|
|
|
388
|
302
|
100
|
|
|
|
745
|
if( $self->is_slurpy ) { |
389
|
33
|
100
|
|
|
|
77
|
sig_parsing_error("Signature can only have one slurpy parameter") |
390
|
|
|
|
|
|
|
if $signature->num_slurpy >= 1; |
391
|
29
|
100
|
|
|
|
80
|
sig_parsing_error("Slurpy parameter '@{[$self->variable]}' cannot be named; use a reference instead") |
|
2
|
|
|
|
|
15
|
|
392
|
|
|
|
|
|
|
if $self->is_named; |
393
|
|
|
|
|
|
|
} |
394
|
|
|
|
|
|
|
|
395
|
296
|
100
|
|
|
|
619
|
if( $self->is_named ) { |
396
|
47
|
100
|
|
|
|
95
|
if( $signature->num_optional_positional ) { |
397
|
2
|
|
|
|
|
9
|
my $pos_var = $signature->positional_parameters->[-1]->variable; |
398
|
2
|
|
|
|
|
4
|
my $var = $self->variable; |
399
|
2
|
|
|
|
|
8
|
sig_parsing_error("Named parameter '$var' mixed with optional positional '$pos_var'"); |
400
|
|
|
|
|
|
|
} |
401
|
|
|
|
|
|
|
} |
402
|
|
|
|
|
|
|
else { # is_positional |
403
|
249
|
100
|
|
|
|
534
|
if( $signature->num_named ) { |
404
|
3
|
|
|
|
|
10
|
my $named_var = $signature->named_parameters->[-1]->variable; |
405
|
3
|
|
|
|
|
6
|
my $var = $self->variable; |
406
|
3
|
|
|
|
|
11
|
sig_parsing_error("Positional parameter '$var' after named param '$named_var'"); |
407
|
|
|
|
|
|
|
} |
408
|
|
|
|
|
|
|
|
409
|
|
|
|
|
|
|
# Required positional after an optional. |
410
|
|
|
|
|
|
|
# Required positional after a slurpy will be handled elsewhere. |
411
|
246
|
100
|
100
|
|
|
791
|
if( $self->is_required && $signature->num_optional_positional && |
|
|
|
100
|
|
|
|
|
412
|
|
|
|
|
|
|
!$signature->num_slurpy |
413
|
|
|
|
|
|
|
) { |
414
|
1
|
|
|
|
|
3
|
my $var = $self->variable; |
415
|
1
|
|
|
|
|
4
|
my $opt_pos_var = $signature->optional_positional_parameters->[-1] |
416
|
|
|
|
|
|
|
->variable; |
417
|
1
|
|
|
|
|
4
|
sig_parsing_error("Required positional parameter '$var' cannot follow an optional positional parameter '$opt_pos_var'"); |
418
|
|
|
|
|
|
|
} |
419
|
|
|
|
|
|
|
} |
420
|
|
|
|
|
|
|
|
421
|
290
|
|
|
|
|
403
|
return 1; |
422
|
|
|
|
|
|
|
} |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
1; |