line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bit::Vector::Array::Tie; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
36459
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
5
|
1
|
|
|
1
|
|
3207
|
use Data::Dumper; |
|
1
|
|
|
|
|
18850
|
|
|
1
|
|
|
|
|
86
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1258
|
use Tie::Array; |
|
1
|
|
|
|
|
1516
|
|
|
1
|
|
|
|
|
40
|
|
8
|
1
|
|
|
1
|
|
9
|
use base 'Tie::Array'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
679
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub TIEARRAY |
11
|
|
|
|
|
|
|
{ |
12
|
3
|
|
|
3
|
|
14
|
return bless {}, $_[0]; |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub CLEAR |
16
|
|
|
|
|
|
|
{ |
17
|
0
|
|
|
0
|
|
0
|
$_[0]->{Value}=0; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub STORESIZE |
21
|
|
|
|
|
|
|
{ |
22
|
5
|
|
|
5
|
|
1436
|
my ($obj,$value)=@_; |
23
|
5
|
|
|
|
|
8
|
$value=int($value); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#warn "STORESIZE, $value"; |
26
|
|
|
|
|
|
|
|
27
|
5
|
|
|
|
|
24
|
$obj->{Value}=$value-1; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub FETCHSIZE |
31
|
|
|
|
|
|
|
{ |
32
|
20
|
|
|
20
|
|
269
|
my ($obj)=@_; |
33
|
20
|
|
|
|
|
35
|
my $value = $obj->{Value}; |
34
|
|
|
|
|
|
|
#warn "FETCHSIZE, $value"; |
35
|
20
|
|
|
|
|
53
|
return $value+1; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub STORE |
39
|
|
|
|
|
|
|
{ |
40
|
16
|
|
|
16
|
|
8892
|
my($obj,$bit_index,$bit_value)=@_; |
41
|
|
|
|
|
|
|
#warn "STORE, $bit_index,$bit_value"; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
################################################# |
44
|
|
|
|
|
|
|
# if user says |
45
|
|
|
|
|
|
|
# $arr[1]=1; |
46
|
|
|
|
|
|
|
# then set bit 1 (lsb) to a '1' |
47
|
|
|
|
|
|
|
# if user says |
48
|
|
|
|
|
|
|
# $arr[4]=0; |
49
|
|
|
|
|
|
|
# then set bit 4 to a '0' |
50
|
|
|
|
|
|
|
################################################# |
51
|
|
|
|
|
|
|
{ |
52
|
16
|
|
|
|
|
41
|
$bit_index--; |
|
16
|
|
|
|
|
17
|
|
53
|
16
|
100
|
|
|
|
33
|
$bit_value = $bit_value ? '1' : '0'; |
54
|
16
|
|
|
|
|
60
|
my $bin_str = sprintf("%lb",$obj->{Value}); |
55
|
16
|
|
|
|
|
38
|
my $padding='0'x($bit_index-length($bin_str)); |
56
|
16
|
|
|
|
|
28
|
$bin_str = '00'.$padding.$bin_str; |
57
|
16
|
|
|
|
|
26
|
my $substr_offset = -1 * ($bit_index+2); |
58
|
|
|
|
|
|
|
#warn $bin_str; |
59
|
16
|
|
|
|
|
25
|
substr($bin_str,$substr_offset,1)=$bit_value; |
60
|
|
|
|
|
|
|
#warn $bin_str; |
61
|
16
|
|
|
|
|
28
|
my $dec_val = oct('0b'.$bin_str); |
62
|
16
|
|
|
|
|
59
|
$obj->{Value}=$dec_val; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub FETCH |
68
|
|
|
|
|
|
|
{ |
69
|
0
|
|
|
0
|
|
0
|
my($obj,$bit_index)=@_; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
################################################# |
72
|
|
|
|
|
|
|
# if user says |
73
|
|
|
|
|
|
|
# my $bit = $arr[1]; |
74
|
|
|
|
|
|
|
# then return the bit at index 1 (lsb) |
75
|
|
|
|
|
|
|
################################################# |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
|
|
|
|
0
|
my $bin_str = sprintf("%lb",$obj->{Value}); |
|
0
|
|
|
|
|
0
|
|
78
|
0
|
|
|
|
|
0
|
my $padding='0'x($bit_index-length($bin_str)); |
79
|
0
|
|
|
|
|
0
|
$bin_str = '00'.$padding.$bin_str; |
80
|
0
|
|
|
|
|
0
|
my $substr_offset = -1 * ($bit_index+1); |
81
|
0
|
|
|
|
|
0
|
my $bit_val=substr($bin_str,$substr_offset,1); |
82
|
0
|
|
|
|
|
0
|
return $bit_val; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
############################################################## |
88
|
|
|
|
|
|
|
package Bit::Vector::Array; |
89
|
|
|
|
|
|
|
|
90
|
1
|
|
|
1
|
|
27
|
use 5.008002; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
144
|
|
91
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
51
|
|
92
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
157
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
require Exporter; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# Items to export into callers namespace by default. |
100
|
|
|
|
|
|
|
our @EXPORT = qw( |
101
|
|
|
|
|
|
|
bva |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub bva(\@) |
107
|
|
|
|
|
|
|
{ |
108
|
3
|
|
|
3
|
0
|
15
|
tie @{$_[0]},'Bit::Vector::Array::Tie'; |
|
3
|
|
|
|
|
15
|
|
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
__END__ |