line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Block::NamedVar::MapLike; |
2
|
6
|
|
|
6
|
|
26472
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
246
|
|
3
|
6
|
|
|
6
|
|
36
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
180
|
|
4
|
|
|
|
|
|
|
|
5
|
6
|
|
|
6
|
|
30
|
use Devel::Declare::Interface; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
420
|
|
6
|
6
|
|
|
6
|
|
36
|
use base 'Devel::Declare::Parser'; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
4836
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Devel::Declare::Interface::register_parser( 'map_var' ); |
9
|
|
|
|
|
|
|
__PACKAGE__->add_accessor( $_ ) for qw/dec var/; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub rewrite { |
12
|
42
|
|
|
42
|
1
|
131430
|
my $self = shift; |
13
|
|
|
|
|
|
|
|
14
|
42
|
50
|
|
|
|
48
|
if ( @{ $self->parts } > 2 ) { |
|
42
|
|
|
|
|
120
|
|
15
|
0
|
|
|
|
|
0
|
( undef, my @bad ) = @{ $self->parts }; |
|
0
|
|
|
|
|
0
|
|
16
|
0
|
|
|
|
|
0
|
$self->bail( |
17
|
|
|
|
|
|
|
"Syntax error near: " . join( ' and ', |
18
|
0
|
|
|
|
|
0
|
map { $self->format_part($_)} @bad |
19
|
|
|
|
|
|
|
) |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
42
|
|
|
|
|
276
|
my ($first, $second) = @{ $self->parts }; |
|
42
|
|
|
|
|
96
|
|
24
|
42
|
|
|
|
|
222
|
my ( $dec, $var ) = (""); |
25
|
42
|
100
|
|
|
|
36
|
if ( @{ $self->parts } > 1 ) { |
|
42
|
|
|
|
|
96
|
|
26
|
60
|
|
|
|
|
168
|
$self->bail( |
27
|
|
|
|
|
|
|
"Syntax error near: " . $self->format_part($first) |
28
|
30
|
50
|
|
|
|
174
|
) unless grep { $first->[0] eq $_ } qw/my our/; |
29
|
30
|
|
|
|
|
150
|
$dec = $first; |
30
|
30
|
|
|
|
|
42
|
$var = $second; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
else { |
33
|
12
|
|
|
|
|
54
|
$var = $first; |
34
|
12
|
100
|
|
|
|
36
|
$dec = ['my'] if ref $self->parts->[0]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
42
|
|
|
|
|
156
|
$var = $self->format_var( $var ); |
38
|
42
|
|
|
|
|
138
|
$self->dec( $dec ); |
39
|
42
|
|
|
|
|
288
|
$self->var( $var ); |
40
|
|
|
|
|
|
|
|
41
|
42
|
|
|
|
|
300
|
$self->new_parts([]); |
42
|
42
|
|
|
|
|
234
|
1; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub format_var { |
46
|
42
|
|
|
42
|
0
|
42
|
my $self = shift; |
47
|
42
|
|
|
|
|
66
|
my ( $var ) = @_; |
48
|
42
|
100
|
|
|
|
90
|
if ( ref $var ) { |
49
|
6
|
|
|
|
|
12
|
$var = $var->[0]; |
50
|
|
|
|
|
|
|
} |
51
|
42
|
100
|
|
|
|
186
|
return $var if $var =~ m/^\$\w[\w\d_]*$/; |
52
|
6
|
50
|
|
|
|
36
|
return "\$$var" if $var =~ m/^\w[\w\d_]*$/; |
53
|
0
|
|
|
|
|
0
|
$self->bail( "Syntax error, '$var' is not a valid block variable name" ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub inject { |
57
|
42
|
|
|
42
|
1
|
894
|
my $self = shift; |
58
|
42
|
100
|
|
|
|
96
|
my $dec = $self->dec ? $self->dec->[0] : ''; |
59
|
42
|
|
|
|
|
474
|
my $var = $self->var; |
60
|
42
|
|
|
|
|
306
|
return ( "$dec $var = \$_" ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub _scope_end { |
64
|
42
|
|
|
42
|
|
6480
|
my $class = shift; |
65
|
42
|
|
|
|
|
66
|
my ( $id ) = @_; |
66
|
42
|
|
|
|
|
96
|
my $self = Devel::Declare::Parser::_unstash( $id ); |
67
|
|
|
|
|
|
|
|
68
|
42
|
|
|
|
|
258
|
my $linestr = $self->line; |
69
|
42
|
|
|
|
|
306
|
$self->offset( $self->_linestr_offset_from_dd() ); |
70
|
42
|
|
|
|
|
342
|
substr($linestr, $self->offset, 0) = ', '; |
71
|
42
|
|
|
|
|
252
|
$self->line($linestr); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub open_line { |
75
|
42
|
|
|
42
|
1
|
252
|
my $self = shift; |
76
|
42
|
|
|
|
|
90
|
return ""; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
1; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
__END__ |