line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Algorithm::Annotate; |
2
|
|
|
|
|
|
|
$VERSION = '0.10'; |
3
|
1
|
|
|
1
|
|
37421
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
34
|
|
4
|
1
|
|
|
1
|
|
1120
|
use Algorithm::Diff qw(traverse_balanced); |
|
1
|
|
|
|
|
6143
|
|
|
1
|
|
|
|
|
8812
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
Algorithm::Annotate - represent a series of changes in annotate form |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 SYNOPSIS |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Algorithm::Annotate; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $ann = Algorithm::Annotate->new (); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$ann->add ($info1, \@seq1); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$ann->add ($info2, \@seq2); |
19
|
|
|
|
|
|
|
$ann->add ($info3, \@seq3); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
$result = $ann->result; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Algorithm::Annotate generates a list that is useful for generating |
26
|
|
|
|
|
|
|
output simliar to C. |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 TODO |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
Might parse diff output and accumulate them for generating the annotate list. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
35
|
1
|
|
|
1
|
0
|
13
|
my $class = shift; |
36
|
1
|
|
|
|
|
4
|
my $self = bless {}, $class; |
37
|
1
|
|
|
|
|
4
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub init { |
41
|
1
|
|
|
1
|
0
|
13
|
my ($self, $info, $seq) = @_; |
42
|
1
|
|
|
|
|
7
|
$self->{lastseq} = $seq; |
43
|
1
|
|
|
|
|
3
|
$self->{annotate} = [map {$info} @$seq]; |
|
11
|
|
|
|
|
18
|
|
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub add { |
47
|
2
|
|
|
2
|
0
|
804
|
my ($self, $info, $seq) = @_; |
48
|
|
|
|
|
|
|
|
49
|
2
|
50
|
|
|
|
8
|
return $self->init ($info, $seq) unless $self->{lastseq}; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
traverse_balanced( $self->{lastseq}, $seq, |
52
|
20
|
|
|
20
|
|
498
|
{ MATCH => sub {}, |
53
|
|
|
|
|
|
|
DISCARD_A => |
54
|
|
|
|
|
|
|
sub { |
55
|
2
|
|
|
2
|
|
21
|
splice (@{$self->{annotate}}, $_[1], 1); |
|
2
|
|
|
|
|
8
|
|
56
|
|
|
|
|
|
|
}, |
57
|
|
|
|
|
|
|
DISCARD_B => |
58
|
|
|
|
|
|
|
sub { |
59
|
6
|
|
|
6
|
|
143
|
splice(@{$self->{annotate}}, $_[1], 0, $info); |
|
6
|
|
|
|
|
22
|
|
60
|
|
|
|
|
|
|
}, |
61
|
|
|
|
|
|
|
CHANGE => |
62
|
|
|
|
|
|
|
sub { |
63
|
2
|
|
|
2
|
|
346
|
$self->{annotate}[$_[1]] = $info; |
64
|
|
|
|
|
|
|
}, |
65
|
2
|
|
|
|
|
54
|
} ); |
66
|
|
|
|
|
|
|
|
67
|
2
|
|
|
|
|
27
|
$self->{lastseq} = $seq; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub result { |
71
|
2
|
|
|
2
|
0
|
12
|
my $self = shift; |
72
|
2
|
|
|
|
|
21
|
return $self->{annotate}; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
1; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHORS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Chia-liang Kao Eclkao@clkao.orgE |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Copyright 2003 by Chia-liang Kao Eclkao@clkao.orgE. |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
86
|
|
|
|
|
|
|
under the same terms as Perl itself. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
See L |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |