line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
5
|
|
|
5
|
|
34
|
use strict; use warnings; |
|
5
|
|
|
5
|
|
10
|
|
|
5
|
|
|
|
|
135
|
|
|
5
|
|
|
|
|
20
|
|
|
5
|
|
|
|
|
10
|
|
|
5
|
|
|
|
|
159
|
|
2
|
|
|
|
|
|
|
package assign::Array; |
3
|
|
|
|
|
|
|
|
4
|
5
|
|
|
5
|
|
2002
|
use assign::Struct; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
180
|
|
5
|
5
|
|
|
5
|
|
36
|
use base 'assign::Struct'; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
458
|
|
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
33
|
use XXX; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
25
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub parse_elem { |
10
|
66
|
|
|
66
|
0
|
110
|
my ($self) = @_; |
11
|
66
|
|
|
|
|
98
|
my $in = $self->{in}; |
12
|
66
|
|
|
|
|
100
|
my $elems = $self->{elems}; |
13
|
66
|
|
|
|
|
159
|
while (@$in) { |
14
|
110
|
|
|
|
|
153
|
my $tok = shift(@$in); |
15
|
110
|
|
|
|
|
165
|
my $type = ref($tok); |
16
|
110
|
100
|
|
|
|
216
|
next if $type eq 'PPI::Token::Whitespace'; |
17
|
|
|
|
|
|
|
|
18
|
64
|
100
|
|
|
|
109
|
if ($type eq 'PPI::Token::Symbol') { |
19
|
58
|
|
|
|
|
133
|
my $str = $tok->content; |
20
|
58
|
50
|
|
|
|
328
|
if ($str =~ /^[\$\@]\w+$/) { |
21
|
58
|
|
|
|
|
139
|
my $elem = $self->get_var($str); |
22
|
58
|
|
|
|
|
112
|
push @$elems, $elem; |
23
|
58
|
|
|
|
|
156
|
return 1; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Parse @$a in the following if-statement. |
28
|
6
|
100
|
|
|
|
16
|
if ($type eq 'PPI::Token::Cast') { |
29
|
1
|
50
|
|
|
|
3
|
$tok->content eq '@' or |
30
|
|
|
|
|
|
|
XXX $tok, "unexpected token"; |
31
|
1
|
|
|
|
|
8
|
$tok = shift(@$in); |
32
|
1
|
|
|
|
|
2
|
$type = ref($tok); |
33
|
1
|
|
|
|
|
4
|
my $str = $tok->content; |
34
|
1
|
50
|
33
|
|
|
14
|
$type eq 'PPI::Token::Symbol' and $str =~ /^\$\w+$/ or |
35
|
|
|
|
|
|
|
XXX $tok, "unexpected token"; |
36
|
1
|
|
|
|
|
7
|
my $elem = $self->get_var($str); |
37
|
1
|
|
|
|
|
4
|
$elem->{cast} = 1; |
38
|
1
|
|
|
|
|
2
|
push @$elems, $elem; |
39
|
1
|
|
|
|
|
4
|
return 1; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
5
|
100
|
|
|
|
10
|
if ($type eq 'PPI::Token::Number') { |
43
|
2
|
|
|
|
|
6
|
my $str = $tok->content; |
44
|
2
|
50
|
|
|
|
18
|
if ($str =~ /^[1-9][0-9]*$/) { |
45
|
2
|
|
|
|
|
24
|
push @$elems, skip_num->new($str); |
46
|
2
|
|
|
|
|
7
|
return 1; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
3
|
50
|
|
|
|
7
|
if ($type eq 'PPI::Token::Magic') { |
50
|
3
|
|
|
|
|
7
|
my $str = $tok->content; |
51
|
3
|
100
|
|
|
|
22
|
if ($str eq '_') { |
52
|
2
|
|
|
|
|
10
|
push @$elems, skip->new; |
53
|
2
|
|
|
|
|
8
|
return 1; |
54
|
|
|
|
|
|
|
} |
55
|
1
|
50
|
|
|
|
4
|
if ($str eq '$_') { |
56
|
1
|
|
|
|
|
4
|
push @$elems, var->new($str); |
57
|
1
|
|
|
|
|
3
|
return 1; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
0
|
|
|
|
|
0
|
XXX $tok, "unexpected token"; |
61
|
|
|
|
|
|
|
} |
62
|
2
|
|
|
|
|
12
|
return 0; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub gen_code { |
66
|
21
|
|
|
21
|
0
|
69
|
my ($self, $decl, $oper, $from, $init) = @_; |
67
|
|
|
|
|
|
|
|
68
|
21
|
|
|
|
|
41
|
my $code = [ @$init ]; |
69
|
21
|
|
|
|
|
38
|
my $elems = $self->{elems}; |
70
|
|
|
|
|
|
|
|
71
|
21
|
100
|
|
|
|
50
|
if ($decl) { |
72
|
|
|
|
|
|
|
push @$code, |
73
|
|
|
|
|
|
|
"$decl(" . |
74
|
|
|
|
|
|
|
join(', ', |
75
|
|
|
|
|
|
|
map $_->val, |
76
|
53
|
|
|
|
|
109
|
grep {$_->val ne '$_'} |
77
|
19
|
|
|
|
|
54
|
grep {$_->val =~ /^[\$\@]/} |
|
57
|
|
|
|
|
119
|
|
78
|
|
|
|
|
|
|
@$elems |
79
|
|
|
|
|
|
|
) . |
80
|
|
|
|
|
|
|
');'; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
21
|
|
|
|
|
43
|
my $i = 0; |
84
|
21
|
|
|
|
|
46
|
for my $elem (@$elems) { |
85
|
64
|
|
|
|
|
91
|
my $type = ref $elem; |
86
|
64
|
100
|
|
|
|
123
|
if ($type eq 'skip') { |
87
|
2
|
|
|
|
|
2
|
$i++; |
88
|
2
|
|
|
|
|
6
|
next; |
89
|
|
|
|
|
|
|
} |
90
|
62
|
100
|
|
|
|
121
|
if ($type eq 'skip_num') { |
91
|
2
|
|
|
|
|
9
|
$i += $elem->val; |
92
|
2
|
|
|
|
|
3
|
next; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
60
|
|
|
|
|
164
|
my $var = $elem->val; |
96
|
60
|
|
100
|
|
|
184
|
my $def = $elem->{def} // ''; |
97
|
60
|
|
66
|
|
|
137
|
$def &&= " // $def"; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
push @$code, |
100
|
|
|
|
|
|
|
($elem->sigil eq '@') |
101
|
|
|
|
|
|
|
? "$var $oper \@$from\[$i..\@$from-1\]$def;" : |
102
|
|
|
|
|
|
|
($elem->{cast}) |
103
|
60
|
100
|
|
|
|
149
|
? "$var $oper \[\@$from\[$i..\@$from-1\]\]$def;" : |
|
|
100
|
|
|
|
|
|
104
|
|
|
|
|
|
|
"$var $oper $from\->[$i]$def;"; |
105
|
|
|
|
|
|
|
|
106
|
60
|
|
|
|
|
135
|
$i++; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
21
|
|
|
|
|
115
|
return join "\n", @$code; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |