| 1 | package Aion::Type::DNF; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use common::sense; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 2692 | ▶ | sub Any() { goto &Aion::Type::Any } | ||||||||||||||||||||||||||
|
Subroutine
Any: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 6 | 4113 | ▶ | sub None() { goto &Aion::Type::None } | ||||||||||||||||||||||||||
|
Subroutine
None: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # A as B as C <=> A & B & C | ||||||||||||||||||||||||||||
| 9 | 480 | ▶ | sub _unfolding { | ||||||||||||||||||||||||||
|
Subroutine
_unfolding: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 10 | 480 | my ($self) = @_; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 480 | my @u; | |||||||||||||||||||||||||||
| 13 | 480 | ▶ | for(my $i=$self; $i; $i = $i->{as}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 14 | 1528 | ▶ | unshift(@u, $i->clone(args => [map $_->_unfolding, @{$i->{args}}])), last if $i->is_set_theoretic; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | 1291 | ▶ | unshift @u, $i if $i->{test} != \&Aion::Type::true; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | } | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 480 | ▶ | @u == 0? Any: | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 19 | @u == 1? $u[0]: Aion::Types::Intersection(\@u); | ||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | # Проталкивание исключений к термам, заодно уменьшает размерность с приведением | ||||||||||||||||||||||||||||
| 23 | 1237 | ▶ | sub _pushing { | ||||||||||||||||||||||||||
|
Subroutine
_pushing: called CC=17 SCAR=28.4
| |||||||||||||||||||||||||||||
| 24 | 1237 | my ($self) = @_; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 1237 | ▶ | if($self->is_exclude) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 468 | my $inner = $self->{args}[0]; | |||||||||||||||||||||||||||
| 28 | # ~(~A) => A | ||||||||||||||||||||||||||||
| 29 | 468 | ▶ | return $inner->{args}[0]->_pushing if $inner->is_exclude; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | # ~(A | B) => ~A & ~B | ||||||||||||||||||||||||||||
| 31 | 467 | ▶ | return _intersection(map { (~$_)->_pushing } @{$inner->{args}}) if $inner->is_union; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | # ~(A & B) => ~A | ~B | ||||||||||||||||||||||||||||
| 33 | 436 | ▶ | return _union(map { (~$_)->_pushing } @{$inner->{args}}) if $inner->is_intersection; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | # Range[A, B] => Range[-Inf, Invert[A]] | Range[Invert[B], Inf] | ||||||||||||||||||||||||||||
| 35 | 316 | ▶ | if($inner->is_range_type) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 25 | my ($min, $max) = @{$inner->{args}}; | |||||||||||||||||||||||||||
| 37 | 25 | ▶ | if($inner->is_range) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | 11 | ▶ | return None if $min == '-Inf' && $max == 'Inf'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$min == "-Inf" and $max == "Inf"
MC/DC0%0/2
$min == "-Inf" and $max == "Inf"
$min == "-Inf"
$max == "Inf"
Truth table33%1/3
A and B
A= $min == "-Inf"B= $max == "Inf"
| |||||||||||||||||||||||||||||
| 39 | 11 | ▶ | return $inner->clone(args => [Aion::Type::Lim->from($max)->inc, 'Inf']) if $min == '-Inf'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 11 | ▶ | return $inner->clone(args => ['-Inf', Aion::Type::Lim->from($min)->dec]) if $max == 'Inf'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | 7 | return $inner->clone(args => ['-Inf', Aion::Type::Lim->from($min)->dec]) | $inner->clone(args => [Aion::Type::Lim->from($max)->inc, 'Inf']); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 14 | ▶ | return None if $min == 0 && $max == 'Inf'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$min == 0 and $max == "Inf"
MC/DC100%2/2
$min == 0 and $max == "Inf"
$min == 0
$max == "Inf"
Truth table100%3/3
A and B
A= $min == 0B= $max == "Inf"
| |||||||||||||||||||||||||||||
| 45 | 13 | ▶ | return $inner->clone(args => [$max+1, 'Inf']) if $min == 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | 5 | ▶ | return $inner->clone(args => [0, $min-1]) if $max == 'Inf'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 4 | return $inner->clone(args => [0, $min-1]) | $inner->clone(args => [$max+1, 'Inf']); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 291 | return $self; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 769 | ▶ | return _intersection(map $_->_pushing, @{$self->{args}}) if $self->is_intersection; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | 522 | ▶ | return _union(map $_->_pushing, @{$self->{args}}) if $self->is_union; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 471 | $self | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | # Сжимает в ДНФ | ||||||||||||||||||||||||||||
| 59 | 925 | ▶ | sub _distribute { | ||||||||||||||||||||||||||
|
Subroutine
_distribute: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 60 | 925 | my ($self) = @_; | |||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | # (A|B) & (C|D|E) & F => (A&C&F) | (A&D&F) | (A&E&F) | (B&C&F) | (B&D&F) | (B&E&F) | ||||||||||||||||||||||||||||
| 63 | 925 | ▶ | if($self->is_intersection) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 129 | ▶ | my @disjuncts = map { my $x = $_->_distribute; $x->is_union? [@{$x->{args}}]: [$x] } @{$self->{args}}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 462 | ▶ | my $dnf = List::Util::reduce { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 67 | 462 | [ map { my $p = $_; map { [@$p, $_] } @$b } @$a ] | |||||||||||||||||||||||||||
| 68 | 129 | } [[]], @disjuncts; | |||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 129 | return _union(map _intersection(@$_), @$dnf); | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 796 | ▶ | return _union(map $_->_distribute, @{$self->{args}}) if $self->is_union; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 670 | $self | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | # Объединение интервалов | ||||||||||||||||||||||||||||
| 79 | 51 | ▶ | sub _union_ranges { | ||||||||||||||||||||||||||
|
Subroutine
_union_ranges: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||
| 80 | 51 | my ($ranges) = @_; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | # Отсекаем пустые | ||||||||||||||||||||||||||||
| 83 | 51 | my @ranges = grep $_->{args}[0] <= $_->{args}[1], @$ranges; | |||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | # Сортируем в порядке возрастания нижней границы | ||||||||||||||||||||||||||||
| 86 | 51 | (my $range, @ranges) = sort { $a->{args}[0] <=> $b->{args}[0] } @ranges; | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | @ranges = map { | ||||||||||||||||||||||||||||
| 89 | 51 | my ($min1, $max1) = @{$range->{args}}; | |||||||||||||||||||||||||||
| 90 | 22 | my ($min2, $max2) = @{$_->{args}}; | |||||||||||||||||||||||||||
| 91 | 0 | ▶ | if($max1 > $min2) { $range = $range->clone(args => [$min1, List::Util::max($max1, $max2)]); () } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 92 | 22 | else { my $arange = $range; $range = $_; $arange } | |||||||||||||||||||||||||||
| 93 | } @ranges; | ||||||||||||||||||||||||||||
| 94 | 51 | push @ranges, $range; | |||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 51 | ▶ | if(@ranges == 1) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 97 | 29 | my ($min, $max) = @{$range->{args}}; | |||||||||||||||||||||||||||
| 98 | 29 | ▶ | return Any if $min == $range->range_lbound && $max == 'Inf'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$min == $range->range_lbound and $max == "Inf"
MC/DC0%0/2
$min == $range->range_lbound and $max == "Inf"
$min == $range->range_lbound
$max == "Inf"
Truth table66%2/3
A and B
A= $min == $range->range_lboundB= $max == "Inf"
| |||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | @ranges | ||||||||||||||||||||||||||||
| 102 | 51 | } | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | # Обрабатывает пересечение границ однотипных диапазонов | ||||||||||||||||||||||||||||
| 105 | 1321 | ▶ | sub _intersection_ranges($) { | ||||||||||||||||||||||||||
|
Subroutine
_intersection_ranges: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 106 | 1321 | my ($ranges) = @_; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | # Пустой диапазон - это None | ||||||||||||||||||||||||||||
| 109 | 1321 | ▶ | return None if 0 == grep $_->{args}[0] <= $_->{args}[1], @$ranges; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | # Сортируем в порядке возрастания нижней границы | ||||||||||||||||||||||||||||
| 112 | 1321 | my ($range, @ranges) = sort { $a->{args}[0] <=> $b->{args}[0] } @$ranges; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 1321 | for my $arange (@ranges) { | |||||||||||||||||||||||||||
| 115 | # Если хотя бы у одного нет пересечений – это None | ||||||||||||||||||||||||||||
| 116 | 79 | my ($min1, $max1) = @{$range->{args}}; | |||||||||||||||||||||||||||
| 117 | 79 | my ($min2, $max2) = @{$arange->{args}}; | |||||||||||||||||||||||||||
| 118 | 79 | my $max = List::Util::min($max1, $max2); | |||||||||||||||||||||||||||
| 119 | 79 | ▶ | return None if $min2 > $max; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 120 | 25 | $range = $range->clone(args => [$min2, $max]); | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | $range | ||||||||||||||||||||||||||||
| 124 | 1267 | } | |||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | # Объединение перечислений | ||||||||||||||||||||||||||||
| 127 | 3 | ▶ | sub _union_enums($,$) { | ||||||||||||||||||||||||||
|
Subroutine
_union_enums: called CC=5 SCAR=26.8
| |||||||||||||||||||||||||||||
| 128 | 3 | my ($enums, $exclude_enums) = @_; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 3 | my %enum = map {($_=>$_)} map @{$_->{args}}, @$enums; | |||||||||||||||||||||||||||
| 131 | 3 | ▶ | return $enums->[0]->clone(args => [sort values %enum])->init unless @$exclude_enums; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 0 | my $first_exclude_enum = shift(@$exclude_enums); | |||||||||||||||||||||||||||
| 134 | 0 | my %exclude_enum = map {($_=>$_)} @{$first_exclude_enum->{args}}; | |||||||||||||||||||||||||||
| 135 | 0 | for my $exclude_enum (@$exclude_enums) { | |||||||||||||||||||||||||||
| 136 | 0 | delete @exclude_enum{grep { !($_ ~~ $exclude_enum->{args}) } keys %exclude_enum}; | |||||||||||||||||||||||||||
| 137 | 0 | ▶ | return Any unless keys %exclude_enum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 0 | delete @exclude_enum{keys %enum}; | |||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | return Any unless keys %exclude_enum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | 0 | ~$first_exclude_enum->clone(args => [sort values %exclude_enum])->init; | |||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | # Пересечение перечислений | ||||||||||||||||||||||||||||
| 148 | 16 | ▶ | sub _intersection_enums($,$) { | ||||||||||||||||||||||||||
|
Subroutine
_intersection_enums: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 149 | 16 | my ($enums, $exclude_enums) = @_; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 16 | my %exclude_enum = map {($_=>$_)} map @{$_->{args}}, @$exclude_enums; | |||||||||||||||||||||||||||
| 152 | 16 | ▶ | return ~$exclude_enums->[0]->clone(args => [sort values %exclude_enum])->init unless @$enums; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | 14 | my $first_enum = shift(@$enums); | |||||||||||||||||||||||||||
| 155 | 14 | my %enum = map {($_=>$_)} @{$first_enum->{args}}; | |||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 14 | for my $enum (@$enums) { | |||||||||||||||||||||||||||
| 158 | 3 | delete @enum{grep { !($_ ~~ $enum->{args}) } keys %enum}; | |||||||||||||||||||||||||||
| 159 | 3 | ▶ | return None unless keys %enum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||
| 162 | 13 | delete @enum{keys %exclude_enum}; | |||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 13 | ▶ | return None unless keys %enum; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 5 | $first_enum->clone(args => [sort values %enum])->init; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | # Обрабатывает пересечение границ диапазонов | ||||||||||||||||||||||||||||
| 170 | 2752 | ▶ | sub _ranges_bag(@) { | ||||||||||||||||||||||||||
|
Subroutine
_ranges_bag: called CC=8 SCAR=20.8
| |||||||||||||||||||||||||||||
| 171 | 2752 | my $ranges_fn = shift; | |||||||||||||||||||||||||||
| 172 | 2752 | my $enums_fn = shift; | |||||||||||||||||||||||||||
| 173 | 2752 | my %bag; my @any; my @enums; my @exclude_enums; | |||||||||||||||||||||||||||
| 174 | 2752 | for my $candidate (@_) { | |||||||||||||||||||||||||||
| 175 | 18645 | ▶ | if($candidate->is_range_type) { push @{$bag{$candidate->_range_lbaund_addr}}, $candidate } | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 176 | 23 | elsif($candidate->is_enum) { push @enums, $candidate } | |||||||||||||||||||||||||||
| 177 | 15 | ▶ | elsif($candidate->is_exclude && $candidate->{args}[0]->is_enum) { push @exclude_enums, $candidate->{args}[0] } | ||||||||||||||||||||||||||
|
Condition100%3/3
$candidate->is_exclude and $candidate->{"args"}[0]->is_enum
MC/DC100%2/2
$candidate->is_exclude and $candidate->{"args"}[0]->is_enum
$candidate->is_exclude
$candidate->{"args"}[0]->is_enum
Truth table100%3/3
A and B
A= $candidate->is_excludeB= $candidate->{"args"}[0]->is_enum
| |||||||||||||||||||||||||||||
| 178 | 17134 | else { push @any, $candidate } | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||
| 181 | 2752 | ▶ | return @any, @enums || @exclude_enums? $enums_fn->(\@enums, \@exclude_enums): (), map $ranges_fn->($_), values %bag; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@enums or @exclude_enums
MC/DC100%2/2
@enums or @exclude_enums
@enums
@exclude_enums
Truth table100%3/3
A or B
A= @enumsB= @exclude_enums
| |||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | # Создание пересечения с приведением | ||||||||||||||||||||||||||||
| 185 | 2326 | ▶ | sub _intersection(@) { | ||||||||||||||||||||||||||
|
Subroutine
_intersection: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 186 | 2326 | ▶ | my %x = map {($_->key => $_)} _ranges_bag \&_intersection_ranges, \&_intersection_enums, map { $_->is_intersection? @{$_->{args}}: $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | # ~Any & A = ~Any | ||||||||||||||||||||||||||||
| 188 | 2326 | ▶ | return None if exists $x{None->key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 189 | # Any & A = A | ||||||||||||||||||||||||||||
| 190 | 2263 | delete $x{Any->key}; | |||||||||||||||||||||||||||
| 191 | # Intersection[A] = A | ||||||||||||||||||||||||||||
| 192 | 2263 | ▶ | return (values %x)[0] if 1 == keys %x; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 193 | # Intersection[] = Any | ||||||||||||||||||||||||||||
| 194 | 2230 | ▶ | return Any if 0 == keys %x; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | # A & ~A = ~Any | ||||||||||||||||||||||||||||
| 196 | 2229 | ▶ | return None if List::Util::first { $_->is_exclude && exists $x{$_->{args}[0]->key} } values %x; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 197 | 1016 | Aion::Types::Intersection([values %x]); | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | # Создание объединения с приведением | ||||||||||||||||||||||||||||
| 201 | 426 | ▶ | sub _union(@) { | ||||||||||||||||||||||||||
|
Subroutine
_union: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||
| 202 | 426 | ▶ | my %x = map {($_->key => $_)} _ranges_bag \&_union_ranges, \&_union_enums, map { $_->is_union? @{$_->{args}}: $_ } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 203 | # Any | A = Any | ||||||||||||||||||||||||||||
| 204 | 426 | ▶ | return Any if exists $x{Any->key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 205 | # ~Any | A = A | ||||||||||||||||||||||||||||
| 206 | 426 | delete $x{None->key}; | |||||||||||||||||||||||||||
| 207 | # Union[A] = A | ||||||||||||||||||||||||||||
| 208 | 426 | ▶ | return (values %x)[0] if 1 == keys %x; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 209 | # Union[] = None | ||||||||||||||||||||||||||||
| 210 | 368 | ▶ | return None if 0 == keys %x; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | # A | ~A = Any | ||||||||||||||||||||||||||||
| 212 | 347 | ▶ | return Any if List::Util::first { $_->is_exclude && exists $x{$_->{args}[0]->key} } values %x; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.0
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 213 | 347 | Aion::Types::Union([values %x]); | |||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | 8 | 1; | |||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | __END__ | ||||||||||||||||||||||||||||