line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Sim::Clock; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
59010
|
use Carp qw(croak carp); |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
220
|
|
4
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
95
|
|
5
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
676
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new ($$) { |
10
|
5
|
50
|
|
5
|
1
|
45
|
my $class = ref $_[0] ? ref shift : shift; |
11
|
5
|
100
|
|
|
|
20
|
my $now = @_ ? shift : 0; |
12
|
5
|
|
|
|
|
32
|
bless { |
13
|
|
|
|
|
|
|
now => $now, |
14
|
|
|
|
|
|
|
}, $class; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub now ($) { |
18
|
118
|
|
|
118
|
1
|
1656
|
$_[0]->{now}; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub push_to ($$) { |
22
|
29
|
|
|
29
|
1
|
44
|
my ($self, $time) = @_; |
23
|
29
|
100
|
|
|
|
55
|
if ($time < $self->now) { |
24
|
1
|
|
|
|
|
163
|
carp "error: Can't push your time back, sir"; |
25
|
1
|
|
|
|
|
108
|
return 0; |
26
|
|
|
|
|
|
|
} |
27
|
28
|
|
|
|
|
47
|
$self->{now} = $time; |
28
|
28
|
|
|
|
|
60
|
return 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub reset ($) { |
32
|
5
|
|
|
5
|
1
|
17
|
$_[0]->{now} = 0; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
1; |
36
|
|
|
|
|
|
|
__END__ |