line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
2
|
|
|
2
|
|
7
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
50
|
|
2
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
116
|
|
3
|
|
|
|
|
|
|
package Time::C::Val; |
4
|
|
|
|
|
|
|
$Time::C::Val::VERSION = '0.001'; |
5
|
|
|
|
|
|
|
use overload ( |
6
|
2
|
|
|
|
|
16
|
'+' => 'add', |
7
|
|
|
|
|
|
|
'-' => 'subtract', |
8
|
|
|
|
|
|
|
'0+' => 'numify', |
9
|
|
|
|
|
|
|
'""' => 'stringify', |
10
|
|
|
|
|
|
|
'+=' => 'add_assign', |
11
|
|
|
|
|
|
|
'-=' => 'subtract_assign', |
12
|
|
|
|
|
|
|
fallback => 1, |
13
|
2
|
|
|
2
|
|
7
|
); |
|
2
|
|
|
|
|
3
|
|
14
|
|
|
|
|
|
|
|
15
|
57
|
|
|
57
|
0
|
57
|
sub new { my $c = shift; bless { @_ }, $c; } |
|
57
|
|
|
|
|
310
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub add { |
18
|
0
|
|
|
0
|
0
|
0
|
my ($self, $other, $swap) = @_; |
19
|
|
|
|
|
|
|
|
20
|
0
|
|
|
|
|
0
|
my $acc = $self->{acc}; |
21
|
|
|
|
|
|
|
my $meth = |
22
|
0
|
0
|
|
|
|
0
|
sprintf "plus_%ss", defined $self->{meth} ? $self->{meth} : $acc; |
23
|
0
|
|
|
|
|
0
|
return $self->{self}{tm}->$meth($other)->$acc(); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub subtract { |
27
|
0
|
|
|
0
|
0
|
0
|
my ($self, $other, $swap) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
0
|
if ($swap) { return $other - $self->{val}; } |
|
0
|
|
|
|
|
0
|
|
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
0
|
my $acc = $self->{acc}; |
32
|
|
|
|
|
|
|
my $meth = |
33
|
0
|
0
|
|
|
|
0
|
sprintf "minus_%ss", defined $self->{meth} ? $self->{meth} : $acc; |
34
|
0
|
|
|
|
|
0
|
return $self->{self}{tm}->$meth($other)->$acc(); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub numify { |
38
|
85
|
|
|
85
|
0
|
96
|
my ($self, $other, $swap) = @_; |
39
|
85
|
|
|
|
|
220
|
$self->{val}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub stringify { |
43
|
14
|
|
|
14
|
0
|
1007
|
my ($self, $other, $swap) = @_; |
44
|
14
|
|
|
|
|
108
|
$self->{val}; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub add_assign { |
48
|
17
|
|
|
17
|
0
|
22
|
my ($self, $other) = @_; |
49
|
|
|
|
|
|
|
|
50
|
17
|
|
|
|
|
21
|
my $acc = $self->{acc}; |
51
|
|
|
|
|
|
|
my $meth = |
52
|
17
|
100
|
|
|
|
65
|
sprintf "plus_%ss", defined $self->{meth} ? $self->{meth} : $acc; |
53
|
17
|
|
|
|
|
64
|
my $tm = $self->{self}{tm}->$meth($other); |
54
|
17
|
|
|
|
|
22
|
$self->{self}{tm} = $tm; |
55
|
17
|
|
|
|
|
84
|
$self->{val} = $tm->$acc(); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub subtract_assign { |
59
|
12
|
|
|
12
|
0
|
20
|
my ($self, $other) = @_; |
60
|
|
|
|
|
|
|
|
61
|
12
|
|
|
|
|
11
|
my $acc = $self->{acc}; |
62
|
|
|
|
|
|
|
my $meth = |
63
|
12
|
100
|
|
|
|
46
|
sprintf "minus_%ss", defined $self->{meth} ? $self->{meth} : $acc; |
64
|
12
|
|
|
|
|
48
|
my $tm = $self->{self}{tm}->$meth($other); |
65
|
12
|
|
|
|
|
13
|
$self->{self}{tm} = $tm; |
66
|
12
|
|
|
|
|
47
|
$self->{val} = $tm->$acc(); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
1; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
__END__ |