line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CLI::MixedArray; |
2
|
1
|
|
|
1
|
|
4
|
use CLI::Base; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
70
|
|
3
|
|
|
|
|
|
|
@ISA = ("CLI::Base"); |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
64
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
12
|
use CLI qw(parse_string typeStr); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
50
|
|
8
|
1
|
|
|
1
|
|
6
|
use CLI::Var; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
9
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
407
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new { |
12
|
0
|
|
|
0
|
0
|
|
my $proto = shift; |
13
|
0
|
|
0
|
|
|
|
my $class = ref($proto) || $proto; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $name = shift; |
16
|
0
|
|
|
|
|
|
my $types = shift; |
17
|
0
|
|
|
|
|
|
my $vals = shift; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
my $self = { |
20
|
|
|
|
|
|
|
NAME => $name, |
21
|
|
|
|
|
|
|
TYPE => undef, |
22
|
|
|
|
|
|
|
VALUE => [], |
23
|
|
|
|
|
|
|
FUNC => undef, |
24
|
|
|
|
|
|
|
MIN => undef, |
25
|
|
|
|
|
|
|
MAX => undef |
26
|
|
|
|
|
|
|
}; |
27
|
0
|
|
|
|
|
|
bless ($self, $class); |
28
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
foreach my $type (@$types) { |
30
|
0
|
|
|
|
|
|
push @{$self->{VALUE}}, new CLI::Var($name, $type, shift @{$vals}); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
0
|
|
|
|
|
|
return $self; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub TIEARRAY { |
37
|
0
|
|
|
0
|
|
|
return new(@_); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub value { |
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
my $index = shift; |
43
|
0
|
|
|
|
|
|
my $value = shift; |
44
|
|
|
|
|
|
|
|
45
|
0
|
0
|
|
|
|
|
if (!defined $index) { # Return the whole lot as a list |
46
|
0
|
|
|
|
|
|
my @return = (); |
47
|
0
|
|
|
|
|
|
foreach (@{$self->{VALUE}}) { |
|
0
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
push @return, $_->value(); |
49
|
|
|
|
|
|
|
} |
50
|
0
|
|
|
|
|
|
return @return; |
51
|
|
|
|
|
|
|
} else { |
52
|
|
|
|
|
|
|
# Verify the index value |
53
|
0
|
0
|
0
|
|
|
|
if ($index<0 || $index>=scalar(@{$self->{VALUE}})) { |
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
carp "Index $index out of range"; |
55
|
0
|
|
|
|
|
|
return undef; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
0
|
0
|
|
|
|
|
if (!defined $value) { # Return a value |
59
|
0
|
|
|
|
|
|
return $self->{VALUE}[$index]->value(); |
60
|
|
|
|
|
|
|
} else { # Save the value |
61
|
0
|
|
|
|
|
|
return $self->{VALUE}[$index]->value($value); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub FETCH { |
67
|
0
|
|
|
0
|
|
|
return value(@_); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub STORE { |
71
|
0
|
|
|
0
|
|
|
value(@_); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub parse { |
75
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
76
|
0
|
|
|
|
|
|
my $string = shift; |
77
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
if (defined $string) { |
79
|
0
|
|
|
|
|
|
my $value; |
80
|
0
|
|
|
|
|
|
foreach my $val (@{$self->{VALUE}}) { |
|
0
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$value = parse_string($val->type(), $string); |
82
|
0
|
0
|
|
|
|
|
if (! defined $value) { |
83
|
0
|
|
|
|
|
|
carp "Bad value \"$string\" for type ", typeStr($val->type()), "\n"; |
84
|
0
|
|
|
|
|
|
return; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
0
|
|
|
|
|
|
$val->value($value); |
88
|
|
|
|
|
|
|
|
89
|
0
|
0
|
|
|
|
|
return if (!defined $string); # End of list |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} else { # Print out the values in the list |
92
|
0
|
|
|
|
|
|
print $self->name(); |
93
|
0
|
|
|
|
|
|
foreach my $val (@{$self->{VALUE}}) { |
|
0
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
print ' ', $val->svalue(); |
95
|
|
|
|
|
|
|
} |
96
|
0
|
|
|
|
|
|
print "\n"; |
97
|
|
|
|
|
|
|
} |
98
|
0
|
0
|
|
|
|
|
if (defined $string) { # Some characters left over |
99
|
0
|
|
|
|
|
|
carp "Ignoring \"$string\"\n"; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |
104
|
|
|
|
|
|
|
|