PartialOrder/CEnum.pm

filter: Statementstmt 45.4% 89 / 196 Branchbran 17.0% 16 / 94 Conditioncond 15.0% 19 / 126 MC/DCmcdc 1.5% 1 / 66 Subroutinesub 70.5% 12 / 17 Podpod 100% 10 / 10 totaltotal 28.8% 147 / 509 CC 95 SCAR 57.8
CC
95
Cov
30%
dump
992.0
get_strata
240.0
subsort
110.0
CRAP 324.0
↑ Summary PartialOrder/CMasked.pm »
1 # -*- Mode: Perl -*-
2  
3 #
4 # Copyright (c) 2001, Bryan Jurish. All rights reserved.
5 #
6 # This package is free software. You may redistribute it
7 # and/or modify it under the same terms as Perl itself.
8 #
9  
10 ###############################################################
11 #
12 # File: Math::PartialOrder::CEnum.pm
13 # Author: Bryan Jurish <jurish@ling.uni-potsdam.de>
14 #
15 # Description: QuD Hierarchy class using
16 # Bit::Vector objects to manipulate hierarchy
17 # information, internal storage as 'Enum'-type
18 # strings (compiling version)
19 #
20 ###############################################################
21  
22 package Math::PartialOrder::CEnum;
23 # System modules
24 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 #require Exporter;
26 # 3rd party exstensions
27 # user extension modules
28 7 ▶use Math::PartialOrder::CMasked qw(:bincompat :bvutils :enumutils);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 7 @ISA = qw(Math::PartialOrder::CMasked);
30 #@EXPORT = qw();
31 #@EXPORT_OK = qw();
32 #%EXPORT_TAGS = (
33 # );
34  
35 7 our $VERSION = 0.01;
36  
37  
38 ###############################################################
39 # Initialization
40 # + object structure:
41 # [
42 # --- inherited ---
43 # indices => { Type0 => Index0, ... }
44 # types => [ Type0, Type1, ... ]
45 # root => scalar type-name
46 # parents => [ Type0Parents, Type1Parents, ... ]
47 # children => [ Type0Children, Type1Children, ... ]
48 # attributes => [ { attr1.1 => val1.1, ... }, ... ]
49 # removed => [ FirstFreeIndex, SecondFreeIndex, ... ]
50 # vectors => [ Bit::Vector0, Bit::Vector1 ]
51 # compiled => scalar boolean
52 # hattributes => { a1 => v1, ... }
53 # --- overriden ---
54 # ancestors => [ Type0Ancs, Type1Ancs, ... ] # Ancs are Enum-strings!
55 # descendants => [ Type0Dscs, Type1Dscs, ... ] # Dscs are Enum-strings!
56 # ]
57 ###############################################################
58  
59 #----------------------------------------------------------------------
60 # new({root=>$r}) : inherited from CMasked
61  
62  
63  
64 #--------------------------------------------------------------
65 # $bool = $h->compile();
66 5 ▶sub compile ($) {
Subroutine compile: called CC=4 SCAR=14.0
Pod documented
67 5 my $h = shift;
68 5 my $rv = $h->SUPER::compile();
69 5 ▶ return $rv unless ($rv);
Branch: 1 branch
BranchTrueFalseTotal
unless $rv 0 5 5
70 # compact ancestors/descendants
71 5 @{$h->{ancestors}} =
72 map {
73 33 ▶ defined($_) ? $_->to_Enum : undef
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 33 0 33
74 5 } @{$h->{ancestors}};
75 5 @{$h->{descendants}} =
76 map {
77 33 ▶ defined($_) ? $_->to_Enum : undef
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 33 0 33
78 5 } @{$h->{descendants}};
79 5 return $rv;
80 }
81  
82 #--------------------------------------------------------------
83 # $h->decompile() : inherited from CMasked
84  
85 #--------------------------------------------------------------
86 # $h->compiled() : inherited from CMasked
87  
88  
89  
90 ###############################################################
91 # Hierarchy Maintainance
92 ###############################################################
93  
94 #--------------------------------------------------------------
95 # @types = $h->types(): inherited from CMasked
96  
97 #--------------------------------------------------------------
98 # $h = $h->add($t,@ps) : inherited from CMasked
99  
100 #--------------------------------------------------------------
101 # $bool = $h->has_type($t) : inherited from CMasked
102  
103 #--------------------------------------------------------------
104 # $h = $h->add_parents($t,@ps) : inherited from CMasked
105  
106 #--------------------------------------------------------------
107 # $h = $h->replace($old,$new) : inherited from CMasked
108  
109 #--------------------------------------------------------------
110 # $h = $h->move($t,@ps) : inherited from CMasked
111  
112 #--------------------------------------------------------------
113 # $h = $h->remove(@types) : inherited from CMasked
114  
115 #--------------------------------------------------------------
116 # @prts = $h->parents($type) : inherited from CMasked
117  
118 #--------------------------------------------------------------
119 # @kids = $h->children($type) : inherited from CMasked
120  
121 #--------------------------------------------------------------
122 1 ▶sub ancestors ($$) {
Subroutine ancestors: called CC=4 SCAR=17.9
Pod documented
123 1 my ($i);
124 return
125 defined($_[1]) && defined($i = $_[0]->{indices}{$_[1]}) &&
126 $_[0]->compiled(1)
127 ? $_[0]->_enum2types($_[0]->{ancestors}[$i],
128 1 ▶ $_[0]->{vectors}[0])
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] && defined($i = $_[0]{'indices'}{$_[1]}) && $_[0]->compiled(1) ? : 1 0 1
Condition33%2/6
defined $_[1] and defined($i = $_[0]{"indices"}{$_[1]}) and $_[0]->compiled(1)
!ll&&!rl&&r
001
defined $_[1] and defined($i = $_[0]{"indices"}{$_[1]})
!ll&&!rl&&r
001
MC/DC0%0/3
defined $_[1] and defined($i = $_[0]{"indices"}{$_[1]}) and $_[0]->compiled(1)
defined $_[1] defined($i = $_[0]{"indices"}{$_[1]}) $_[0]->compiled(1)
Truth table25%1/4
A and B and C
A= defined $_[1]B= defined($i = $_[0]{"indices"}{$_[1]})C= $_[0]->compiled(1)
ABCresult
0XX0
10X0
1100
1111
129 : qw();
130 }
131  
132 #--------------------------------------------------------------
133 1 ▶sub descendants ($$) {
Subroutine descendants: called CC=4 SCAR=17.9
Pod documented
134 1 my ($i);
135 return
136 defined($_[1]) && defined($i = $_[0]->{indices}{$_[1]}) &&
137 $_[0]->compiled(1)
138 ? $_[0]->_enum2types($_[0]->{descendants}[$i],
139 1 ▶ $_[0]->{vectors}[0])
Branch: 1 branch
BranchTrueFalseTotal
defined $_[1] && defined($i = $_[0]{'indices'}{$_[1]}) && $_[0]->compiled(1) ? : 1 0 1
Condition33%2/6
defined $_[1] and defined($i = $_[0]{"indices"}{$_[1]}) and $_[0]->compiled(1)
!ll&&!rl&&r
001
defined $_[1] and defined($i = $_[0]{"indices"}{$_[1]})
!ll&&!rl&&r
001
MC/DC0%0/3
defined $_[1] and defined($i = $_[0]{"indices"}{$_[1]}) and $_[0]->compiled(1)
defined $_[1] defined($i = $_[0]{"indices"}{$_[1]}) $_[0]->compiled(1)
Truth table25%1/4
A and B and C
A= defined $_[1]B= defined($i = $_[0]{"indices"}{$_[1]})C= $_[0]->compiled(1)
ABCresult
0XX0
10X0
1100
1111
140 : qw();
141 }
142  
143 #--------------------------------------------------------------
144 # $bool = $h->has_parent($typ,$prt) : inherited from CMasked
145  
146  
147 #--------------------------------------------------------------
148 # $bool = $h->has_child($typ,$kid) : inherited from CMasked
149  
150  
151 #--------------------------------------------------------------
152 # $bool = $h->has_ancestor($typ,$anc) : inherited from CMasked
153 # --> delegates to has_ancestor_index($typ_idx,$anc_idx)
154  
155 #--------------------------------------------------------------
156 # $bool = $h->has_descendant($typ,$anc) : inherited from CMasked
157 # --> delegates to has_descendant_index($typ_idx,$anc_idx)
158  
159  
160 #--------------------------------------------------------------
161 # @sorted = subsort(@types)
162 0 ▶sub subsort ($@) {
Subroutine subsort: not called CC=10 SCAR=47.0
Pod documented
163 0 my $h = shift;
164 0 ▶ return qw() unless (@_);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
165 0 $h->compiled(1);
166 0 ▶ my @indices = map { defined($_) ? $h->{indices}{$_} : undef } @_;
Branch: 1 branch
BranchTrueFalseTotal
defined $_ ? : 0 0 0
167 0 my @other = qw();
168 0 my $v = $h->{vectors}[0];
169 0 my ($i,$j,$e);
170 0 ▶ for ($i = 0; $i <= $#_; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#_) 0 0 0
171 0 ▶ for ($j = $i+1; $j <= $#_; ++$j) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#_) 0 0 0
172 0 ▶ if (!defined($indices[$i])
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $indices[$i] or defined $indices[$j] and defined($e = $h->{"ancestors"}[$indices[$i]]) and $e ne "" and &_enum_bit_test($e, $indices[$j], $v)) 0 0 0
Condition0%0/12
not defined $indices[$i] or defined $indices[$j] and defined($e = $h->{"ancestors"}[$indices[$i]]) and $e ne "" and &_enum_bit_test($e, $indices[$j], $v)
l!l&&r!l&&!r
000
defined $indices[$j] and defined($e = $h->{"ancestors"}[$indices[$i]]) and $e ne "" and &_enum_bit_test($e, $indices[$j], $v)
!ll&&!rl&&r
000
defined $indices[$j] and defined($e = $h->{"ancestors"}[$indices[$i]]) and $e ne ""
!ll&&!rl&&r
000
defined $indices[$j] and defined($e = $h->{"ancestors"}[$indices[$i]])
!ll&&!rl&&r
000
MC/DC0%0/5
not defined $indices[$i] or defined $indices[$j] and defined($e = $h->{"ancestors"}[$indices[$i]]) and $e ne "" and &_enum_bit_test($e, $indices[$j], $v)
not defined $indices[$i] defined $indices[$j] defined($e = $h->{"ancestors"}[$indices[$i]]) $e ne "" &_enum_bit_test($e, $indices[$j], $v)
Truth table0%0/6
not(A) or B and C and D and E
A= not defined $indices[$i]B= defined $indices[$j]C= defined($e = $h->{"ancestors"}[$indices[$i]])D= $e ne ""E= &_enum_bit_test($e, $indices[$j], $v)
ABCDEresult
1XXXX1
011111
00XXX0
010XX0
0110X0
011100
173 ||
174 (defined($indices[$j]) &&
175 defined($e = $h->{ancestors}[$indices[$i]]) &&
176 $e ne '' &&
177 _enum_bit_test($e, $indices[$j], $v)))
178 {
179 0 @indices[$i,$j] = @indices[$j,$i];
180 0 @_[$i,$j] = @_[$j,$i];
181 }
182 }
183 }
184 0 return @_, @other;
185 }
186  
187  
188 #--------------------------------------------------------------
189 # \%strata = get_strata(@types)
190 0 ▶sub get_strata ($@) {
Subroutine get_strata: not called CC=15 SCAR=54.8
Pod documented
191 0 my $h = shift;
192 0 $h->compiled(1);
193 0 ▶ my @indices = @{$h->{indices}}{grep { defined($_) && exists($h->{indices}{$_}) } @_};
Condition0%0/3
defined $_ && exists $h->{'indices'}{$_}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_ && exists $h->{'indices'}{$_}
defined $_ exists $h->{'indices'}{$_}
Truth table0%0/3
A && B
A= defined $_B= exists $h->{'indices'}{$_}
ABresult
0X0
100
111
194 0 my (@strata);
195 0 foreach (@indices) { $strata[$_] = 0; }
196 0 my $v = $h->{vectors}[0];
197 0 my ($cmp,$i,$j,$e);
198 0 my $changed = 1;
199 0 my $step = 1;
200  
201 0 ▶ while ($changed) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed) 0 0 0
202 0 ▶ last if ($step > scalar(@_));
Branch: 1 branch
BranchTrueFalseTotal
if $step > scalar @_ 0 0 0
203 0 $changed = 0;
204  
205 0 ▶ for ($i = 0; $i < $#indices; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $#indices) 0 0 0
206 0 ▶ for ($j = $i+1; $j <= $#indices; ++$j) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#indices) 0 0 0
207
208 0 ▶ if (defined($e = $h->{ancestors}[$indices[$j]]) &&
Branch: 2 branches
BranchTrueFalseTotal
if (defined($e = $h->{'ancestors'}[$indices[$j]]) and $e ne '' and &_enum_bit_test($e, $indices[$i], $v)) { } 0 0 0
elsif (defined($e = $h->{'ancestors'}[$indices[$i]]) and $e ne '' and &_enum_bit_test($e, $indices[$j], $v)) { } 0 0 0
Condition0%0/6
defined($e = $h->{"ancestors"}[$indices[$j]]) and $e ne "" and &_enum_bit_test($e, $indices[$i], $v)
!ll&&!rl&&r
000
defined($e = $h->{"ancestors"}[$indices[$j]]) and $e ne ""
!ll&&!rl&&r
000
MC/DC0%0/3
defined($e = $h->{"ancestors"}[$indices[$j]]) and $e ne "" and &_enum_bit_test($e, $indices[$i], $v)
defined($e = $h->{"ancestors"}[$indices[$j]]) $e ne "" &_enum_bit_test($e, $indices[$i], $v)
Truth table0%0/4
A and B and C
A= defined($e = $h->{"ancestors"}[$indices[$j]])B= $e ne ""C= &_enum_bit_test($e, $indices[$i], $v)
ABCresult
0XX0
10X0
1100
1111
209 $e ne '' &&
210 _enum_bit_test($e, $indices[$i], $v))
211 {
212 0 ▶ next if ($strata[$indices[$i]] < $strata[$indices[$j]]);
Branch: 1 branch
BranchTrueFalseTotal
if $strata[$indices[$i]] < $strata[$indices[$j]] 0 0 0
213 0 $changed = 1;
214 0 $strata[$indices[$j]] = $strata[$indices[$i]] + 1;
215 }
216 ▶ elsif (defined($e = $h->{ancestors}[$indices[$i]]) &&
Condition0%0/6
defined($e = $h->{"ancestors"}[$indices[$i]]) and $e ne "" and &_enum_bit_test($e, $indices[$j], $v)
!ll&&!rl&&r
000
defined($e = $h->{"ancestors"}[$indices[$i]]) and $e ne ""
!ll&&!rl&&r
000
MC/DC0%0/3
defined($e = $h->{"ancestors"}[$indices[$i]]) and $e ne "" and &_enum_bit_test($e, $indices[$j], $v)
defined($e = $h->{"ancestors"}[$indices[$i]]) $e ne "" &_enum_bit_test($e, $indices[$j], $v)
Truth table0%0/4
A and B and C
A= defined($e = $h->{"ancestors"}[$indices[$i]])B= $e ne ""C= &_enum_bit_test($e, $indices[$j], $v)
ABCresult
0XX0
10X0
1100
1111
217 $e ne '' &&
218 _enum_bit_test($e, $indices[$j], $v))
219 {
220 0 ▶ next if ($strata[$indices[$i]] > $strata[$indices[$j]]);
Branch: 1 branch
BranchTrueFalseTotal
if $strata[$indices[$i]] > $strata[$indices[$j]] 0 0 0
221 0 $changed = 1;
222 0 $strata[$indices[$i]] = $strata[$indices[$j]] + 1;
223 }
224 }
225 }
226 }
227 my %strata =
228 0 (map { $h->{types}[$_] => $strata[$_] } @indices);
229 0 return \%strata;
230 }
231  
232  
233  
234 #--------------------------------------------------------------
235 # $bv = $h->_minimize($bv,$tmp)
236 12 ▶sub _minimize ($$;$) {
Subroutine _minimize: called CC=4 SCAR=14.3
237 12 my $self = shift;
238 12 my $bv = shift;
239 12 ▶ my $tmp = shift || $self->{vectors}[1];
Condition33%1/3
shift() || $self->{'vectors'}[1]
l!l&&r!l&&!r
1200
MC/DC0%0/2
shift() || $self->{'vectors'}[1]
shift() $self->{'vectors'}[1]
Truth table33%1/3
A || B
A= shift()B= $self->{'vectors'}[1]
ABresult
1X1
011
000
240 12 $self->compiled(1);
241 12 foreach ($bv->Index_List_Read) {
242 $tmp->from_Enum(defined($self->{descendants}[$_])
243 14 ▶ ? $self->{descendants}[$_]
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'descendants'}[$_] ? : 14 0 14
244 : '');
245 14 $bv->Difference($bv,$tmp);
246 }
247 12 return $bv;
248 }
249  
250 #--------------------------------------------------------------
251 # $bv = $h->_maximize($bv,$tmp)
252 1 ▶sub _maximize ($$;$) {
Subroutine _maximize: called CC=4 SCAR=14.3
253 1 my $self = shift;
254 1 my $bv = shift;
255 1 ▶ my $tmp = shift || $self->{vectors}[1];;
Condition33%1/3
shift() || $self->{'vectors'}[1]
l!l&&r!l&&!r
100
MC/DC0%0/2
shift() || $self->{'vectors'}[1]
shift() $self->{'vectors'}[1]
Truth table33%1/3
A || B
A= shift()B= $self->{'vectors'}[1]
ABresult
1X1
011
000
256 1 $self->compiled(1);
257 1 foreach ($bv->Index_List_Read) {
258 $tmp->from_Enum(defined($self->{ancestors}[$_])
259 2 ▶ ? $self->{ancestors}[$_]
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'ancestors'}[$_] ? : 2 0 2
260 : '');
261 2 $bv->Difference($bv,$tmp);
262 }
263 1 return $bv;
264 }
265  
266  
267 #--------------------------------------------------------------
268 # $val = $h->get_attribute($t,$a) : inherited from Base
269  
270 #--------------------------------------------------------------
271 # $v = $h->set_attribute($t,$a,$v) : inherited from Base
272  
273 #--------------------------------------------------------------
274 # $h1 = $h1->assign($h2) : inherited from CMasked
275  
276 #--------------------------------------------------------------
277 # $h = $h->merge($h1,...) : inherited from Base
278  
279 #--------------------------------------------------------------
280 # $h = $h->clear() : inherited from CMasked
281  
282  
283  
284 ###############################################################
285 # Additional Hierarchy Maintainence Operations
286 ###############################################################
287  
288 #--------------------------------------------------------------
289 # $root = $h->ensure_types(@types): inherited from Base
290  
291 #--------------------------------------------------------------
292 # $bool = $h->has_types(@types): inherited from Base
293  
294 # $bool = $h->has_ancestor_index($typ_idx,$anc_idx);
295 3 ▶sub has_ancestor_index ($$$) {
Subroutine has_ancestor_index: called CC=6 SCAR=24.3
Pod documented
296 3 my ($e);
297 return
298 defined($_[1]) && defined($_[2]) &&
299 $_[0]->compiled(1) &&
300 defined($e = $_[0]->{ancestors}[$_[1]]) && $e ne '' &&
301 3 ▶ _enum_bit_test($e, $_[2], $_[0]->{vectors}[0]);
Condition40%6/15
defined $_[1] && defined $_[2] && $_[0]->compiled(1) && defined($e = $_[0]{'ancestors'}[$_[1]]) && $e ne '' && &_enum_bit_test($e, $_[2], $_[0]{'vectors'}[0])
!ll&&!rl&&r
012
defined $_[1] and defined $_[2] and $_[0]->compiled(1) and defined($e = $_[0]{"ancestors"}[$_[1]]) and $e ne ""
!ll&&!rl&&r
003
defined $_[1] and defined $_[2] and $_[0]->compiled(1) and defined($e = $_[0]{"ancestors"}[$_[1]])
!ll&&!rl&&r
003
defined $_[1] and defined $_[2] and $_[0]->compiled(1)
!ll&&!rl&&r
003
defined $_[1] and defined $_[2]
!ll&&!rl&&r
003
MC/DC16%1/6
defined $_[1] && defined $_[2] && $_[0]->compiled(1) && defined($e = $_[0]{'ancestors'}[$_[1]]) && $e ne '' && &_enum_bit_test($e, $_[2], $_[0]{'vectors'}[0])
defined $_[1] defined $_[2] $_[0]->compiled(1) defined($e = $_[0]{"ancestors"}[$_[1]]) $e ne "" &_enum_bit_test($e, $_[2], $_[0]{'vectors'}[0])
Truth table28%2/7
A and B and C and D and E && F
A= defined $_[1]B= defined $_[2]C= $_[0]->compiled(1)D= defined($e = $_[0]{"ancestors"}[$_[1]])E= $e ne ""F= &_enum_bit_test($e, $_[2], $_[0]{'vectors'}[0])
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
302 }
303  
304 # $bool = $h->has_descendant_index($typ_idx,$dsc_idx);
305 1 ▶sub has_descendant_index ($$$) {
Subroutine has_descendant_index: called CC=6 SCAR=25.9
Pod documented
306 1 my ($e);
307 return
308 1 ▶ defined($_[1]) && defined($_[2]) &&
Condition33%5/15
defined $_[1] && defined $_[2] && $_[0]->compiled(1) && defined($e = $_[0]->_descendants->[$_[1]]) && $e ne '' && &_enum_bit_test($e, $_[2], $_[0]->_vectors->[0])
!ll&&!rl&&r
001
defined $_[1] and defined $_[2] and $_[0]->compiled(1) and defined($e = $_[0]->_descendants->[$_[1]]) and $e ne ""
!ll&&!rl&&r
001
defined $_[1] and defined $_[2] and $_[0]->compiled(1) and defined($e = $_[0]->_descendants->[$_[1]])
!ll&&!rl&&r
001
defined $_[1] and defined $_[2] and $_[0]->compiled(1)
!ll&&!rl&&r
001
defined $_[1] and defined $_[2]
!ll&&!rl&&r
001
MC/DC0%0/6
defined $_[1] && defined $_[2] && $_[0]->compiled(1) && defined($e = $_[0]->_descendants->[$_[1]]) && $e ne '' && &_enum_bit_test($e, $_[2], $_[0]->_vectors->[0])
defined $_[1] defined $_[2] $_[0]->compiled(1) defined($e = $_[0]->_descendants->[$_[1]]) $e ne "" &_enum_bit_test($e, $_[2], $_[0]->_vectors->[0])
Truth table14%1/7
A and B and C and D and E && F
A= defined $_[1]B= defined $_[2]C= $_[0]->compiled(1)D= defined($e = $_[0]->_descendants->[$_[1]])E= $e ne ""F= &_enum_bit_test($e, $_[2], $_[0]->_vectors->[0])
ABCDEFresult
0XXXXX0
10XXXX0
110XXX0
1110XX0
11110X0
1111100
1111111
309 $_[0]->compiled(1) &&
310 defined($e = $_[0]->_descendants->[$_[1]]) && $e ne '' &&
311 _enum_bit_test($e, $_[2], $_[0]->_vectors->[0]);
312 }
313  
314 # $bv = $h->ancestors_mask($typ_idx)
315 0 ▶sub ancestors_mask ($$) {
Subroutine ancestors_mask: not called CC=4 SCAR=30.0
Pod documented
316 0 ▶ if (defined($_[0]) && defined($_[1]) && $_[0]->compiled(1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0] and defined $_[1] and $_[0]->compiled(1)) 0 0 0
Condition0%0/6
defined $_[0] and defined $_[1] and $_[0]->compiled(1)
!ll&&!rl&&r
000
defined $_[0] and defined $_[1]
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_[0] and defined $_[1] and $_[0]->compiled(1)
defined $_[0] defined $_[1] $_[0]->compiled(1)
Truth table0%0/4
A and B and C
A= defined $_[0]B= defined $_[1]C= $_[0]->compiled(1)
ABCresult
0XX0
10X0
1100
1111
317 0 my $v = $_[0]->{vectors}[0];
318 0 $v->from_Enum($_[0]->{ancestors}[$_[1]]);
319 0 return $v->Clone;
320 }
321 0 return undef;
322 }
323  
324 # $bv = $h->descendants_mask($typ_idx)
325 0 ▶sub descendants_mask ($$) {
Subroutine descendants_mask: not called CC=4 SCAR=30.0
Pod documented
326 0 ▶ if (defined($_[0]) && defined($_[1]) && $_[0]->compiled(1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[0] and defined $_[1] and $_[0]->compiled(1)) 0 0 0
Condition0%0/6
defined $_[0] and defined $_[1] and $_[0]->compiled(1)
!ll&&!rl&&r
000
defined $_[0] and defined $_[1]
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_[0] and defined $_[1] and $_[0]->compiled(1)
defined $_[0] defined $_[1] $_[0]->compiled(1)
Truth table0%0/4
A and B and C
A= defined $_[0]B= defined $_[1]C= $_[0]->compiled(1)
ABCresult
0XX0
10X0
1100
1111
327 0 my $v = $_[0]->{vectors}[0];
328 0 $v->from_Enum($_[0]->{descendants}[$_[1]]);
329 0 return $v->Clone;
330 }
331 0 return undef;
332 }
333  
334 #--------------------------------------------------------------
335 # $rv = $h->iterate_i(\&next,\&callback,\%args) : inherited from CMasked
336  
337 #--------------------------------------------------------------
338 # $rv = $h->iterate_pc_i(\&callback,\%args) : inherited from CMasked
339  
340 #--------------------------------------------------------------
341 # $rv = $h->iterate_cp_i(\&callback,\%args) : inherited from CMasked
342  
343  
344 ###############################################################
345 # Type Operations
346 ###############################################################
347  
348 #--------------------------------------------------------------
349 # _get_bounds_log($i1,$i2,\@enums,$want_indices,$min_or_max)
350 13 ▶sub _get_bounds_log ($$$$;$$) {
Subroutine _get_bounds_log: called CC=9 SCAR=23.9
351 13 my $self = shift;
352 13 my $i1 = shift;
353 13 my $i2 = shift;
354 13 my $enums = shift;
355  
356 # sanity checks
357 return undef unless
358 13 ▶ (defined($i1) && defined($i2) && $self->compiled(1));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $i1 and defined $i2 and $self->compiled(1) 0 13 13
Condition33%2/6
defined $i1 and defined $i2 and $self->compiled(1)
!ll&&!rl&&r
0013
defined $i1 and defined $i2
!ll&&!rl&&r
0013
MC/DC0%0/3
defined $i1 and defined $i2 and $self->compiled(1)
defined $i1 defined $i2 $self->compiled(1)
Truth table25%1/4
A and B and C
A= defined $i1B= defined $i2C= $self->compiled(1)
ABCresult
0XX0
10X0
1100
1111
359  
360 # set up solutions vector
361 13 my $tmp = $self->{vectors}[0];
362 13 my $solns = $tmp->Shadow;
363  
364 # do the *real* computation
365 13 ▶ $solns->from_Enum(defined($enums->[$i1]) ? $enums->[$i1] : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $enums->[$i1] ? : 13 0 13
366 13 ▶ $tmp->from_Enum(defined($enums->[$i2]) ? $enums->[$i2] : '');
Branch: 1 branch
BranchTrueFalseTotal
defined $enums->[$i2] ? : 13 0 13
367 13 ▶ if (shift) { # $want_indices
Branch: 1 branch
BranchTrueFalseTotal
if (shift()) 13 0 13
368 13 $solns->Bit_On($i1);
369 13 $tmp->Bit_On($i2);
370 }
371 13 $solns->Intersection($solns,$tmp);
372 13 ▶ if ($_[0] < 0) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_[0] < 0) { } 12 1 13
elsif ($_[0] > 0) { } 1 0 1
373 12 return $self->_minimize($solns,$tmp);
374 } elsif ($_[0] > 0) {
375 1 return $self->_maximize($solns,$tmp);
376 }
377 # well that's odd -- let's just return the intersection
378 0 return $solns;
379 }
380  
381  
382 #--------------------------------------------------------------
383 # @lubs = $h->_lub($t1,$t2) : inherited from CMasked
384 # --> $h->types($h->_get_bounds_log($i1,$i2,$h->descendants,1,-1)->Index_List_Read)
385  
386 #--------------------------------------------------------------
387 # @mcds = $h->_mcd($i1,$i2) : inherited from CMasked
388 # --> $h->types($h->_get_bounds_log($i1,$i2,$h->descendants,0,-1)->Index_List_Read)
389  
390 #--------------------------------------------------------------
391 # @glbs = $h->_glb($t1,$t2) : inherited from CMasked
392 # --> $h->types($h->_get_bounds_log($i1,$i2,$h->ancestors,1,1)->Index_List_Read)
393  
394 #--------------------------------------------------------------
395 # @mcas = $h->_mca($i1,$i2)
396 # --> $h->types($h->_get_bounds_log($i1,$i2,$h->ancestors,0,1)->Index_List_Read)
397  
398  
399 ###############################################################
400 # Low-level Accessors/manipulators : inherited from CMasked
401 ###############################################################
402  
403  
404 ###############################################################
405 # Misc
406 ###############################################################
407  
408 #--------------------------------------------------------------
409 0 ▶sub dump ($;$$) {
Subroutine dump: not called CC=31 SCAR=69.0
Pod documented
410 0 my $h = shift;
411 0 ▶ my $name = shift || "$h";
Condition0%0/3
shift() || "$h"
l!l&&r!l&&!r
000
MC/DC0%0/2
shift() || "$h"
shift() "$h"
Truth table0%0/3
A || B
A= shift()B= "$h"
ABresult
1X1
011
000
412 0 my $what = shift;
413 0 my $dump = "\$$name = [\n";
414 0 my ($i);
415 0 ▶ if (!defined($what) || $what =~ /\btypes\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\btypes\b/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\btypes\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\btypes\b/
not defined $what $what =~ /\btypes\b/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\btypes\b/
ABresult
1X1
011
000
416 0 $dump .= " TYPES: [";
417 0 ▶ for ($i = 0; $i <= $#{$h->{types}}; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{$$h{"types"};}) 0 0 0
418 $dump .=
419 "\n $i: " .
420 0 ▶ (defined($h->{types}[$i]) ? "'" . $h->{types}[$i] . "'" : 'undef');
Branch: 1 branch
BranchTrueFalseTotal
defined $h->{'types'}[$i] ? : 0 0 0
421 }
422 0 $dump .= "\n ],\n";
423 }
424 0 ▶ if (!defined($what) || $what =~ /\bindices\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\bindices\b/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\bindices\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\bindices\b/
not defined $what $what =~ /\bindices\b/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\bindices\b/
ABresult
1X1
011
000
425 0 $dump .= " INDICES: {";
426 0 foreach $i (keys(%{$h->{indices}})) {
427 0 $dump .= "\n '$i' => '" . $h->{indices}{$i} . "'";
428 }
429 0 $dump .= "\n },\n";
430 }
431 0 ▶ if (!defined($what) || $what =~ /\broot\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\broot\b/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\broot\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\broot\b/
not defined $what $what =~ /\broot\b/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\broot\b/
ABresult
1X1
011
000
432 0 $dump .= " ROOT: '" . $h->{root} . "',\n";
433 }
434 0 ▶ if (!defined($what) || $what =~ /\bparents\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\bparents\b/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\bparents\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\bparents\b/
not defined $what $what =~ /\bparents\b/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\bparents\b/
ABresult
1X1
011
000
435 0 $dump .= " PARENTS: [";
436 0 ▶ for ($i = 0; $i <= $#{$h->{parents}}; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{$$h{"parents"};}) 0 0 0
437 0 $dump .= "\n $i: (" . $h->{parents}[$i] . ")";
438 }
439 0 $dump .= "\n ],\n";
440 }
441 0 ▶ if (!defined($what) || $what =~ /\bchildren\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\bchildren\b/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\bchildren\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\bchildren\b/
not defined $what $what =~ /\bchildren\b/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\bchildren\b/
ABresult
1X1
011
000
442 0 $dump .= " CHILDREN: [";
443 0 ▶ for ($i = 0; $i <= $#{$h->{children}}; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{$$h{"children"};}) 0 0 0
444 0 $dump .= "\n $i: (" . $h->{children}[$i] . ")";
445 }
446 0 $dump .= "\n ],\n";
447 }
448 0 ▶ if (!defined($what) || $what =~ /\bremoved\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\bremoved\b/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\bremoved\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\bremoved\b/
not defined $what $what =~ /\bremoved\b/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\bremoved\b/
ABresult
1X1
011
000
449 0 $dump .= " REMOVED: [" . join(',', @{$h->{removed}}) . "],\n";
450 }
451 0 ▶ if (!defined($what) || $what =~ /\bancestors\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\bancestors\b/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\bancestors\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\bancestors\b/
not defined $what $what =~ /\bancestors\b/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\bancestors\b/
ABresult
1X1
011
000
452 0 $dump .= " ANCESTORS: [";
453 0 ▶ for ($i = 0; $i <= $#{$h->{ancestors}}; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{$$h{"ancestors"};}) 0 0 0
454 0 $dump .= "\n $i: (" . $h->{ancestors}[$i] . ")";
455 }
456 0 $dump .= "\n ],\n";
457 }
458 0 ▶ if (!defined($what) || $what =~ /\bdescendants\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\bdescendants\b/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\bdescendants\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\bdescendants\b/
not defined $what $what =~ /\bdescendants\b/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\bdescendants\b/
ABresult
1X1
011
000
459 0 $dump .= " DESCENDANTS: [";
460 0 ▶ for ($i = 0; $i <= $#{$h->{descendants}}; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i <= $#{$$h{"descendants"};}) 0 0 0
461 0 $dump .= "\n $i: (" . $h->{descendants}[$i] . ")";
462 }
463 0 $dump .= "\n ],\n";
464 }
465 0 ▶ if (!defined($what) || $what =~ /\bcompiled\b/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\bcompiled\b/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\bcompiled\b/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\bcompiled\b/
not defined $what $what =~ /\bcompiled\b/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\bcompiled\b/
ABresult
1X1
011
000
466 0 ▶ $dump .= " COMPILED: " . ($h->compiled ? '1' : '0') . "\n";
Branch: 1 branch
BranchTrueFalseTotal
$h->compiled ? : 0 0 0
467 }
468 0 ▶ if (!defined($what) || $what =~ /\bhattr/) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $what or $what =~ /\bhattr/) 0 0 0
Condition0%0/3
not defined $what or $what =~ /\bhattr/
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $what or $what =~ /\bhattr/
not defined $what $what =~ /\bhattr/
Truth table0%0/3
not(A) or B
A= not defined $whatB= $what =~ /\bhattr/
ABresult
1X1
011
000
469 0 $dump .= " HATTRS: {";
470 0 foreach $i (keys(%{$h->{hattributes}})) {
471 0 $dump .= "\n '$i' => '" . $h->{hattributes}{$i} . "'";
472 }
473 0 $dump .= "\n },\n";
474 }
475 0 return $dump . "];\n";
476 }
477  
478  
479 #--------------------------------------------------------------
480 # Storage/retrieval
481  
482 #---------------------------------------------------------------------
483 # $hashref = $h->_get_bin_compat() : inherited from CMasked
484  
485 #---------------------------------------------------------------------
486 # $h->_store_before($retr)
487 1 ▶sub _store_before {
Subroutine _store_before: called CC=2 SCAR=6.9
488 1 my ($h,$retr) = @_;
489 1 $retr->{RemovedIndices} = $h->{removed};
490 1 $retr->{ParentsEnums} = $h->{parents};
491 1 $retr->{ChildrenEnums} = $h->{children};
492 1 $retr->{CompiledFlag} = $h->{compiled};
493 1 ▶ if ($h->{compiled}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h->{"compiled"}) 1 0 1
494 1 $retr->{AncestorsEnums} = $h->{ancestors};
495 1 $retr->{DescendantsEnums} = $h->{descendants};
496 }
497 1 return $retr;
498 }
499  
500 #--------------------------------------------------------------
501 # $h->_store_type($tr,$retr) : inherited from CMasked
502  
503 #--------------------------------------------------------------
504 # $h->_retrieve_type($tr,$retr) : inherited from CMasked
505  
506 #--------------------------------------------------------------
507 # $h->_retrieve_after($h,$retr)
508 1 ▶sub _retrieve_after {
Subroutine _retrieve_after: called CC=2 SCAR=6.9
509 1 my ($h,$retr) = @_;
510 1 @{$h->{removed}} = @{$retr->{RemovedIndices}};
511 1 @{$h->{parents}} = @{$retr->{ParentsEnums}};
512 1 @{$h->{children}} = @{$retr->{ChildrenEnums}};
513 1 $h->{compiled} = $retr->{CompiledFlag};
514 1 ▶ if ($h->{compiled}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h->{"compiled"}) 1 0 1
515 1 $h->_ensure_vector_sizes();
516 1 @{$h->{ancestors}} = @{$retr->{AncestorsEnums}};
517 1 @{$h->{descendants}} = @{$retr->{DescendantsEnums}};
518 }
519 }
520  
521 7 1;
522 __END__
↑ Summary PartialOrder/CMasked.pm »