line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SPVM::BlessedObject::Array; |
2
|
|
|
|
|
|
|
|
3
|
278
|
|
|
278
|
|
1866
|
use strict; |
|
278
|
|
|
|
|
524
|
|
|
278
|
|
|
|
|
7744
|
|
4
|
278
|
|
|
278
|
|
1284
|
use warnings; |
|
278
|
|
|
|
|
506
|
|
|
278
|
|
|
|
|
6752
|
|
5
|
278
|
|
|
278
|
|
1322
|
use Carp 'confess'; |
|
278
|
|
|
|
|
588
|
|
|
278
|
|
|
|
|
12480
|
|
6
|
|
|
|
|
|
|
|
7
|
278
|
|
|
278
|
|
1650
|
use base 'SPVM::BlessedObject'; |
|
278
|
|
|
|
|
611
|
|
|
278
|
|
|
|
|
58504
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use overload '@{}' => sub { |
10
|
15873
|
|
|
15873
|
|
32925
|
my ($array) = @_; |
11
|
|
|
|
|
|
|
|
12
|
15873
|
|
|
|
|
37733
|
my $elems = $array->to_elems; |
13
|
|
|
|
|
|
|
|
14
|
15873
|
|
|
|
|
204946
|
return $elems; |
15
|
278
|
|
|
278
|
|
331245
|
}; |
|
278
|
|
|
|
|
272441
|
|
|
278
|
|
|
|
|
2455
|
|
16
|
|
|
|
|
|
|
|
17
|
278
|
|
|
278
|
|
18652
|
use overload fallback => 1; |
|
278
|
|
|
|
|
773
|
|
|
278
|
|
|
|
|
970
|
|
18
|
|
|
|
|
|
|
|
19
|
278
|
|
|
278
|
|
189463
|
use SPVM::ExchangeAPI; |
|
278
|
|
|
|
|
823
|
|
|
278
|
|
|
|
|
89673
|
|
20
|
|
|
|
|
|
|
|
21
|
20
|
50
|
|
20
|
0
|
153
|
sub length { my $ret; eval { $ret = shift->_xs_length(@_) }; if ($@) { confess $@ } $ret; } |
|
20
|
|
|
|
|
45
|
|
|
20
|
|
|
|
|
323
|
|
|
20
|
|
|
|
|
90
|
|
|
0
|
|
|
|
|
0
|
|
|
20
|
|
|
|
|
121
|
|
22
|
|
|
|
|
|
|
|
23
|
16081
|
50
|
|
16081
|
1
|
24384
|
sub to_elems { my $ret; eval { $ret = shift->_xs_to_elems(@_) }; if ($@) { confess $@ } $ret; } |
|
16081
|
|
|
|
|
27447
|
|
|
16081
|
|
|
|
|
266425
|
|
|
16081
|
|
|
|
|
41187
|
|
|
0
|
|
|
|
|
0
|
|
|
16081
|
|
|
|
|
27478
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub to_strings { |
26
|
6
|
|
|
6
|
1
|
79
|
my $self = shift; |
27
|
|
|
|
|
|
|
|
28
|
6
|
|
|
|
|
23
|
my $elems = $self->to_elems; |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
|
|
22
|
my $strings = [map { $_->to_string } @$elems]; |
|
14
|
|
|
|
|
73
|
|
31
|
|
|
|
|
|
|
|
32
|
6
|
|
|
|
|
153
|
return $strings; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub to_bins { |
36
|
2
|
|
|
2
|
1
|
16
|
my $self = shift; |
37
|
|
|
|
|
|
|
|
38
|
2
|
|
|
|
|
7
|
my $elems = $self->to_elems; |
39
|
|
|
|
|
|
|
|
40
|
2
|
|
|
|
|
7
|
my $binaries = [map { $_->to_bin } @$elems]; |
|
4
|
|
|
|
|
13
|
|
41
|
|
|
|
|
|
|
|
42
|
2
|
|
|
|
|
48
|
return $binaries; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
46
|
50
|
|
46
|
1
|
187
|
sub to_bin { my $ret; eval { $ret = shift->_xs_to_bin(@_) }; if ($@) { confess $@ } $ret; } |
|
46
|
|
|
|
|
76
|
|
|
46
|
|
|
|
|
700
|
|
|
46
|
|
|
|
|
144
|
|
|
0
|
|
|
|
|
0
|
|
|
46
|
|
|
|
|
126
|
|
46
|
|
|
|
|
|
|
|
47
|
12
|
50
|
|
12
|
1
|
64
|
sub set { my $ret; eval { $ret = shift->_xs_set(@_) }; if ($@) { confess $@ } $ret; } |
|
12
|
|
|
|
|
18
|
|
|
12
|
|
|
|
|
150
|
|
|
12
|
|
|
|
|
39
|
|
|
0
|
|
|
|
|
0
|
|
|
12
|
|
|
|
|
26
|
|
48
|
|
|
|
|
|
|
|
49
|
12
|
50
|
|
12
|
1
|
26
|
sub get { my $ret; eval { $ret = shift->_xs_get(@_) }; if ($@) { confess $@ } $ret; } |
|
12
|
|
|
|
|
18
|
|
|
12
|
|
|
|
|
256
|
|
|
12
|
|
|
|
|
45
|
|
|
0
|
|
|
|
|
0
|
|
|
12
|
|
|
|
|
31
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 Name |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
SPVM::BlessedObject::Array - SPVM Array |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 DESCRIPTION |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
The object of the C class holds a SPVM array. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 Usage |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Gets an element of the array |
64
|
|
|
|
|
|
|
my $elem = $blessed_object_array->get(2); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# Sets an element of the array |
67
|
|
|
|
|
|
|
$blessed_object_array->set(2 => 5); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Converts a SPVM array to a Perl array reference |
70
|
|
|
|
|
|
|
my $elems = $blessed_object_array->to_elems; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Converts a SPVM array to a binary |
73
|
|
|
|
|
|
|
my $binary = $blessed_object_array->to_bin; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 Methods |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 get |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $elem = $blessed_object_array->get($index); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns an element of the array with the index. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 set |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$blessed_object_array->set($index, $elem); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Sets an element of the array with the index. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
If $elem cannnot be assigned to the element of the array, an exception is thrown. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 to_elems |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $elems = $blessed_object_array->to_elems; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Converts a SPVM array to a Perl array reference and returns it. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 to_bin |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
my $binary = $blessed_object_array->to_bin; |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Converts a SPVM array to a binary and returns it. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This binary is unpacked by L function. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
If the array is an object array, an excetion is thrown. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Examples: |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# byte[] |
110
|
|
|
|
|
|
|
my @elems = unpack 'c*', $binary; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
# short[] |
113
|
|
|
|
|
|
|
my @elems = unpack 's*', $binary; |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# int[] |
116
|
|
|
|
|
|
|
my @elems = unpack 'l*', $binary; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
# long[] |
119
|
|
|
|
|
|
|
my @elems = unpack 'q*', $binary; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# float[] |
122
|
|
|
|
|
|
|
my @elems = unpack 'f*', $binary; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
# double[] |
125
|
|
|
|
|
|
|
my @elems = unpack 'd*', $binary; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 to_strings |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
my $elems = $blessed_object_array->to_strings; |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
Converts a SPVM string array to a Perl array reference and returns it. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Each element calls L method. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 to_bins |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
my $elems = $blessed_object_array->to_bins; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Converts a SPVM string array to Perl array reference and returns it. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Each element calls L method. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head1 Operators |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Overloads the following operators. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head2 array dereference |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
my @elems = @$array; |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is the same as the following operation. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
my @elems = @{$array->to_elems}; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 Copyright & License |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Copyright (c) 2023 Yuki Kimoto |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
MIT License |