line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
############################################################################### |
3
|
|
|
|
|
|
|
## ## |
4
|
|
|
|
|
|
|
## Copyright (c) 2004 - 2009 by Steffen Beyer. ## |
5
|
|
|
|
|
|
|
## All rights reserved. ## |
6
|
|
|
|
|
|
|
## ## |
7
|
|
|
|
|
|
|
## This package is free software; you can redistribute it ## |
8
|
|
|
|
|
|
|
## and/or modify it under the same terms as Perl itself. ## |
9
|
|
|
|
|
|
|
## ## |
10
|
|
|
|
|
|
|
############################################################################### |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
package Bit::Vector::String; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
|
850
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
73
|
|
15
|
2
|
|
|
2
|
|
7
|
use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
112
|
|
16
|
|
|
|
|
|
|
|
17
|
2
|
|
|
2
|
|
446
|
use Bit::Vector; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
156
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
require Exporter; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
@ISA = qw(Exporter Bit::Vector); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
@EXPORT = qw(); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
@EXPORT_OK = qw(); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$VERSION = '7.2'; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
package Bit::Vector; |
30
|
|
|
|
|
|
|
|
31
|
2
|
|
|
2
|
|
8
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
32
|
2
|
|
|
2
|
|
511
|
use Carp::Clan '^Bit::Vector\b'; |
|
2
|
|
|
|
|
3331
|
|
|
2
|
|
|
|
|
11
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $Factor = log(10) / log(2); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub to_Oct |
37
|
|
|
|
|
|
|
{ |
38
|
108
|
50
|
|
108
|
0
|
1486
|
croak('Usage: $vector->to_Oct();') unless (@_ == 1); |
39
|
108
|
|
|
|
|
112
|
my($self) = @_; |
40
|
108
|
|
|
|
|
127
|
my($string) = ''; |
41
|
108
|
|
|
|
|
102
|
local $@; |
42
|
|
|
|
|
|
|
|
43
|
108
|
|
|
|
|
104
|
eval { $string = reverse(join('', $self->Chunk_List_Read(3))); }; |
|
108
|
|
|
|
|
2759
|
|
44
|
108
|
50
|
|
|
|
695
|
if ($@) |
45
|
|
|
|
|
|
|
{ |
46
|
0
|
|
|
|
|
0
|
$string = $@; |
47
|
0
|
|
|
|
|
0
|
$string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; |
48
|
0
|
|
|
|
|
0
|
$string =~ s!\s+at\s.*$!!; |
49
|
0
|
|
|
|
|
0
|
croak($string); |
50
|
|
|
|
|
|
|
} |
51
|
108
|
|
|
|
|
264
|
return $string; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub from_Oct |
55
|
|
|
|
|
|
|
{ |
56
|
27
|
50
|
|
27
|
0
|
48
|
croak('Usage: $vector->from_Oct($string);') unless (@_ == 2); |
57
|
27
|
|
|
|
|
34
|
my($self,$string) = @_; |
58
|
27
|
|
|
|
|
29
|
local $@; |
59
|
|
|
|
|
|
|
|
60
|
27
|
50
|
|
|
|
87
|
if ($string =~ /^[0-7]+$/) |
61
|
|
|
|
|
|
|
{ |
62
|
27
|
|
|
|
|
37
|
eval { $self->Chunk_List_Store(3, split(//, reverse($string))); }; |
|
27
|
|
|
|
|
715
|
|
63
|
27
|
50
|
|
|
|
179
|
if ($@) |
64
|
|
|
|
|
|
|
{ |
65
|
0
|
|
|
|
|
0
|
$string = $@; |
66
|
0
|
|
|
|
|
0
|
$string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; |
67
|
0
|
|
|
|
|
0
|
$string =~ s!\s+at\s.*$!!; |
68
|
0
|
|
|
|
|
0
|
croak($string); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
else |
72
|
|
|
|
|
|
|
{ |
73
|
0
|
|
|
|
|
0
|
croak("unknown string type"); |
74
|
|
|
|
|
|
|
} |
75
|
27
|
|
|
|
|
39
|
return $self; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub new_Oct |
79
|
|
|
|
|
|
|
{ |
80
|
54
|
50
|
|
54
|
0
|
104
|
croak('Usage: Bit::Vector->new_Oct($bits,$string);') unless (@_ == 3); |
81
|
54
|
|
|
|
|
64
|
my($class,$bits,$string) = @_; |
82
|
54
|
|
|
|
|
38
|
my($self); |
83
|
54
|
|
|
|
|
36
|
local $@; |
84
|
|
|
|
|
|
|
|
85
|
54
|
50
|
|
|
|
172
|
if ($string =~ /^[0-7]+$/) |
86
|
|
|
|
|
|
|
{ |
87
|
54
|
100
|
|
|
|
101
|
unless (defined $bits) { $bits = 3 * length($string); } |
|
27
|
|
|
|
|
31
|
|
88
|
54
|
|
|
|
|
56
|
eval { $self = Bit::Vector->new($bits); $self->Chunk_List_Store(3, split(//, reverse($string))); }; |
|
54
|
|
|
|
|
161
|
|
|
54
|
|
|
|
|
1397
|
|
89
|
54
|
50
|
|
|
|
360
|
if ($@) |
90
|
|
|
|
|
|
|
{ |
91
|
0
|
|
|
|
|
0
|
$string = $@; |
92
|
0
|
|
|
|
|
0
|
$string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; |
93
|
0
|
|
|
|
|
0
|
$string =~ s!\s+at\s.*$!!; |
94
|
0
|
|
|
|
|
0
|
croak($string); |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
else |
98
|
|
|
|
|
|
|
{ |
99
|
0
|
|
|
|
|
0
|
croak("unknown string type"); |
100
|
|
|
|
|
|
|
} |
101
|
54
|
|
|
|
|
97
|
return $self; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub String_Export |
105
|
|
|
|
|
|
|
{ |
106
|
486
|
50
|
33
|
486
|
0
|
5063
|
croak('Usage: $vector->String_Export($type);') unless (@_ == 1 or @_ == 2); |
107
|
486
|
|
|
|
|
437
|
my($self,$type) = @_; |
108
|
486
|
|
|
|
|
405
|
my($string) = ''; |
109
|
486
|
|
|
|
|
348
|
local $@; |
110
|
|
|
|
|
|
|
|
111
|
486
|
50
|
33
|
|
|
5615
|
if (not defined $type or not $type) |
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
100
|
66
|
|
|
|
|
|
|
50
|
33
|
|
|
|
|
112
|
|
|
|
|
|
|
{ |
113
|
0
|
|
|
|
|
0
|
eval { $string = '0x' . $self->to_Hex(); }; |
|
0
|
|
|
|
|
0
|
|
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
elsif ($type eq '1' or $type =~ /^b(?:in)?$/i) |
116
|
|
|
|
|
|
|
{ |
117
|
81
|
|
|
|
|
89
|
eval { $string = '0b' . $self->to_Bin(); }; |
|
81
|
|
|
|
|
613
|
|
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
elsif ($type eq '2' or $type =~ /^o(?:ct)?$/i) |
120
|
|
|
|
|
|
|
{ |
121
|
81
|
|
|
|
|
76
|
eval { $string = '0o' . reverse(join('', $self->Chunk_List_Read(3))); }; |
|
81
|
|
|
|
|
1901
|
|
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
elsif ($type eq '3' or $type =~ /^d(?:ec)?$/i) |
124
|
|
|
|
|
|
|
{ |
125
|
81
|
|
|
|
|
81
|
eval { $string = $self->to_Dec(); }; |
|
81
|
|
|
|
|
161636
|
|
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
elsif ($type eq '4' or $type =~ /^(?:h(?:ex)?|x)$/i) |
128
|
|
|
|
|
|
|
{ |
129
|
81
|
|
|
|
|
110
|
eval { $string = '0x' . $self->to_Hex(); }; |
|
81
|
|
|
|
|
353
|
|
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
elsif ($type eq '5' or $type =~ /^e(?:num)?$/i) |
132
|
|
|
|
|
|
|
{ |
133
|
81
|
|
|
|
|
109
|
eval { $string = '{' . $self->to_Enum() . '}'; }; |
|
81
|
|
|
|
|
1037
|
|
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
elsif ($type eq '6' or $type =~ /^p(?:ack)?$/i) |
136
|
|
|
|
|
|
|
{ |
137
|
81
|
|
|
|
|
87
|
eval { $string = ':' . $self->Size() . ':' . $self->Block_Read(); }; |
|
81
|
|
|
|
|
403
|
|
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
else |
140
|
|
|
|
|
|
|
{ |
141
|
0
|
|
|
|
|
0
|
croak("unknown string type '$type'"); |
142
|
|
|
|
|
|
|
} |
143
|
486
|
50
|
|
|
|
1242
|
if ($@) |
144
|
|
|
|
|
|
|
{ |
145
|
0
|
|
|
|
|
0
|
$string = $@; |
146
|
0
|
|
|
|
|
0
|
$string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; |
147
|
0
|
|
|
|
|
0
|
$string =~ s!\s+at\s.*$!!; |
148
|
0
|
|
|
|
|
0
|
croak($string); |
149
|
|
|
|
|
|
|
} |
150
|
486
|
|
|
|
|
1173
|
return $string; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
sub String_Import |
154
|
|
|
|
|
|
|
{ |
155
|
306
|
50
|
|
306
|
0
|
55046
|
croak('Usage: $vector->String_Import($string);') unless (@_ == 2); |
156
|
306
|
|
|
|
|
277
|
my($self,$string) = @_; |
157
|
306
|
|
|
|
|
251
|
my($type) = 0; |
158
|
306
|
|
|
|
|
214
|
local $@; |
159
|
|
|
|
|
|
|
|
160
|
306
|
100
|
|
|
|
2512
|
if ($string =~ /^(?:0[bB])?([01]+)$/) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
161
|
|
|
|
|
|
|
{ |
162
|
54
|
|
|
|
|
48
|
$type = 1; |
163
|
54
|
|
|
|
|
51
|
eval { $self->from_Bin($1); }; |
|
54
|
|
|
|
|
274
|
|
164
|
|
|
|
|
|
|
} |
165
|
|
|
|
|
|
|
elsif ($string =~ /^(?:0[oO])?([0-7]+)$/) |
166
|
|
|
|
|
|
|
{ |
167
|
45
|
|
|
|
|
29
|
$type = 2; |
168
|
45
|
|
|
|
|
47
|
eval { $self->Chunk_List_Store(3, split(//, reverse($1))); }; |
|
45
|
|
|
|
|
1194
|
|
169
|
|
|
|
|
|
|
} |
170
|
|
|
|
|
|
|
elsif ($string =~ /^(?:[+-])?[0-9]+$/) |
171
|
|
|
|
|
|
|
{ |
172
|
54
|
|
|
|
|
56
|
$type = 3; |
173
|
54
|
|
|
|
|
68
|
eval { $self->from_Dec($string); }; |
|
54
|
|
|
|
|
9306
|
|
174
|
|
|
|
|
|
|
} |
175
|
|
|
|
|
|
|
elsif ($string =~ /^(?:0[hHxX])?([0-9A-Fa-f]+)$/) |
176
|
|
|
|
|
|
|
{ |
177
|
45
|
|
|
|
|
45
|
$type = 4; |
178
|
45
|
|
|
|
|
43
|
eval { $self->from_Hex($1); }; |
|
45
|
|
|
|
|
207
|
|
179
|
|
|
|
|
|
|
} |
180
|
|
|
|
|
|
|
elsif ($string =~ /^[(<{\[]?([0-9]+(?:-[0-9]+)?(?:,[0-9]+(?:-[0-9]+)?)*)[)>}\]]?$/) |
181
|
|
|
|
|
|
|
{ |
182
|
54
|
|
|
|
|
63
|
$type = 5; |
183
|
54
|
|
|
|
|
71
|
eval { $self->from_Enum($1); }; |
|
54
|
|
|
|
|
313
|
|
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
elsif ($string =~ s!^:\d+:!!) |
186
|
|
|
|
|
|
|
{ |
187
|
54
|
|
|
|
|
56
|
$type = 6; |
188
|
54
|
|
|
|
|
47
|
eval { $self->Block_Store($string); }; |
|
54
|
|
|
|
|
127
|
|
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
else |
191
|
|
|
|
|
|
|
{ |
192
|
0
|
|
|
|
|
0
|
croak("unknown string type"); |
193
|
|
|
|
|
|
|
} |
194
|
306
|
50
|
|
|
|
704
|
if ($@) |
195
|
|
|
|
|
|
|
{ |
196
|
0
|
|
|
|
|
0
|
$string = $@; |
197
|
0
|
|
|
|
|
0
|
$string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; |
198
|
0
|
|
|
|
|
0
|
$string =~ s!\s+at\s.*$!!; |
199
|
0
|
|
|
|
|
0
|
croak($string); |
200
|
|
|
|
|
|
|
} |
201
|
306
|
|
|
|
|
458
|
return $type; |
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub new_String |
205
|
|
|
|
|
|
|
{ |
206
|
324
|
50
|
|
324
|
0
|
472
|
croak('Usage: Bit::Vector->new_String($bits,$string);') unless (@_ == 3); |
207
|
324
|
|
|
|
|
309
|
my($class,$bits,$string) = @_; |
208
|
324
|
|
|
|
|
226
|
my($type) = 0; |
209
|
324
|
|
|
|
|
186
|
my($self); |
210
|
324
|
|
|
|
|
232
|
local $@; |
211
|
|
|
|
|
|
|
|
212
|
324
|
100
|
|
|
|
2385
|
if ($string =~ /^(?:0[bB])?([01]+)$/) |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
213
|
|
|
|
|
|
|
{ |
214
|
54
|
|
|
|
|
44
|
$type = 1; |
215
|
54
|
100
|
|
|
|
101
|
unless (defined $bits) { $bits = length($1); } |
|
27
|
|
|
|
|
46
|
|
216
|
54
|
|
|
|
|
51
|
eval { $self = Bit::Vector->new_Bin($bits,$1); }; |
|
54
|
|
|
|
|
343
|
|
217
|
|
|
|
|
|
|
} |
218
|
|
|
|
|
|
|
elsif ($string =~ /^(?:0[oO])?([0-7]+)$/) |
219
|
|
|
|
|
|
|
{ |
220
|
54
|
|
|
|
|
33
|
$type = 2; |
221
|
54
|
100
|
|
|
|
89
|
unless (defined $bits) { $bits = 3 * length($1); } |
|
27
|
|
|
|
|
41
|
|
222
|
54
|
|
|
|
|
43
|
eval { $self = Bit::Vector->new($bits); $self->Chunk_List_Store(3, split(//, reverse($1))); }; |
|
54
|
|
|
|
|
115
|
|
|
54
|
|
|
|
|
1387
|
|
223
|
|
|
|
|
|
|
} |
224
|
|
|
|
|
|
|
elsif ($string =~ /^(?:[+-])?([0-9]+)$/) |
225
|
|
|
|
|
|
|
{ |
226
|
54
|
|
|
|
|
51
|
$type = 3; |
227
|
54
|
100
|
|
|
|
86
|
unless (defined $bits) { $bits = int( length($1) * $Factor + 1 ); } |
|
27
|
|
|
|
|
93
|
|
228
|
54
|
|
|
|
|
54
|
eval { $self = Bit::Vector->new_Dec($bits,$string); }; |
|
54
|
|
|
|
|
9950
|
|
229
|
|
|
|
|
|
|
} |
230
|
|
|
|
|
|
|
elsif ($string =~ /^(?:0[hHxX])?([0-9A-Fa-f]+)$/) |
231
|
|
|
|
|
|
|
{ |
232
|
54
|
|
|
|
|
51
|
$type = 4; |
233
|
54
|
100
|
|
|
|
96
|
unless (defined $bits) { $bits = 4 * length($1); } |
|
27
|
|
|
|
|
34
|
|
234
|
54
|
|
|
|
|
49
|
eval { $self = Bit::Vector->new_Hex($bits,$1); }; |
|
54
|
|
|
|
|
278
|
|
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
elsif ($string =~ /^[(<{\[]?([0-9]+(?:-[0-9]+)?(?:,[0-9]+(?:-[0-9]+)?)*)[)>}\]]?$/) |
237
|
|
|
|
|
|
|
{ |
238
|
54
|
|
|
|
|
41
|
$type = 5; |
239
|
54
|
|
|
|
|
124
|
$string = $1; |
240
|
54
|
100
|
|
|
|
82
|
unless (defined $bits) |
241
|
|
|
|
|
|
|
{ |
242
|
27
|
|
|
|
|
24
|
$bits = 0; |
243
|
27
|
100
|
|
|
|
101
|
while ($string =~ /([0-9]+)/g) { $bits = $1 if ($1 > $bits); } |
|
958
|
|
|
|
|
2402
|
|
244
|
27
|
|
|
|
|
34
|
$bits++; |
245
|
|
|
|
|
|
|
} |
246
|
54
|
|
|
|
|
56
|
eval { $self = Bit::Vector->new_Enum($bits,$string); }; |
|
54
|
|
|
|
|
319
|
|
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
elsif ($string =~ s!^:(\d+):!!) |
249
|
|
|
|
|
|
|
{ |
250
|
54
|
|
|
|
|
37
|
$type = 6; |
251
|
54
|
100
|
|
|
|
100
|
$bits = $1 unless (defined $bits); |
252
|
54
|
|
|
|
|
48
|
eval { $self = Bit::Vector->new($bits); $self->Block_Store($string); }; |
|
54
|
|
|
|
|
154
|
|
|
54
|
|
|
|
|
127
|
|
253
|
|
|
|
|
|
|
} |
254
|
|
|
|
|
|
|
else |
255
|
|
|
|
|
|
|
{ |
256
|
0
|
|
|
|
|
0
|
croak("unknown string type"); |
257
|
|
|
|
|
|
|
} |
258
|
324
|
50
|
|
|
|
704
|
if ($@) |
259
|
|
|
|
|
|
|
{ |
260
|
0
|
|
|
|
|
0
|
$string = $@; |
261
|
0
|
|
|
|
|
0
|
$string =~ s!^[A-Za-z0-9_]+(?:::[A-Za-z0-9_]+)*\(\):\s+!!; |
262
|
0
|
|
|
|
|
0
|
$string =~ s!\s+at\s.*$!!; |
263
|
0
|
|
|
|
|
0
|
croak($string); |
264
|
|
|
|
|
|
|
} |
265
|
324
|
50
|
|
|
|
400
|
if (wantarray) { return($self,$type); } |
|
324
|
|
|
|
|
724
|
|
266
|
0
|
|
|
|
|
|
return $self; |
267
|
|
|
|
|
|
|
} |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
1; |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
__END__ |