line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl6ish::Syntax::constant; |
2
|
1
|
|
|
1
|
|
1399
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
3
|
1
|
|
|
1
|
|
1014
|
use Devel::Declare; |
|
1
|
|
|
|
|
7207
|
|
|
1
|
|
|
|
|
7
|
|
4
|
1
|
|
|
1
|
|
1151
|
use Readonly; |
|
1
|
|
|
|
|
3566
|
|
|
1
|
|
|
|
|
435
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our ($Declarator, $Offset); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub skip_declarator { |
9
|
3
|
|
|
3
|
0
|
9
|
$Offset += Devel::Declare::toke_move_past_token($Offset); |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub handle_constant { |
13
|
3
|
|
|
3
|
0
|
208
|
my $line = Devel::Declare::get_linestr; |
14
|
3
|
|
|
|
|
7
|
$Offset = Devel::Declare::get_linestr_offset; |
15
|
|
|
|
|
|
|
|
16
|
3
|
50
|
|
|
|
33
|
if (my ($statement, $sigil, $name, $val) = $line =~ /(\bconstant\s+([\$\@\%])(\w+)\s*=\s*(.+);)/) { |
17
|
3
|
|
|
|
|
6
|
skip_declarator; |
18
|
3
|
|
|
|
|
5
|
my $var = "$sigil$name"; |
19
|
|
|
|
|
|
|
|
20
|
3
|
|
|
|
|
10
|
substr( $line, $Offset, length($statement) ) = "(my $var, $val);"; |
21
|
3
|
|
|
|
|
8
|
Devel::Declare::set_linestr($line); |
22
|
|
|
|
|
|
|
|
23
|
3
|
100
|
|
|
|
82
|
print "emit: $line\n" if $sigil eq '@'; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub constant(\[$@%]@) { |
28
|
3
|
|
|
3
|
0
|
740
|
my $ref = shift; |
29
|
|
|
|
|
|
|
|
30
|
3
|
100
|
|
|
|
19
|
if (ref($ref) eq 'SCALAR') { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
31
|
1
|
|
|
|
|
3
|
my $val = shift; |
32
|
1
|
|
|
|
|
6
|
Readonly::Scalar $$ref, $val; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif (ref($ref) eq 'ARRAY') { |
35
|
1
|
|
|
|
|
6
|
Readonly::Array @$ref, @_; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif (ref($ref) eq 'HASH') { |
38
|
1
|
|
|
|
|
4
|
my %val = (@_); |
39
|
1
|
|
|
|
|
8
|
Readonly::Hash %$ref, %val; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub import { |
45
|
1
|
|
|
1
|
|
10
|
my $caller = caller; |
46
|
1
|
|
|
1
|
|
9
|
no strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
108
|
|
47
|
1
|
|
|
|
|
2
|
*{"$caller\::constant"} = \&constant; |
|
1
|
|
|
|
|
5
|
|
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
11
|
Devel::Declare->setup_for( |
50
|
|
|
|
|
|
|
$caller => { constant => { const => \&handle_constant } } |
51
|
|
|
|
|
|
|
); |
52
|
1
|
|
|
|
|
57
|
1; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
1; |
57
|
|
|
|
|
|
|
|