| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
=head1 NAME |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Starlink::ATL::Region - Tools for AST regions. |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Starlink::ATL::Region qw/merge_regions/; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $cmp = merge_regions(\@regions); |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This module contains a utility subroutine for working |
|
14
|
|
|
|
|
|
|
with AST regions. |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package Starlink::ATL::Region; |
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
990
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
35
|
|
|
21
|
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
6
|
use Exporter; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
46
|
|
|
23
|
1
|
|
|
1
|
|
5
|
use Starlink::AST; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
239
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = 0.05; |
|
26
|
|
|
|
|
|
|
our @ISA = qw/Exporter/; |
|
27
|
|
|
|
|
|
|
our @EXPORT_OK = qw/merge_regions/; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SUBROUTINES |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=over 4 |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=item B<merge_regions> |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Takes a reference to an array of AST regions and returns a single |
|
36
|
|
|
|
|
|
|
CmpRegion object. The CmpRegion is built in a tree manner rather |
|
37
|
|
|
|
|
|
|
than linearly to minimize the depth of the structure. |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub merge_regions { |
|
42
|
1
|
|
|
1
|
1
|
6780
|
my $ref = shift; |
|
43
|
1
|
|
|
|
|
5
|
my @regions = @$ref; |
|
44
|
|
|
|
|
|
|
|
|
45
|
1
|
50
|
|
|
|
7
|
return unless @regions; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# While we have more than one region in our list, keep |
|
48
|
|
|
|
|
|
|
# merging them. |
|
49
|
1
|
|
|
|
|
5
|
while (1 < scalar @regions) { |
|
50
|
2
|
|
|
|
|
5
|
my @tmp = (); |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Step over the list, 2 spots at a time, taking the two |
|
53
|
|
|
|
|
|
|
# regions and making them into a CmpRegion. |
|
54
|
2
|
|
|
|
|
6
|
for (my $i = 0; $i <= $#regions; $i += 2) { |
|
55
|
|
|
|
|
|
|
# Odd number of regions? Allow the last through unmerged. |
|
56
|
3
|
100
|
|
|
|
11
|
if ($i == $#regions) { |
|
57
|
1
|
|
|
|
|
5
|
push @tmp, $regions[$i]; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
else { |
|
60
|
2
|
|
|
|
|
1425
|
push @tmp, $regions[$i]->CmpRegion($regions[$i + 1], |
|
61
|
|
|
|
|
|
|
Starlink::AST::Region::AST__OR(), ''); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
} |
|
64
|
|
|
|
|
|
|
|
|
65
|
2
|
|
|
|
|
34
|
@regions = @tmp; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
1
|
|
|
|
|
5
|
return $regions[0]; |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
__END__ |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=back |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Graham Bell <g.bell@jach.hawaii.edu> |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Copyright (C) 2012 Science and Technology Facilities Council. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify |
|
86
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
|
87
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
|
88
|
|
|
|
|
|
|
(at your option) any later version. |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, |
|
91
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
92
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
93
|
|
|
|
|
|
|
GNU General Public License for more details. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
|
96
|
|
|
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. |