line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Variable::Lazy; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
47537
|
use strict; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
95
|
|
4
|
2
|
|
|
2
|
|
10
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
118
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
7
|
2
|
|
|
2
|
|
1180
|
use Variable::Lazy::Guts; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
107
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
2117
|
use Devel::Declare; |
|
2
|
|
|
|
|
47003
|
|
|
2
|
|
|
|
|
30
|
|
10
|
2
|
|
|
2
|
|
2996
|
use B::Hooks::EndOfScope; |
|
2
|
|
|
|
|
49624
|
|
|
2
|
|
|
|
|
16
|
|
11
|
2
|
|
|
2
|
|
168
|
use Carp qw/croak/; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
92
|
|
12
|
2
|
|
|
2
|
|
1819
|
use namespace::clean; |
|
2
|
|
|
|
|
10267
|
|
|
2
|
|
|
|
|
13
|
|
13
|
|
|
|
|
|
|
our @CARP_NOT = qw/Devel::Declare/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub import { |
16
|
2
|
|
|
2
|
|
17
|
my $package = caller; |
17
|
|
|
|
|
|
|
|
18
|
2
|
|
|
|
|
20
|
Devel::Declare->setup_for($package, { lazy => { const => \&_parser } }); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
{ |
21
|
2
|
|
|
2
|
|
1066
|
no strict 'refs'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1142
|
|
|
2
|
|
|
|
|
52
|
|
22
|
2
|
|
|
|
|
17
|
*{ $package . '::lazy' } = \&Variable::Lazy::Guts::lazy; |
|
2
|
|
|
|
|
44
|
|
23
|
|
|
|
|
|
|
} |
24
|
2
|
|
|
|
|
39
|
return; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub _parser { |
28
|
7
|
|
|
7
|
|
544
|
my ($declarator, $offset) = @_; |
29
|
7
|
|
|
|
|
14
|
my $linestr = Devel::Declare::get_linestr; |
30
|
7
|
|
|
|
|
13
|
$offset += Devel::Declare::toke_move_past_token($offset); |
31
|
7
|
|
|
|
|
12
|
$offset += Devel::Declare::toke_skipspace($offset); |
32
|
|
|
|
|
|
|
|
33
|
7
|
100
|
|
|
|
15
|
if (substr($linestr, $offset, 1) eq '{') { |
34
|
2
|
|
|
|
|
4
|
substr $linestr, $offset, 1, q/(Variable::Lazy::_variable(), \\@_, sub { BEGIN { Variable::Lazy::_inject_scope(')') }; /; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
5
|
100
|
|
|
|
14
|
if (my $length = Devel::Declare::toke_scan_word($offset, 0)) { |
38
|
4
|
|
|
|
|
6
|
my $word = substr $linestr, $offset, $length; |
39
|
4
|
50
|
33
|
|
|
13
|
croak "Invalid word '$word' in lazy expression" unless $word eq 'my' or $word eq 'our'; |
40
|
4
|
|
|
|
|
3
|
$offset += $length; |
41
|
4
|
|
|
|
|
7
|
$offset += Devel::Declare::toke_skipspace($offset); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
5
|
50
|
|
|
|
13
|
croak 'Variable expected' if substr($linestr, $offset, 1) ne '$'; |
45
|
5
|
|
33
|
|
|
18
|
$offset += Devel::Declare::toke_scan_ident($offset) || croak 'Variable name expected'; |
46
|
|
|
|
|
|
|
|
47
|
5
|
|
|
|
|
8
|
$offset += Devel::Declare::toke_skipspace($offset); |
48
|
|
|
|
|
|
|
|
49
|
5
|
50
|
|
|
|
10
|
croak 'Assignment expected' if substr($linestr, $offset, 1) ne '='; |
50
|
5
|
|
|
|
|
7
|
substr $linestr, $offset++, 1, ','; |
51
|
|
|
|
|
|
|
|
52
|
5
|
|
|
|
|
8
|
$offset += Devel::Declare::toke_skipspace($offset); |
53
|
|
|
|
|
|
|
|
54
|
5
|
50
|
|
|
|
10
|
croak 'Opening bracket expected' if substr($linestr, $offset, 1) ne '{'; |
55
|
5
|
|
|
|
|
7
|
substr $linestr, $offset, 1, q/\\@_, sub { /; |
56
|
|
|
|
|
|
|
} |
57
|
7
|
|
|
|
|
10
|
Devel::Declare::set_linestr($linestr); |
58
|
7
|
|
|
|
|
40
|
return; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub _variable { |
62
|
2
|
|
|
2
|
|
1744
|
return my $foo; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _inject_scope { |
66
|
2
|
|
|
2
|
|
85
|
my $terminator = shift; |
67
|
|
|
|
|
|
|
on_scope_end { |
68
|
2
|
|
|
2
|
|
12
|
my $linestr = Devel::Declare::get_linestr; |
69
|
2
|
|
|
|
|
3
|
my $offset = Devel::Declare::get_linestr_offset; |
70
|
2
|
|
|
|
|
4
|
substr $linestr, $offset, 0, $terminator; |
71
|
2
|
|
|
|
|
7
|
Devel::Declare::set_linestr($linestr); |
72
|
2
|
|
|
|
|
9
|
}; |
73
|
2
|
|
|
|
|
31
|
return; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
1; # End of Variable::Lazy |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__END__ |