blib/lib/GraphQL/Houtou/Runtime/OperationCompiler.pm

filter: Statementstmt 83.6% 343 / 410 Branchbran 70.1% 174 / 248 Conditioncond 37.5% 117 / 312 MC/DCmcdc 10.0% 16 / 159 Subroutinesub 87.2% 41 / 47 Podpod 0.0% 0 / 4 totaltotal 58.5% 691 / 1180 CC 278 SCAR 37.9
CC
278
Cov
65%
_inflate_instruction
306.0
_lower_selection_block
111.9
_build_typename_instruction
110.0
CRAP 44.3
« blib/lib/GraphQL/Houtou/Type/Object.pm ↑ Summary blib/lib/GraphQL/Houtou/Runtime/DirectiveRuntime.pm »
1 package GraphQL::Houtou::Runtime::OperationCompiler;
2  
3 62 ▶use 5.014;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 62 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 62 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 62 ▶use Scalar::Util qw(refaddr);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 62 ▶use JSON::MaybeXS qw(is_bool);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 62 ▶use GraphQL::Houtou ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 62 ▶use GraphQL::Houtou::Error ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11 62 ▶use GraphQL::Houtou::Runtime::Slot ();
Subroutine BEGIN: called CC=1 SCAR=0.0
12 62 ▶use GraphQL::Houtou::Runtime::VMBlock ();
Subroutine BEGIN: called CC=1 SCAR=0.0
13 62 ▶use GraphQL::Houtou::Runtime::VMOp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 62 ▶use GraphQL::Houtou::Runtime::VMProgram ();
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 62 my %RESOLVE_CODE = (
17 RESOLVE_DEFAULT => 1,
18 RESOLVE_EXPLICIT => 2,
19 );
20  
21  
22 62 my %COMPLETE_CODE = (
23 COMPLETE_GENERIC => 1,
24 COMPLETE_OBJECT => 2,
25 COMPLETE_LIST => 3,
26 COMPLETE_ABSTRACT => 4,
27 );
28  
29 1 ▶sub compile_operation {
Subroutine compile_operation: called CC=12 SCAR=28.8
Pod undocumented
30 1 my ($class, $runtime_schema, $document, %opts) = @_;
31 1 ▶ my $ast = ref($document) ? $document : GraphQL::Houtou::parse($document);
Branch: 1 branch
BranchTrueFalseTotal
ref $document ? : 0 1 1
32 1 ▶ my ($operation) = grep { ($_->{kind} || '') eq 'operation' } @{ $ast || [] };
Condition50%2/4
$_->{'kind'} || ''
l!l
10
$ast || []
l!l
10
MC/DC0%0/1
$_->{'kind'} || ''
$_->{'kind'}
MC/DC0%0/1
$ast || []
$ast
Truth table50%1/2
A
A= $_->{'kind'}
Aresult
11
00
Truth table50%1/2
A
A= $ast
Aresult
11
00
33 1 ▶ die "No operation found for runtime compiler.\n" if !$operation;
Branch: 1 branch
BranchTrueFalseTotal
unless $operation 0 1 1
34 0 ▶ my %fragments = map { (($_->{name} || '') => $_) }
Condition0%0/2
$_->{'name'} || ''
l!l
00
MC/DC0%0/1
$_->{'name'} || ''
$_->{'name'}
Truth table0%0/2
A
A= $_->{'name'}
Aresult
11
00
35 1 ▶ grep { ($_->{kind} || '') eq 'fragment' } @{ $ast || [] };
Condition50%2/4
$_->{'kind'} || ''
l!l
10
$ast || []
l!l
10
MC/DC0%0/1
$_->{'kind'} || ''
$_->{'kind'}
MC/DC0%0/1
$ast || []
$ast
Truth table50%1/2
A
A= $_->{'kind'}
Aresult
11
00
Truth table50%1/2
A
A= $ast
Aresult
11
00
36  
37 1 ▶ my $operation_type = $operation->{operation} || $operation->{operationType} || 'query';
Condition40%2/5
$operation->{'operation'} || $operation->{'operationType'} || 'query'
l!l
01
$operation->{"operation"} or $operation->{"operationType"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$operation->{'operation'} || $operation->{'operationType'} || 'query'
$operation->{"operation"} $operation->{"operationType"}
Truth table33%1/3
A or B
A= $operation->{"operation"}B= $operation->{"operationType"}
ABresult
1X1
011
000
38 1 _assert_supported_operation($operation_type);
39 1 ▶ my $schema_block = $runtime_schema->root_block($operation_type)
Branch: 1 branch
BranchTrueFalseTotal
my $schema_block = $runtime_schema->root_block($operation_type) or die "No root block for operation type '${operation_type}'.\n" 1 0 1
40 or die "No root block for operation type '$operation_type'.\n";
41  
42 1 my %state = (
43 runtime_schema => $runtime_schema,
44 block_index => 0,
45 blocks => [],
46 fragments => \%fragments,
47 );
48  
49 my $root_block = _lower_selection_block(
50 \%state,
51 $schema_block->root_type_name,
52 $schema_block,
53 1 ▶ $operation->{selections} || [],
Condition50%1/2
$operation->{'selections'} || []
l!l
10
MC/DC0%0/1
$operation->{'selections'} || []
$operation->{'selections'}
Truth table50%1/2
A
A= $operation->{'selections'}
Aresult
11
00
54 uc($operation_type),
55 );
56  
57 my $program = GraphQL::Houtou::Runtime::VMProgram->new(
58 operation_type => $operation_type,
59 operation_name => $operation->{name},
60 variable_defs => _lower_variable_defs($operation->{variables}),
61 blocks => $state{blocks},
62 1 root_block => $root_block,
63 );
64  
65 1 _bind_instruction_blocks($program);
66 1 return $program;
67 }
68  
69 409 ▶sub compile_operation_native_compact {
Subroutine compile_operation_native_compact: called CC=12 SCAR=26.2
Pod undocumented
70 409 my ($class, $runtime_schema, $document, %opts) = @_;
71 409 ▶ my $ast = ref($document) ? $document : GraphQL::Houtou::parse($document);
Branch: 1 branch
BranchTrueFalseTotal
ref $document ? : 7 402 409
72 409 ▶ my ($operation) = grep { ($_->{kind} || '') eq 'operation' } @{ $ast || [] };
Condition50%2/4
$_->{'kind'} || ''
l!l
4210
$ast || []
l!l
4090
MC/DC0%0/1
$_->{'kind'} || ''
$_->{'kind'}
MC/DC0%0/1
$ast || []
$ast
Truth table50%1/2
A
A= $_->{'kind'}
Aresult
11
00
Truth table50%1/2
A
A= $ast
Aresult
11
00
73 409 ▶ die "No operation found for runtime compiler.\n" if !$operation;
Branch: 1 branch
BranchTrueFalseTotal
unless $operation 0 409 409
74 11 ▶ my %fragments = map { (($_->{name} || '') => $_) }
Condition50%1/2
$_->{'name'} || ''
l!l
110
MC/DC0%0/1
$_->{'name'} || ''
$_->{'name'}
Truth table50%1/2
A
A= $_->{'name'}
Aresult
11
00
75 409 ▶ grep { ($_->{kind} || '') eq 'fragment' } @{ $ast || [] };
Condition50%2/4
$_->{'kind'} || ''
l!l
4210
$ast || []
l!l
4090
MC/DC0%0/1
$_->{'kind'} || ''
$_->{'kind'}
MC/DC0%0/1
$ast || []
$ast
Truth table50%1/2
A
A= $_->{'kind'}
Aresult
11
00
Truth table50%1/2
A
A= $ast
Aresult
11
00
76  
77 409 ▶ my $operation_type = $operation->{operation} || $operation->{operationType} || 'query';
Condition80%4/5
$operation->{'operation'} || $operation->{'operationType'} || 'query'
l!l
144265
$operation->{"operation"} or $operation->{"operationType"}
l!l&&r!l&&!r
0144265
MC/DC50%1/2
$operation->{'operation'} || $operation->{'operationType'} || 'query'
$operation->{"operation"} $operation->{"operationType"}
Truth table66%2/3
A or B
A= $operation->{"operation"}B= $operation->{"operationType"}
ABresult
1X1
011
000
78 409 _assert_supported_operation($operation_type);
79 404 ▶ my $schema_block = $runtime_schema->root_block($operation_type)
Branch: 1 branch
BranchTrueFalseTotal
my $schema_block = $runtime_schema->root_block($operation_type) or die "No root block for operation type '${operation_type}'.\n" 404 0 404
80 or die "No root block for operation type '$operation_type'.\n";
81  
82 404 my %state = (
83 runtime_schema => $runtime_schema,
84 block_index => 0,
85 blocks_compact => [],
86 args_payloads_compact => [],
87 directives_payloads_compact => [],
88 args_payload_index => {},
89 directives_payload_index => {},
90 fragments => \%fragments,
91 );
92  
93 my $root_block_index = _lower_selection_block_compact(
94 \%state,
95 $schema_block->root_type_name,
96 $schema_block,
97 404 ▶ $operation->{selections} || [],
Condition50%1/2
$operation->{'selections'} || []
l!l
4040
MC/DC0%0/1
$operation->{'selections'} || []
$operation->{'selections'}
Truth table50%1/2
A
A= $operation->{'selections'}
Aresult
11
00
98 uc($operation_type),
99 );
100  
101 return {
102 version => 1,
103 operation_type_code => _operation_type_code($operation_type),
104 operation_name => $operation->{name},
105 variable_defs => _lower_variable_defs($operation->{variables}),
106 args_payloads_compact => $state{args_payloads_compact},
107 directives_payloads_compact => $state{directives_payloads_compact},
108 root_block_index => $root_block_index,
109 blocks_compact => $state{blocks_compact},
110 404 };
111 }
112  
113 414 ▶sub _assert_supported_operation {
Subroutine _assert_supported_operation: called CC=2 SCAR=6.9
114 414 my ($operation_type) = @_;
115 414 ▶ die GraphQL::Houtou::Error->new(
Branch: 1 branch
BranchTrueFalseTotal
if $operation_type eq "subscription" 9 405 414
116 message => 'Subscription execution is not supported.',
117 extensions => { code => 'SUBSCRIPTION_NOT_SUPPORTED' },
118 ) if $operation_type eq 'subscription';
119 405 return;
120 }
121  
122 36 ▶sub assert_supported_operation_descriptor {
Subroutine assert_supported_operation_descriptor: called CC=6 SCAR=19.0
Pod undocumented
123 36 my ($descriptor) = @_;
124 36 ▶ return if ref($descriptor) ne 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $descriptor ne "HASH" 0 36 36
125 _assert_supported_operation('subscription')
126 if ($descriptor->{operation_type} || q()) eq 'subscription'
127 36 ▶ || ($descriptor->{operation_type_code} // q()) eq '3';
Branch: 1 branch
BranchTrueFalseTotal
if ($descriptor->{"operation_type"} || "") eq "subscription" or ($descriptor->{"operation_type_code"} // "") eq 3 4 32 36
Condition57%4/7
($descriptor->{"operation_type"} || "") eq "subscription" or ($descriptor->{"operation_type_code"} // "") eq 3
l!l&&r!l&&!r
0432
$descriptor->{'operation_type'} || ''
l!l
036
$descriptor->{"operation_type_code"} // ""
l!l
360
MC/DC0%0/2
($descriptor->{"operation_type"} || "") eq "subscription" or ($descriptor->{"operation_type_code"} // "") eq 3
$descriptor->{'operation_type'} $descriptor->{"operation_type_code"}
Truth table33%1/3
A or B
A= $descriptor->{'operation_type'}B= $descriptor->{"operation_type_code"}
ABresult
1X1
011
000
128 32 return;
129 }
130  
131 0 ▶sub inflate_operation {
Subroutine inflate_operation: not called CC=6 SCAR=37.4
Pod undocumented
132 0 my ($class, $runtime_schema, $struct) = @_;
133 0 ▶ my @blocks = map { _inflate_execution_block($_) } @{ $struct->{blocks} || [] };
Condition0%0/2
$struct->{'blocks'} || []
l!l
00
MC/DC0%0/1
$struct->{'blocks'} || []
$struct->{'blocks'}
Truth table0%0/2
A
A= $struct->{'blocks'}
Aresult
11
00
134 0 my %by_name = map { ($_->name => $_) } @blocks;
135 0 ▶ my $root_block = defined $struct->{root_block} ? $by_name{ $struct->{root_block} } : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $struct->{'root_block'} ? : 0 0 0
136 0 _bind_instructions_to_schema_slots($runtime_schema, \@blocks);
137 my $program = GraphQL::Houtou::Runtime::VMProgram->new(
138 version => $struct->{version} || 1,
139 operation_type => $struct->{operation_type} || 'query',
140 operation_name => $struct->{operation_name},
141 0 ▶ variable_defs => _clone_argument_value($struct->{variable_defs} || {}),
Condition0%0/6
$struct->{'version'} || 1
l!l
00
$struct->{'operation_type'} || 'query'
l!l
00
$struct->{'variable_defs'} || {}
l!l
00
MC/DC0%0/1
$struct->{'version'} || 1
$struct->{'version'}
MC/DC0%0/1
$struct->{'operation_type'} || 'query'
$struct->{'operation_type'}
MC/DC0%0/1
$struct->{'variable_defs'} || {}
$struct->{'variable_defs'}
Truth table0%0/2
A
A= $struct->{'version'}
Aresult
11
00
Truth table0%0/2
A
A= $struct->{'operation_type'}
Aresult
11
00
Truth table0%0/2
A
A= $struct->{'variable_defs'}
Aresult
11
00
142 blocks => \@blocks,
143 root_block => $root_block,
144 );
145 0 _bind_instruction_blocks($program);
146 0 return $program;
147 }
148  
149 1 ▶sub _lower_selection_block {
Subroutine _lower_selection_block: called CC=27 SCAR=47.2
150 1 my ($state, $type_name, $schema_block, $selections, $base_name) = @_;
151 1 ▶ my %schema_slots = map { ($_->field_name => $_) } @{ $schema_block->slots || [] };
Condition50%1/2
$schema_block->slots || []
l!l
10
MC/DC0%0/1
$schema_block->slots || []
$schema_block->slots
Truth table50%1/2
A
A= $schema_block->slots
Aresult
11
00
152 1 my @ops;
153 1 my $field_selections = _normalize_selections($state, $selections, $type_name);
154  
155 1 ▶ for my $selection (@{ $field_selections || [] }) {
Condition50%1/2
$field_selections || []
l!l
10
MC/DC0%0/1
$field_selections || []
$field_selections
Truth table50%1/2
A
A= $field_selections
Aresult
11
00
156 1 ▶ next if !$selection || ($selection->{kind} || '') ne 'field';
Branch: 1 branch
BranchTrueFalseTotal
if not $selection or ($selection->{"kind"} || "") ne "field" 0 1 1
Condition40%2/5
not $selection or ($selection->{"kind"} || "") ne "field"
l!l&&r!l&&!r
001
$selection->{'kind'} || ''
l!l
10
MC/DC0%0/2
not $selection or ($selection->{"kind"} || "") ne "field"
not $selection $selection->{'kind'}
Truth table33%1/3
not(A) or B
A= not $selectionB= $selection->{'kind'}
ABresult
1X1
011
000
157 1 my $field_name = $selection->{name};
158 1 ▶ if (($field_name || q()) eq '__typename') {
Branch: 1 branch
BranchTrueFalseTotal
if (($field_name || "") eq "__typename") 0 1 1
Condition50%1/2
$field_name || ''
l!l
10
MC/DC0%0/1
$field_name || ''
$field_name
Truth table50%1/2
A
A= $field_name
Aresult
11
00
159 0 push @ops, _build_typename_instruction($state, $type_name, $selection);
160 0 next;
161 }
162 1 ▶ my $slot = $schema_slots{$field_name} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $slot = $schema_slots{$field_name} or next 1 0 1
163 1 my $child_block;
164 my $abstract_child_blocks;
165 1 my ($args_mode, $args_payload) = _lower_arguments($selection->{arguments});
166 1 my ($directives_mode, $directives_payload) = _lower_directives($selection->{_runtime_guards});
167 my ($runtime_directives_mode, $runtime_directives_payload) =
168 1 _lower_directives($selection->{_runtime_directives});
169  
170 0 ▶ if ($selection->{selections} && @{ $selection->{selections} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($selection->{"selections"} and @{$selection->{"selections"};}) 0 1 1
Condition33%1/3
$selection->{"selections"} and @{$selection->{"selections"};}
!ll&&!rl&&r
100
MC/DC0%0/2
$selection->{"selections"} and @{$selection->{"selections"};}
$selection->{"selections"} @{$selection->{"selections"};}
Truth table33%1/3
A and B
A= $selection->{"selections"}B= @{$selection->{"selections"};}
ABresult
0X0
100
111
171 0 my $child_type_name = $slot->return_type_name;
172 0 ▶ if (($slot->completion_family || '') eq 'ABSTRACT') {
Branch: 3 branches
BranchTrueFalseTotal
if (($slot->completion_family || '') eq 'ABSTRACT') { } 0 0 0
elsif (my $child_schema_block = $state->{'runtime_schema'}->block_by_type_name($child_type_name)) { } 0 0 0
elsif (@{$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name} or [];}) { } 0 0 0
Condition0%0/2
$slot->completion_family || ''
l!l
00
MC/DC0%0/1
$slot->completion_family || ''
$slot->completion_family
Truth table0%0/2
A
A= $slot->completion_family
Aresult
11
00
173 $abstract_child_blocks = _lower_abstract_child_blocks(
174 $state,
175 $child_type_name,
176 $selection->{selections},
177 0 $base_name . q(.) . $field_name,
178 );
179 }
180 elsif (my $child_schema_block = $state->{runtime_schema}->block_by_type_name($child_type_name)) {
181 $child_block = _lower_selection_block(
182 $state,
183 $child_type_name,
184 $child_schema_block,
185 $selection->{selections},
186 0 $base_name . q(.) . $field_name,
187 );
188 }
189 0 ▶ elsif (@{ $state->{runtime_schema}->runtime_cache->{possible_types}{$child_type_name} || [] }) {
Condition0%0/2
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name} || []
l!l
00
MC/DC0%0/1
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name} || []
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name}
Truth table0%0/2
A
A= $state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name}
Aresult
11
00
190 # A list of an interface/union: the inner type has no object block
191 # of its own, so lower one member block per possible type and let
192 # the runtime pick per item.
193 $abstract_child_blocks = _lower_abstract_child_blocks(
194 $state,
195 $child_type_name,
196 $selection->{selections},
197 0 $base_name . q(.) . $field_name,
198 );
199 }
200 }
201  
202 1 my $resolve_family = _resolve_op_for_slot($slot);
203 1 my $complete_family = _complete_op_for_slot($slot);
204 push @ops, GraphQL::Houtou::Runtime::VMOp->new(
205 opcode => join(q(:), $resolve_family, $complete_family),
206 opcode_code => (($RESOLVE_CODE{$resolve_family} || 0) * 16) + ($COMPLETE_CODE{$complete_family} || 0),
207 field_name => $field_name,
208 result_name => ($selection->{alias} || $field_name),
209 return_type_name => $slot->return_type_name,
210 resolve_family => $resolve_family,
211 resolve_code => $RESOLVE_CODE{$resolve_family} || 0,
212 complete_family => $complete_family,
213 1 ▶ complete_code => $COMPLETE_CODE{$complete_family} || 0,
Branch: 3 branches
BranchTrueFalseTotal
($directives_mode || 'NONE') ne 'NONE' ? : 0 1 1
($runtime_directives_mode || 'NONE') ne 'NONE' ? : 0 1 1
$child_block ? : 0 1 1
Condition46%7/15
$RESOLVE_CODE{$resolve_family} || 0
l!l
10
$COMPLETE_CODE{$complete_family} || 0
l!l
10
$selection->{'alias'} || $field_name
l!l&&r!l&&!r
010
$RESOLVE_CODE{$resolve_family} || 0
l!l
10
$COMPLETE_CODE{$complete_family} || 0
l!l
10
$directives_mode || 'NONE'
l!l
10
$runtime_directives_mode || 'NONE'
l!l
10
MC/DC0%0/1
$RESOLVE_CODE{$resolve_family} || 0
$RESOLVE_CODE{$resolve_family}
MC/DC0%0/1
$COMPLETE_CODE{$complete_family} || 0
$COMPLETE_CODE{$complete_family}
MC/DC0%0/2
$selection->{'alias'} || $field_name
$selection->{'alias'} $field_name
MC/DC0%0/1
$RESOLVE_CODE{$resolve_family} || 0
$RESOLVE_CODE{$resolve_family}
MC/DC0%0/1
$COMPLETE_CODE{$complete_family} || 0
$COMPLETE_CODE{$complete_family}
MC/DC0%0/1
$directives_mode || 'NONE'
$directives_mode
MC/DC0%0/1
$runtime_directives_mode || 'NONE'
$runtime_directives_mode
Truth table50%1/2
A
A= $RESOLVE_CODE{$resolve_family}
Aresult
11
00
Truth table50%1/2
A
A= $COMPLETE_CODE{$complete_family}
Aresult
11
00
Truth table33%1/3
A || B
A= $selection->{'alias'}B= $field_name
ABresult
1X1
011
000
Truth table50%1/2
A
A= $RESOLVE_CODE{$resolve_family}
Aresult
11
00
Truth table50%1/2
A
A= $COMPLETE_CODE{$complete_family}
Aresult
11
00
Truth table50%1/2
A
A= $directives_mode
Aresult
11
00
Truth table50%1/2
A
A= $runtime_directives_mode
Aresult
11
00
214 dispatch_family => $slot->dispatch_family,
215 has_args => $slot->has_args,
216 args_mode => $args_mode,
217 args_payload => $args_payload,
218 has_directives => (($directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
219 directives_mode => $directives_mode,
220 directives_payload => $directives_payload,
221 has_runtime_directives => (($runtime_directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
222 runtime_directives_mode => $runtime_directives_mode,
223 runtime_directives_payload => $runtime_directives_payload,
224 child_block_name => $child_block ? $child_block->name : undef,
225 abstract_child_blocks => $abstract_child_blocks,
226 abstract_child_blocks_index => undef,
227 bound_slot => $slot,
228 );
229 }
230  
231 1 my $block = GraphQL::Houtou::Runtime::VMBlock->new(
232 name => _next_block_name($state, $base_name),
233 type_name => $type_name,
234 family => 'OBJECT',
235 ops => \@ops,
236 );
237 1 push @{ $state->{blocks} }, $block;
238 1 return $block;
239 }
240  
241 1040 ▶sub _lower_selection_block_compact {
Subroutine _lower_selection_block_compact: called CC=30 SCAR=35.6
242 1040 my ($state, $type_name, $schema_block, $selections, $base_name) = @_;
243 1040 ▶ my %schema_slots = map { ($_->field_name => $_) } @{ $schema_block->slots || [] };
Condition50%1/2
$schema_block->slots || []
l!l
10400
MC/DC0%0/1
$schema_block->slots || []
$schema_block->slots
Truth table50%1/2
A
A= $schema_block->slots
Aresult
11
00
244 1040 my @ops;
245 my @slot_table;
246 1040 my %slot_index;
247 1040 my $field_selections = _normalize_selections($state, $selections, $type_name);
248  
249 1040 ▶ for my $selection (@{ $field_selections || [] }) {
Condition50%1/2
$field_selections || []
l!l
10400
MC/DC0%0/1
$field_selections || []
$field_selections
Truth table50%1/2
A
A= $field_selections
Aresult
11
00
250 1952 ▶ next if !$selection || ($selection->{kind} || '') ne 'field';
Branch: 1 branch
BranchTrueFalseTotal
if not $selection or ($selection->{"kind"} || "") ne "field" 0 1952 1952
Condition40%2/5
not $selection or ($selection->{"kind"} || "") ne "field"
l!l&&r!l&&!r
001952
$selection->{'kind'} || ''
l!l
19520
MC/DC0%0/2
not $selection or ($selection->{"kind"} || "") ne "field"
not $selection $selection->{'kind'}
Truth table33%1/3
not(A) or B
A= not $selectionB= $selection->{'kind'}
ABresult
1X1
011
000
251 1952 my $field_name = $selection->{name};
252  
253 1952 ▶ if (($field_name || q()) eq '__typename') {
Branch: 1 branch
BranchTrueFalseTotal
if (($field_name || "") eq "__typename") 29 1923 1952
Condition50%1/2
$field_name || ''
l!l
19520
MC/DC0%0/1
$field_name || ''
$field_name
Truth table50%1/2
A
A= $field_name
Aresult
11
00
254 29 my ($directives_mode, $directives_payload) = _lower_directives($selection->{_runtime_guards});
255 my ($runtime_directives_mode, $runtime_directives_payload) =
256 29 _lower_directives($selection->{_runtime_directives});
257 my $directives_payload_index = _intern_compact_payload(
258 $state->{directives_payloads_compact},
259 $state->{directives_payload_index},
260 29 $directives_payload,
261 );
262 29 ▶ my $result_name = ($selection->{alias} || '__typename');
Condition100%2/2
$selection->{'alias'} || '__typename'
l!l
128
MC/DC100%1/1
$selection->{'alias'} || '__typename'
$selection->{'alias'}
Truth table100%2/2
A
A= $selection->{'alias'}
Aresult
11
00
263 29 my $slot = _lookup_typename_slot($state->{runtime_schema}, $type_name, $result_name, $directives_mode);
264 29 my $slot_compact_index = _intern_slot_compact(\@slot_table, \%slot_index, $slot, $result_name);
265 29 ▶ push @ops, _build_compact_op(
Branch: 3 branches
BranchTrueFalseTotal
defined $directives_payload_index ? : 0 29 29
($directives_mode || 'NONE') ne 'NONE' ? : 0 29 29
($runtime_directives_mode || 'NONE') ne 'NONE' ? : 0 29 29
Condition50%2/4
$directives_mode || 'NONE'
l!l
290
$runtime_directives_mode || 'NONE'
l!l
290
MC/DC0%0/1
$directives_mode || 'NONE'
$directives_mode
MC/DC0%0/1
$runtime_directives_mode || 'NONE'
$runtime_directives_mode
Truth table50%1/2
A
A= $directives_mode
Aresult
11
00
Truth table50%1/2
A
A= $runtime_directives_mode
Aresult
11
00
266 field_name => '__typename',
267 result_name => $result_name,
268 return_type_name => 'String',
269 resolve_family => 'RESOLVE_DEFAULT',
270 complete_family => 'COMPLETE_GENERIC',
271 dispatch_family => 'DEFAULT',
272 slot_index => $slot_compact_index,
273 args_mode => 'NONE',
274 args_payload_index => undef,
275 args_payload => undef,
276 has_args => 0,
277 directives_mode => $directives_mode,
278 directives_payload_index => $directives_payload_index,
279 directives_payload => defined $directives_payload_index ? undef : $directives_payload,
280 has_directives => (($directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
281 runtime_directives_mode => $runtime_directives_mode,
282 runtime_directives_payload => $runtime_directives_payload,
283 has_runtime_directives => (($runtime_directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
284 child_block_index => undef,
285 abstract_child_block_indexes => {},
286 );
287 29 next;
288 }
289  
290 1923 ▶ my $slot = $schema_slots{$field_name} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $slot = $schema_slots{$field_name} or next 1921 2 1923
291 1921 my $child_block_index;
292 1921 my $abstract_child_block_indexes = {};
293 1921 my ($args_mode, $args_payload) = _lower_arguments($selection->{arguments});
294 1921 my ($directives_mode, $directives_payload) = _lower_directives($selection->{_runtime_guards});
295 my ($runtime_directives_mode, $runtime_directives_payload) =
296 1921 _lower_directives($selection->{_runtime_directives});
297 my $args_payload_index = _intern_compact_payload(
298 $state->{args_payloads_compact},
299 $state->{args_payload_index},
300 1921 $args_payload,
301 );
302 my $directives_payload_index = _intern_compact_payload(
303 $state->{directives_payloads_compact},
304 $state->{directives_payload_index},
305 1921 $directives_payload,
306 );
307  
308 1921 ▶ if ($selection->{selections} && @{ $selection->{selections} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($selection->{"selections"} and @{$selection->{"selections"};}) 570 1351 1921
Condition66%2/3
$selection->{"selections"} and @{$selection->{"selections"};}
!ll&&!rl&&r
13510570
MC/DC50%1/2
$selection->{"selections"} and @{$selection->{"selections"};}
$selection->{"selections"} @{$selection->{"selections"};}
Truth table66%2/3
A and B
A= $selection->{"selections"}B= @{$selection->{"selections"};}
ABresult
0X0
100
111
309 570 my $child_type_name = $slot->return_type_name;
310 570 ▶ if (($slot->completion_family || '') eq 'ABSTRACT') {
Branch: 3 branches
BranchTrueFalseTotal
if (($slot->completion_family || '') eq 'ABSTRACT') { } 37 533 570
elsif (my $child_schema_block = $state->{'runtime_schema'}->block_by_type_name($child_type_name)) { } 493 40 533
elsif (@{$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name} or [];}) { } 40 0 40
Condition50%1/2
$slot->completion_family || ''
l!l
5700
MC/DC0%0/1
$slot->completion_family || ''
$slot->completion_family
Truth table50%1/2
A
A= $slot->completion_family
Aresult
11
00
311 $abstract_child_block_indexes = _lower_abstract_child_blocks_compact(
312 $state,
313 $child_type_name,
314 $selection->{selections},
315 37 $base_name . q(.) . $field_name,
316 );
317 }
318 elsif (my $child_schema_block = $state->{runtime_schema}->block_by_type_name($child_type_name)) {
319 $child_block_index = _lower_selection_block_compact(
320 $state,
321 $child_type_name,
322 $child_schema_block,
323 $selection->{selections},
324 493 $base_name . q(.) . $field_name,
325 );
326 }
327 40 ▶ elsif (@{ $state->{runtime_schema}->runtime_cache->{possible_types}{$child_type_name} || [] }) {
Condition50%1/2
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name} || []
l!l
400
MC/DC0%0/1
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name} || []
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name}
Truth table50%1/2
A
A= $state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$child_type_name}
Aresult
11
00
328 # A list of an interface/union: the inner type has no object block
329 # of its own, so lower one member block per possible type and let
330 # the runtime pick per item.
331 $abstract_child_block_indexes = _lower_abstract_child_blocks_compact(
332 $state,
333 $child_type_name,
334 $selection->{selections},
335 40 $base_name . q(.) . $field_name,
336 );
337 }
338 }
339  
340 1921 my $resolve_family = _resolve_op_for_slot($slot);
341 1921 my $complete_family = _complete_op_for_slot($slot);
342 1921 ▶ my $result_name = ($selection->{alias} || $field_name);
Condition66%2/3
$selection->{'alias'} || $field_name
l!l&&r!l&&!r
29216290
MC/DC0%0/2
$selection->{'alias'} || $field_name
$selection->{'alias'} $field_name
Truth table66%2/3
A || B
A= $selection->{'alias'}B= $field_name
ABresult
1X1
011
000
343 1921 my $slot_compact_index = _intern_slot_compact(\@slot_table, \%slot_index, $slot, $result_name);
344  
345 1921 ▶ push @ops, _build_compact_op(
Branch: 4 branches
BranchTrueFalseTotal
defined $args_payload_index ? : 250 1671 1921
defined $directives_payload_index ? : 15 1906 1921
($directives_mode || 'NONE') ne 'NONE' ? : 15 1906 1921
($runtime_directives_mode || 'NONE') ne 'NONE' ? : 4 1917 1921
Condition50%2/4
$directives_mode || 'NONE'
l!l
19210
$runtime_directives_mode || 'NONE'
l!l
19210
MC/DC0%0/1
$directives_mode || 'NONE'
$directives_mode
MC/DC0%0/1
$runtime_directives_mode || 'NONE'
$runtime_directives_mode
Truth table50%1/2
A
A= $directives_mode
Aresult
11
00
Truth table50%1/2
A
A= $runtime_directives_mode
Aresult
11
00
346 field_name => $field_name,
347 result_name => $result_name,
348 return_type_name => $slot->return_type_name,
349 resolve_family => $resolve_family,
350 complete_family => $complete_family,
351 dispatch_family => $slot->dispatch_family,
352 slot_index => $slot_compact_index,
353 args_mode => $args_mode,
354 args_payload_index => $args_payload_index,
355 args_payload => defined $args_payload_index ? undef : $args_payload,
356 has_args => $slot->has_args,
357 directives_mode => $directives_mode,
358 directives_payload_index => $directives_payload_index,
359 directives_payload => defined $directives_payload_index ? undef : $directives_payload,
360 has_directives => (($directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
361 runtime_directives_mode => $runtime_directives_mode,
362 runtime_directives_payload => $runtime_directives_payload,
363 has_runtime_directives => (($runtime_directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
364 child_block_index => $child_block_index,
365 abstract_child_block_indexes => $abstract_child_block_indexes,
366 );
367 }
368  
369 1040 my $name = _next_block_name($state, $base_name);
370 1040 my $block = [
371 $name,
372 $type_name,
373 2,
374 \@slot_table,
375 \@ops,
376 ];
377 1040 push @{ $state->{blocks_compact} }, $block;
378 1040 return $#{$state->{blocks_compact}};
379 }
380  
381 1041 ▶sub _next_block_name {
Subroutine _next_block_name: called CC=1 SCAR=0.0
382 1041 my ($state, $base_name) = @_;
383 1041 my $name = sprintf('%s#%d', $base_name, $state->{block_index}++);
384 1041 return $name;
385 }
386  
387 0 ▶sub _inflate_execution_block {
Subroutine _inflate_execution_block: not called CC=4 SCAR=30.0
388 0 my ($struct) = @_;
389 return GraphQL::Houtou::Runtime::VMBlock->new(
390 name => $struct->{name},
391 type_name => $struct->{type_name},
392 family => $struct->{family} || 'OBJECT',
393 0 ▶ ops => [ map { _inflate_instruction($_) } @{ $struct->{ops} || $struct->{instructions} || [] } ],
Condition0%0/7
$struct->{'family'} || 'OBJECT'
l!l
00
$struct->{'ops'} || $struct->{'instructions'} || []
l!l
00
$struct->{"ops"} or $struct->{"instructions"}
l!l&&r!l&&!r
000
MC/DC0%0/1
$struct->{'family'} || 'OBJECT'
$struct->{'family'}
MC/DC0%0/2
$struct->{'ops'} || $struct->{'instructions'} || []
$struct->{"ops"} $struct->{"instructions"}
Truth table0%0/2
A
A= $struct->{'family'}
Aresult
11
00
Truth table0%0/3
A or B
A= $struct->{"ops"}B= $struct->{"instructions"}
ABresult
1X1
011
000
394 );
395 }
396  
397 0 ▶sub _inflate_instruction {
Subroutine _inflate_instruction: not called CC=17 SCAR=57.2
398 0 my ($struct) = @_;
399 0 ▶ my $resolve_family = $struct->{resolve_family} || $struct->{resolve_op} || 'RESOLVE_DEFAULT';
Condition0%0/5
$struct->{'resolve_family'} || $struct->{'resolve_op'} || 'RESOLVE_DEFAULT'
l!l
00
$struct->{"resolve_family"} or $struct->{"resolve_op"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$struct->{'resolve_family'} || $struct->{'resolve_op'} || 'RESOLVE_DEFAULT'
$struct->{"resolve_family"} $struct->{"resolve_op"}
Truth table0%0/3
A or B
A= $struct->{"resolve_family"}B= $struct->{"resolve_op"}
ABresult
1X1
011
000
400 0 ▶ my $complete_family = $struct->{complete_family} || $struct->{complete_op} || 'COMPLETE_GENERIC';
Condition0%0/5
$struct->{'complete_family'} || $struct->{'complete_op'} || 'COMPLETE_GENERIC'
l!l
00
$struct->{"complete_family"} or $struct->{"complete_op"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$struct->{'complete_family'} || $struct->{'complete_op'} || 'COMPLETE_GENERIC'
$struct->{"complete_family"} $struct->{"complete_op"}
Truth table0%0/3
A or B
A= $struct->{"complete_family"}B= $struct->{"complete_op"}
ABresult
1X1
011
000
401 return GraphQL::Houtou::Runtime::VMOp->new(
402 opcode => $struct->{opcode} || join(q(:), $resolve_family, $complete_family),
403 opcode_code => $struct->{opcode_code} || (($RESOLVE_CODE{$resolve_family} || 0) * 16) + ($COMPLETE_CODE{$complete_family} || 0),
404 field_name => $struct->{field_name},
405 result_name => $struct->{result_name},
406 return_type_name => $struct->{return_type_name},
407 resolve_family => $resolve_family,
408 resolve_code => $struct->{resolve_code} || $RESOLVE_CODE{$resolve_family} || 0,
409 complete_family => $complete_family,
410 complete_code => $struct->{complete_code} || $COMPLETE_CODE{$complete_family} || 0,
411 dispatch_family => $struct->{dispatch_family},
412 has_args => $struct->{has_args},
413 args_mode => $struct->{args_mode} || 'NONE',
414 args_payload => _clone_argument_value($struct->{args_payload}),
415 has_directives => $struct->{has_directives},
416 directives_mode => $struct->{directives_mode} || 'NONE',
417 directives_payload => _clone_argument_value($struct->{directives_payload}),
418 has_runtime_directives => $struct->{has_runtime_directives},
419 runtime_directives_mode => $struct->{runtime_directives_mode} || 'NONE',
420 runtime_directives_payload => _clone_argument_value($struct->{runtime_directives_payload}),
421 child_block_name => $struct->{child_block_name},
422 abstract_child_blocks => _clone_argument_value($struct->{abstract_child_blocks} || {}),
423 abstract_child_blocks_index => $struct->{abstract_child_blocks_index},
424 0 ▶ );
Condition0%0/28
$struct->{'opcode'} || join(':', $resolve_family, $complete_family)
l!l&&r!l&&!r
000
$struct->{'opcode_code'} || ($RESOLVE_CODE{$resolve_family} || 0) * 16 + ($COMPLETE_CODE{$complete_family} || 0)
l!l&&r!l&&!r
000
$RESOLVE_CODE{$resolve_family} || 0
l!l
00
$COMPLETE_CODE{$complete_family} || 0
l!l
00
$struct->{'resolve_code'} || $RESOLVE_CODE{$resolve_family} || 0
l!l
00
$struct->{"resolve_code"} or $RESOLVE_CODE{$resolve_family}
l!l&&r!l&&!r
000
$struct->{'complete_code'} || $COMPLETE_CODE{$complete_family} || 0
l!l
00
$struct->{"complete_code"} or $COMPLETE_CODE{$complete_family}
l!l&&r!l&&!r
000
$struct->{'args_mode'} || 'NONE'
l!l
00
$struct->{'directives_mode'} || 'NONE'
l!l
00
$struct->{'runtime_directives_mode'} || 'NONE'
l!l
00
$struct->{'abstract_child_blocks'} || {}
l!l
00
MC/DC0%0/2
$struct->{'opcode'} || join(':', $resolve_family, $complete_family)
$struct->{'opcode'} join(':', $resolve_family, $complete_family)
MC/DC0%0/2
$struct->{'opcode_code'} || ($RESOLVE_CODE{$resolve_family} || 0) * 16 + ($COMPLETE_CODE{$complete_family} || 0)
$struct->{'opcode_code'} $RESOLVE_CODE{$resolve_family}
MC/DC0%0/1
$COMPLETE_CODE{$complete_family} || 0
$COMPLETE_CODE{$complete_family}
MC/DC0%0/2
$struct->{'resolve_code'} || $RESOLVE_CODE{$resolve_family} || 0
$struct->{"resolve_code"} $RESOLVE_CODE{$resolve_family}
MC/DC0%0/2
$struct->{'complete_code'} || $COMPLETE_CODE{$complete_family} || 0
$struct->{"complete_code"} $COMPLETE_CODE{$complete_family}
MC/DC0%0/1
$struct->{'args_mode'} || 'NONE'
$struct->{'args_mode'}
MC/DC0%0/1
$struct->{'directives_mode'} || 'NONE'
$struct->{'directives_mode'}
MC/DC0%0/1
$struct->{'runtime_directives_mode'} || 'NONE'
$struct->{'runtime_directives_mode'}
MC/DC0%0/1
$struct->{'abstract_child_blocks'} || {}
$struct->{'abstract_child_blocks'}
Truth table0%0/3
A || B
A= $struct->{'opcode'}B= join(':', $resolve_family, $complete_family)
ABresult
1X1
011
000
Truth table0%0/3
A || B
A= $struct->{'opcode_code'}B= $RESOLVE_CODE{$resolve_family}
ABresult
1X1
011
000
Truth table0%0/2
A
A= $COMPLETE_CODE{$complete_family}
Aresult
11
00
Truth table0%0/3
A or B
A= $struct->{"resolve_code"}B= $RESOLVE_CODE{$resolve_family}
ABresult
1X1
011
000
Truth table0%0/3
A or B
A= $struct->{"complete_code"}B= $COMPLETE_CODE{$complete_family}
ABresult
1X1
011
000
Truth table0%0/2
A
A= $struct->{'args_mode'}
Aresult
11
00
Truth table0%0/2
A
A= $struct->{'directives_mode'}
Aresult
11
00
Truth table0%0/2
A
A= $struct->{'runtime_directives_mode'}
Aresult
11
00
Truth table0%0/2
A
A= $struct->{'abstract_child_blocks'}
Aresult
11
00
425 }
426  
427 0 ▶sub _bind_instructions_to_schema_slots {
Subroutine _bind_instructions_to_schema_slots: not called CC=7 SCAR=40.3
428 0 my ($runtime_schema, $blocks) = @_;
429  
430 0 ▶ for my $block (@{ $blocks || [] }) {
Condition0%0/2
$blocks || []
l!l
00
MC/DC0%0/1
$blocks || []
$blocks
Truth table0%0/2
A
A= $blocks
Aresult
11
00
431 0 ▶ my $schema_block = $runtime_schema->block_by_type_name($block->type_name) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $schema_block = $runtime_schema->block_by_type_name($block->type_name) or next 0 0 0
432 0 ▶ my %slots = map { ($_->field_name => $_) } @{ $schema_block->slots || [] };
Condition0%0/2
$schema_block->slots || []
l!l
00
MC/DC0%0/1
$schema_block->slots || []
$schema_block->slots
Truth table0%0/2
A
A= $schema_block->slots
Aresult
11
00
433 0 ▶ for my $op (@{ $block->ops || [] }) {
Condition0%0/2
$block->ops || []
l!l
00
MC/DC0%0/1
$block->ops || []
$block->ops
Truth table0%0/2
A
A= $block->ops
Aresult
11
00
434 0 $op->set_bound_slot($slots{ $op->field_name });
435 }
436 }
437  
438 0 return $blocks;
439 }
440  
441 1 ▶sub _bind_instruction_blocks {
Subroutine _bind_instruction_blocks: called CC=12 SCAR=29.3
442 1 my ($program) = @_;
443 1 ▶ my %by_name = map { ($_->name => $_) } @{ $program->blocks || [] };
Condition50%1/2
$program->blocks || []
l!l
10
MC/DC0%0/1
$program->blocks || []
$program->blocks
Truth table50%1/2
A
A= $program->blocks
Aresult
11
00
444 1 ▶ if (my $root = $program->root_block) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $root = $program->root_block) 1 0 1
445 1 $by_name{ $root->name } = $root;
446 }
447  
448 1 ▶ for my $block (@{ $program->blocks || [] }, ($program->root_block || ())) {
Condition40%2/5
$program->blocks || []
l!l
10
$program->root_block || ()
l!l&&r!l&&!r
100
MC/DC0%0/1
$program->blocks || []
$program->blocks
MC/DC0%0/2
$program->root_block || ()
$program->root_block ()
Truth table50%1/2
A
A= $program->blocks
Aresult
11
00
Truth table33%1/3
A || B
A= $program->root_blockB= ()
ABresult
1X1
011
000
449 2 ▶ next if !$block;
Branch: 1 branch
BranchTrueFalseTotal
unless $block 0 2 2
450 2 ▶ for my $op (@{ $block->ops || [] }) {
Condition50%1/2
$block->ops || []
l!l
20
MC/DC0%0/1
$block->ops || []
$block->ops
Truth table50%1/2
A
A= $block->ops
Aresult
11
00
451 $op->set_bound_child_block($op->child_block_name
452 2 ▶ ? $by_name{ $op->child_block_name }
Branch: 1 branch
BranchTrueFalseTotal
$op->child_block_name ? : 0 2 2
453 : undef);
454 $op->set_bound_abstract_child_blocks({
455 map {
456 0 my $child_name = $op->abstract_child_blocks->{$_};
457 0 ▶ ($_ => ($child_name ? $by_name{$child_name} : undef))
Branch: 1 branch
BranchTrueFalseTotal
$child_name ? : 0 0 0
458 2 ▶ } keys %{ $op->abstract_child_blocks || {} }
Condition50%1/2
$op->abstract_child_blocks || {}
l!l
20
MC/DC0%0/1
$op->abstract_child_blocks || {}
$op->abstract_child_blocks
Truth table50%1/2
A
A= $op->abstract_child_blocks
Aresult
11
00
459 });
460 }
461 }
462  
463 1 return $program;
464 }
465  
466 0 ▶sub _lower_abstract_child_blocks {
Subroutine _lower_abstract_child_blocks: not called CC=7 SCAR=40.3
467 0 my ($state, $abstract_type_name, $selections, $base_name) = @_;
468 0 ▶ my $possible_types = $state->{runtime_schema}->runtime_cache->{possible_types}{$abstract_type_name} || [];
Condition0%0/2
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$abstract_type_name} || []
l!l
00
MC/DC0%0/1
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$abstract_type_name} || []
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$abstract_type_name}
Truth table0%0/2
A
A= $state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$abstract_type_name}
Aresult
11
00
469 0 my %blocks;
470  
471 0 for my $type (@$possible_types) {
472 0 ▶ next if !$type || !$type->isa('GraphQL::Houtou::Type::Object');
Branch: 1 branch
BranchTrueFalseTotal
unless $type and $type->isa("GraphQL::Houtou::Type::Object") 0 0 0
Condition0%0/3
$type and $type->isa("GraphQL::Houtou::Type::Object")
!ll&&!rl&&r
000
MC/DC0%0/2
$type and $type->isa("GraphQL::Houtou::Type::Object")
$type $type->isa("GraphQL::Houtou::Type::Object")
Truth table0%0/3
A and B
A= $typeB= $type->isa("GraphQL::Houtou::Type::Object")
ABresult
0X0
100
111
473 0 ▶ my $schema_block = $state->{runtime_schema}->block_by_type_name($type->name) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $schema_block = $state->{"runtime_schema"}->block_by_type_name($type->name) or next 0 0 0
474 0 my $block = _lower_selection_block(
475 $state,
476 $type->name,
477 $schema_block,
478 $selections,
479 $base_name . q(.) . $type->name,
480 );
481 0 ▶ $blocks{ $type->name } = $block->name if $block;
Branch: 1 branch
BranchTrueFalseTotal
if $block 0 0 0
482 }
483  
484 0 return \%blocks;
485 }
486  
487 77 ▶sub _lower_abstract_child_blocks_compact {
Subroutine _lower_abstract_child_blocks_compact: called CC=7 SCAR=21.2
488 77 my ($state, $abstract_type_name, $selections, $base_name) = @_;
489 77 ▶ my $possible_types = $state->{runtime_schema}->runtime_cache->{possible_types}{$abstract_type_name} || [];
Condition50%1/2
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$abstract_type_name} || []
l!l
770
MC/DC0%0/1
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$abstract_type_name} || []
$state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$abstract_type_name}
Truth table50%1/2
A
A= $state->{'runtime_schema'}->runtime_cache->{'possible_types'}{$abstract_type_name}
Aresult
11
00
490 77 my %blocks;
491  
492 77 for my $type (@$possible_types) {
493 143 ▶ next if !$type || !$type->isa('GraphQL::Houtou::Type::Object');
Branch: 1 branch
BranchTrueFalseTotal
unless $type and $type->isa("GraphQL::Houtou::Type::Object") 0 143 143
Condition33%1/3
$type and $type->isa("GraphQL::Houtou::Type::Object")
!ll&&!rl&&r
00143
MC/DC0%0/2
$type and $type->isa("GraphQL::Houtou::Type::Object")
$type $type->isa("GraphQL::Houtou::Type::Object")
Truth table33%1/3
A and B
A= $typeB= $type->isa("GraphQL::Houtou::Type::Object")
ABresult
0X0
100
111
494 143 ▶ my $schema_block = $state->{runtime_schema}->block_by_type_name($type->name) or next;
Branch: 1 branch
BranchTrueFalseTotal
my $schema_block = $state->{"runtime_schema"}->block_by_type_name($type->name) or next 143 0 143
495 143 my $block_index = _lower_selection_block_compact(
496 $state,
497 $type->name,
498 $schema_block,
499 $selections,
500 $base_name . q(.) . $type->name,
501 );
502 143 ▶ $blocks{ $type->name } = $block_index if defined $block_index;
Branch: 1 branch
BranchTrueFalseTotal
if defined $block_index 143 0 143
503 }
504  
505 77 return \%blocks;
506 }
507  
508 1950 ▶sub _intern_slot_compact {
Subroutine _intern_slot_compact: called CC=4 SCAR=14.5
509 1950 my ($slot_table, $slot_index, $slot, $result_name) = @_;
510 1950 ▶ my $id = join("\x1E", refaddr($slot), ($result_name // q()));
Condition50%1/2
$result_name // ""
l!l
19500
MC/DC0%0/1
$result_name // ""
$result_name
Truth table50%1/2
A
A= $result_name
Aresult
11
00
511 1950 ▶ return $slot_index->{$id} if exists $slot_index->{$id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $slot_index->{$id} 0 1950 1950
512 1950 my $compact = $slot->to_native_compact_struct;
513 1950 ▶ $compact->[1] = ($result_name // $compact->[1]);
Condition33%1/3
$result_name // $compact->[1]
l!l&&r!l&&!r
195000
MC/DC0%0/2
$result_name // $compact->[1]
$result_name $compact->[1]
Truth table33%1/3
A // B
A= $result_nameB= $compact->[1]
ABresult
1X1
011
000
514 1950 my $index = @$slot_table;
515 1950 push @$slot_table, $compact;
516 1950 $slot_index->{$id} = $index;
517 1950 return $index;
518 }
519  
520 1950 ▶sub _build_compact_op {
Subroutine _build_compact_op: called CC=9 SCAR=23.3
521 1950 my (%args) = @_;
522 1950 ▶ my $resolve_code = $RESOLVE_CODE{ $args{resolve_family} || 'RESOLVE_DEFAULT' } || 0;
Condition50%2/4
$RESOLVE_CODE{$args{'resolve_family'} or 'RESOLVE_DEFAULT'} || 0
l!l
19500
$args{'resolve_family'} || 'RESOLVE_DEFAULT'
l!l
19500
MC/DC0%0/1
$RESOLVE_CODE{$args{'resolve_family'} or 'RESOLVE_DEFAULT'} || 0
$RESOLVE_CODE{$args{'resolve_family'} or 'RESOLVE_DEFAULT'}
MC/DC0%0/1
$args{'resolve_family'} || 'RESOLVE_DEFAULT'
$args{'resolve_family'}
Truth table50%1/2
A
A= $RESOLVE_CODE{$args{'resolve_family'} or 'RESOLVE_DEFAULT'}
Aresult
11
00
Truth table50%1/2
A
A= $args{'resolve_family'}
Aresult
11
00
523 1950 ▶ my $complete_code = $COMPLETE_CODE{ $args{complete_family} || 'COMPLETE_GENERIC' } || 0;
Condition50%2/4
$COMPLETE_CODE{$args{'complete_family'} or 'COMPLETE_GENERIC'} || 0
l!l
19500
$args{'complete_family'} || 'COMPLETE_GENERIC'
l!l
19500
MC/DC0%0/1
$COMPLETE_CODE{$args{'complete_family'} or 'COMPLETE_GENERIC'} || 0
$COMPLETE_CODE{$args{'complete_family'} or 'COMPLETE_GENERIC'}
MC/DC0%0/1
$args{'complete_family'} || 'COMPLETE_GENERIC'
$args{'complete_family'}
Truth table50%1/2
A
A= $COMPLETE_CODE{$args{'complete_family'} or 'COMPLETE_GENERIC'}
Aresult
11
00
Truth table50%1/2
A
A= $args{'complete_family'}
Aresult
11
00
524 return [
525 ($resolve_code * 16) + $complete_code,
526 $resolve_code,
527 $complete_code,
528 _dispatch_family_code($args{dispatch_family}),
529 $args{slot_index},
530 $args{child_block_index},
531 $args{abstract_child_block_indexes} || {},
532 _args_mode_code($args{args_mode}),
533 $args{args_payload_index},
534 $args{args_payload},
535 $args{has_args} ? 1 : 0,
536 _directives_mode_code($args{directives_mode}),
537 $args{directives_payload_index},
538 $args{directives_payload},
539 $args{has_directives} ? 1 : 0,
540 $args{field_name},
541 $args{result_name},
542 $args{return_type_name},
543 _directives_mode_code($args{runtime_directives_mode}),
544 $args{runtime_directives_payload},
545 1950 ▶ $args{has_runtime_directives} ? 1 : 0,
Branch: 3 branches
BranchTrueFalseTotal
$args{'has_args'} ? : 292 1658 1950
$args{'has_directives'} ? : 15 1935 1950
$args{'has_runtime_directives'} ? : 4 1946 1950
Condition50%1/2
$args{'abstract_child_block_indexes'} || {}
l!l
19500
MC/DC0%0/1
$args{'abstract_child_block_indexes'} || {}
$args{'abstract_child_block_indexes'}
Truth table50%1/2
A
A= $args{'abstract_child_block_indexes'}
Aresult
11
00
546 ];
547 }
548  
549 1950 ▶sub _dispatch_family_code {
Subroutine _dispatch_family_code: called CC=7 SCAR=21.1
550 1950 my ($family) = @_;
551 1950 ▶ return 2 if ($family || q()) eq 'RESOLVE_TYPE';
Branch: 1 branch
BranchTrueFalseTotal
if ($family || "") eq "RESOLVE_TYPE" 0 1950 1950
Condition50%1/2
$family || ''
l!l
19500
MC/DC0%0/1
$family || ''
$family
Truth table50%1/2
A
A= $family
Aresult
11
00
552 1950 ▶ return 3 if ($family || q()) eq 'TAG';
Branch: 1 branch
BranchTrueFalseTotal
if ($family || "") eq "TAG" 77 1873 1950
Condition50%1/2
$family || ''
l!l
19500
MC/DC0%0/1
$family || ''
$family
Truth table50%1/2
A
A= $family
Aresult
11
00
553 1873 ▶ return 4 if ($family || q()) eq 'POSSIBLE_TYPES';
Branch: 1 branch
BranchTrueFalseTotal
if ($family || "") eq "POSSIBLE_TYPES" 0 1873 1873
Condition50%1/2
$family || ''
l!l
18730
MC/DC0%0/1
$family || ''
$family
Truth table50%1/2
A
A= $family
Aresult
11
00
554 1873 return 1;
555 }
556  
557 1950 ▶sub _args_mode_code {
Subroutine _args_mode_code: called CC=5 SCAR=16.3
558 1950 my ($mode) = @_;
559 1950 ▶ return 1 if ($mode || q()) eq 'STATIC';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "STATIC" 114 1836 1950
Condition50%1/2
$mode || ''
l!l
19500
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
560 1836 ▶ return 2 if ($mode || q()) eq 'DYNAMIC';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "DYNAMIC" 136 1700 1836
Condition50%1/2
$mode || ''
l!l
18360
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
561 1700 return 0;
562 }
563  
564 3900 ▶sub _directives_mode_code {
Subroutine _directives_mode_code: called CC=5 SCAR=16.3
565 3900 my ($mode) = @_;
566 3900 ▶ return 1 if ($mode || q()) eq 'STATIC';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "STATIC" 2 3898 3900
Condition50%1/2
$mode || ''
l!l
39000
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
567 3898 ▶ return 2 if ($mode || q()) eq 'DYNAMIC';
Branch: 1 branch
BranchTrueFalseTotal
if ($mode || "") eq "DYNAMIC" 17 3881 3898
Condition50%1/2
$mode || ''
l!l
38980
MC/DC0%0/1
$mode || ''
$mode
Truth table50%1/2
A
A= $mode
Aresult
11
00
568 3881 return 0;
569 }
570  
571 404 ▶sub _operation_type_code {
Subroutine _operation_type_code: called CC=5 SCAR=16.8
572 404 my ($type) = @_;
573 404 ▶ return 2 if ($type || q()) eq 'mutation';
Branch: 1 branch
BranchTrueFalseTotal
if ($type || "") eq "mutation" 11 393 404
Condition50%1/2
$type || ''
l!l
4040
MC/DC0%0/1
$type || ''
$type
Truth table50%1/2
A
A= $type
Aresult
11
00
574 393 ▶ return 3 if ($type || q()) eq 'subscription';
Branch: 1 branch
BranchTrueFalseTotal
if ($type || "") eq "subscription" 0 393 393
Condition50%1/2
$type || ''
l!l
3930
MC/DC0%0/1
$type || ''
$type
Truth table50%1/2
A
A= $type
Aresult
11
00
575 393 return 1;
576 }
577  
578 1094 ▶sub _normalize_selections {
Subroutine _normalize_selections: called CC=26 SCAR=34.8
579 1094 my ($state, $selections, $type_name, $visited, $inherited_guards, $inherited_runtime_directives) = @_;
580 1094 ▶ $visited ||= {};
Condition100%2/2
$visited ||= {}
l!l
531041
MC/DC100%1/1
$visited ||= {}
$visited
Truth table100%2/2
A
A= $visited
Aresult
11
00
581 1094 ▶ $inherited_guards ||= [];
Condition100%2/2
$inherited_guards ||= []
l!l
531041
MC/DC100%1/1
$inherited_guards ||= []
$inherited_guards
Truth table100%2/2
A
A= $inherited_guards
Aresult
11
00
582 1094 ▶ $inherited_runtime_directives ||= [];
Condition100%2/2
$inherited_runtime_directives ||= []
l!l
531041
MC/DC100%1/1
$inherited_runtime_directives ||= []
$inherited_runtime_directives
Truth table100%2/2
A
A= $inherited_runtime_directives
Aresult
11
00
583 1094 my @normalized;
584  
585 1094 ▶ for my $selection (@{ $selections || [] }) {
Condition50%1/2
$selections || []
l!l
10940
MC/DC0%0/1
$selections || []
$selections
Truth table50%1/2
A
A= $selections
Aresult
11
00
586 2032 ▶ next if !$selection;
Branch: 1 branch
BranchTrueFalseTotal
unless $selection 0 2032 2032
587 2032 ▶ my $kind = $selection->{kind} || '';
Condition50%1/2
$selection->{'kind'} || ''
l!l
20320
MC/DC0%0/1
$selection->{'kind'} || ''
$selection->{'kind'}
Truth table50%1/2
A
A= $selection->{'kind'}
Aresult
11
00
588 2032 my ($allowed, $dynamic_guards, $runtime_directives) = _partition_runtime_guards($selection->{directives});
589 2032 ▶ next if !$allowed;
Branch: 1 branch
BranchTrueFalseTotal
unless $allowed 2 2030 2032
590 2030 my $combined_guards = [ @$inherited_guards, @$dynamic_guards ];
591 2030 my $combined_runtime_directives = [ @$inherited_runtime_directives, @$runtime_directives ];
592 2030 ▶ if ($kind eq 'field') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "field") 1953 77 2030
593 1953 my %copy = %$selection;
594 1953 ▶ $copy{_runtime_guards} = $combined_guards if @$combined_guards;
Branch: 1 branch
BranchTrueFalseTotal
if @$combined_guards 15 1938 1953
595 1953 ▶ $copy{_runtime_directives} = $combined_runtime_directives if @$combined_runtime_directives;
Branch: 1 branch
BranchTrueFalseTotal
if @$combined_runtime_directives 4 1949 1953
596 1953 push @normalized, \%copy;
597 1953 next;
598 }
599 77 ▶ if ($kind eq 'inline_fragment') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "inline_fragment") 51 26 77
600 51 my $on = $selection->{on};
601 51 ▶ next if defined($on) && defined($type_name) && $on ne $type_name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $on and defined $type_name and $on ne $type_name 24 27 51
Condition50%3/6
defined $on and defined $type_name and $on ne $type_name
!ll&&!rl&&r
02724
defined $on and defined $type_name
!ll&&!rl&&r
0051
MC/DC33%1/3
defined $on and defined $type_name and $on ne $type_name
defined $on defined $type_name $on ne $type_name
Truth table50%2/4
A and B and C
A= defined $onB= defined $type_nameC= $on ne $type_name
ABCresult
0XX0
10X0
1100
1111
602 27 push @normalized, @{ _normalize_selections(
603 $state,
604 27 ▶ $selection->{selections} || [],
Condition50%1/2
$selection->{'selections'} || []
l!l
270
MC/DC0%0/1
$selection->{'selections'} || []
$selection->{'selections'}
Truth table50%1/2
A
A= $selection->{'selections'}
Aresult
11
00
605 $type_name,
606 $visited,
607 $combined_guards,
608 $combined_runtime_directives,
609 ) };
610 27 next;
611 }
612 26 ▶ if ($kind eq 'fragment_spread') {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind eq "fragment_spread") 26 0 26
613 26 ▶ my $name = $selection->{name} || '';
Condition50%1/2
$selection->{'name'} || ''
l!l
260
MC/DC0%0/1
$selection->{'name'} || ''
$selection->{'name'}
Truth table50%1/2
A
A= $selection->{'name'}
Aresult
11
00
614 26 ▶ next if !$name || $visited->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if not $name or $visited->{$name} 0 26 26
Condition33%1/3
not $name or $visited->{$name}
l!l&&r!l&&!r
0026
MC/DC0%0/2
not $name or $visited->{$name}
not $name $visited->{$name}
Truth table33%1/3
not(A) or B
A= not $nameB= $visited->{$name}
ABresult
1X1
011
000
615 26 ▶ my $fragment = $state->{fragments}{$name} or next;
Branch: 1 branch
BranchTrueFalseTotal
my $fragment = $state->{"fragments"}{$name} or next 26 0 26
616 26 my $on = $fragment->{on};
617 26 ▶ next if defined($on) && defined($type_name) && $on ne $type_name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $on and defined $type_name and $on ne $type_name 0 26 26
Condition33%2/6
defined $on and defined $type_name and $on ne $type_name
!ll&&!rl&&r
0260
defined $on and defined $type_name
!ll&&!rl&&r
0026
MC/DC0%0/3
defined $on and defined $type_name and $on ne $type_name
defined $on defined $type_name $on ne $type_name
Truth table25%1/4
A and B and C
A= defined $onB= defined $type_nameC= $on ne $type_name
ABCresult
0XX0
10X0
1100
1111
618 26 local $visited->{$name} = 1;
619 26 push @normalized, @{ _normalize_selections(
620 $state,
621 26 ▶ $fragment->{selections} || [],
Condition50%1/2
$fragment->{'selections'} || []
l!l
260
MC/DC0%0/1
$fragment->{'selections'} || []
$fragment->{'selections'}
Truth table50%1/2
A
A= $fragment->{'selections'}
Aresult
11
00
622 $type_name,
623 $visited,
624 $combined_guards,
625 $combined_runtime_directives,
626 ) };
627 26 next;
628 }
629 }
630  
631 1094 return \@normalized;
632 }
633  
634 0 ▶sub _build_typename_instruction {
Subroutine _build_typename_instruction: not called CC=10 SCAR=47.0
635 0 my ($state, $type_name, $selection) = @_;
636 0 my ($directives_mode, $directives_payload) = _lower_directives($selection->{_runtime_guards});
637 my ($runtime_directives_mode, $runtime_directives_payload) =
638 0 _lower_directives($selection->{_runtime_directives});
639 0 ▶ my $result_name = ($selection->{alias} || '__typename');
Condition0%0/2
$selection->{'alias'} || '__typename'
l!l
00
MC/DC0%0/1
$selection->{'alias'} || '__typename'
$selection->{'alias'}
Truth table0%0/2
A
A= $selection->{'alias'}
Aresult
11
00
640 0 my $slot = _lookup_typename_slot($state->{runtime_schema}, $type_name, $result_name, $directives_mode);
641 0 my $resolve_family = 'RESOLVE_DEFAULT';
642 0 my $complete_family = 'COMPLETE_GENERIC';
643 return GraphQL::Houtou::Runtime::VMOp->new(
644 opcode => 'RESOLVE_DEFAULT:COMPLETE_GENERIC',
645 opcode_code => (($RESOLVE_CODE{$resolve_family} || 0) * 16) + ($COMPLETE_CODE{$complete_family} || 0),
646 field_name => '__typename',
647 result_name => $result_name,
648 return_type_name => 'String',
649 resolve_family => $resolve_family,
650 resolve_code => $RESOLVE_CODE{$resolve_family} || 0,
651 complete_family => $complete_family,
652 0 ▶ complete_code => $COMPLETE_CODE{$complete_family} || 0,
Branch: 2 branches
BranchTrueFalseTotal
($directives_mode || 'NONE') ne 'NONE' ? : 0 0 0
($runtime_directives_mode || 'NONE') ne 'NONE' ? : 0 0 0
Condition0%0/12
$RESOLVE_CODE{$resolve_family} || 0
l!l
00
$COMPLETE_CODE{$complete_family} || 0
l!l
00
$RESOLVE_CODE{$resolve_family} || 0
l!l
00
$COMPLETE_CODE{$complete_family} || 0
l!l
00
$directives_mode || 'NONE'
l!l
00
$runtime_directives_mode || 'NONE'
l!l
00
MC/DC0%0/1
$RESOLVE_CODE{$resolve_family} || 0
$RESOLVE_CODE{$resolve_family}
MC/DC0%0/1
$COMPLETE_CODE{$complete_family} || 0
$COMPLETE_CODE{$complete_family}
MC/DC0%0/1
$RESOLVE_CODE{$resolve_family} || 0
$RESOLVE_CODE{$resolve_family}
MC/DC0%0/1
$COMPLETE_CODE{$complete_family} || 0
$COMPLETE_CODE{$complete_family}
MC/DC0%0/1
$directives_mode || 'NONE'
$directives_mode
MC/DC0%0/1
$runtime_directives_mode || 'NONE'
$runtime_directives_mode
Truth table0%0/2
A
A= $RESOLVE_CODE{$resolve_family}
Aresult
11
00
Truth table0%0/2
A
A= $COMPLETE_CODE{$complete_family}
Aresult
11
00
Truth table0%0/2
A
A= $RESOLVE_CODE{$resolve_family}
Aresult
11
00
Truth table0%0/2
A
A= $COMPLETE_CODE{$complete_family}
Aresult
11
00
Truth table0%0/2
A
A= $directives_mode
Aresult
11
00
Truth table0%0/2
A
A= $runtime_directives_mode
Aresult
11
00
653 dispatch_family => 'DEFAULT',
654 has_args => 0,
655 args_mode => 'NONE',
656 args_payload => undef,
657 has_directives => (($directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
658 directives_mode => $directives_mode,
659 directives_payload => $directives_payload,
660 has_runtime_directives => (($runtime_directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
661 runtime_directives_mode => $runtime_directives_mode,
662 runtime_directives_payload => $runtime_directives_payload,
663 bound_slot => $slot,
664 );
665 }
666  
667 29 ▶sub _lookup_typename_slot {
Subroutine _lookup_typename_slot: called CC=11 SCAR=32.6
668 29 my ($runtime_schema, $type_name, $result_name, $directives_mode) = @_;
669 29 my $schema_block = $runtime_schema->block_by_type_name($type_name);
670 29 ▶ if ($schema_block) {
Branch: 1 branch
BranchTrueFalseTotal
if ($schema_block) 29 0 29
671 29 ▶ for my $slot (@{ $schema_block->slots || [] }) {
Condition50%1/2
$schema_block->slots || []
l!l
290
MC/DC0%0/1
$schema_block->slots || []
$schema_block->slots
Truth table50%1/2
A
A= $schema_block->slots
Aresult
11
00
672 29 ▶ next if ($slot->field_name || q()) ne '__typename';
Branch: 1 branch
BranchTrueFalseTotal
if ($slot->field_name || "") ne "__typename" 0 29 29
Condition50%1/2
$slot->field_name || ''
l!l
290
MC/DC0%0/1
$slot->field_name || ''
$slot->field_name
Truth table50%1/2
A
A= $slot->field_name
Aresult
11
00
673 29 ▶ return GraphQL::Houtou::Runtime::Slot->new(
Branch: 1 branch
BranchTrueFalseTotal
($directives_mode || 'NONE') ne 'NONE' ? : 0 29 29
Condition50%1/2
$directives_mode || 'NONE'
l!l
290
MC/DC0%0/1
$directives_mode || 'NONE'
$directives_mode
Truth table50%1/2
A
A= $directives_mode
Aresult
11
00
674 schema_slot_key => $slot->schema_slot_key,
675 schema_slot_index => $slot->schema_slot_index,
676 field_name => '__typename',
677 result_name => $result_name,
678 return_type_name => $slot->return_type_name,
679 return_type_kind_code => $slot->return_type_kind_code,
680 resolver_shape => $slot->resolver_shape,
681 resolver_mode => $slot->resolver_mode,
682 completion_family => $slot->completion_family,
683 dispatch_family => $slot->dispatch_family,
684 has_args => 0,
685 has_directives => (($directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
686 );
687 }
688 }
689 0 ▶ return GraphQL::Houtou::Runtime::Slot->new(
Branch: 1 branch
BranchTrueFalseTotal
($directives_mode || 'NONE') ne 'NONE' ? : 0 0 0
Condition0%0/4
$type_name || ''
l!l
00
$directives_mode || 'NONE'
l!l
00
MC/DC0%0/1
$type_name || ''
$type_name
MC/DC0%0/1
$directives_mode || 'NONE'
$directives_mode
Truth table0%0/2
A
A= $type_name
Aresult
11
00
Truth table0%0/2
A
A= $directives_mode
Aresult
11
00
690 schema_slot_key => join(q(.), ($type_name || q()), '__typename'),
691 field_name => '__typename',
692 result_name => $result_name,
693 return_type_name => 'String',
694 return_type_kind_code => 1,
695 resolver_shape => 'DEFAULT',
696 resolver_mode => 'DEFAULT',
697 completion_family => 'GENERIC',
698 dispatch_family => 'GENERIC',
699 has_args => 0,
700 has_directives => (($directives_mode || 'NONE') ne 'NONE') ? 1 : 0,
701 );
702 }
703  
704 1922 ▶sub _resolve_op_for_slot {
Subroutine _resolve_op_for_slot: called CC=3 SCAR=11.1
705 1922 my ($slot) = @_;
706 1922 ▶ return 'RESOLVE_EXPLICIT' if ($slot->resolver_shape || '') eq 'EXPLICIT';
Branch: 1 branch
BranchTrueFalseTotal
if ($slot->resolver_shape || "") eq "EXPLICIT" 1462 460 1922
Condition50%1/2
$slot->resolver_shape || ''
l!l
19220
MC/DC0%0/1
$slot->resolver_shape || ''
$slot->resolver_shape
Truth table50%1/2
A
A= $slot->resolver_shape
Aresult
11
00
707 460 return 'RESOLVE_DEFAULT';
708 }
709  
710 405 ▶sub _lower_variable_defs {
Subroutine _lower_variable_defs: called CC=7 SCAR=19.6
711 405 my ($variables) = @_;
712 405 ▶ return {} if !$variables || !keys %$variables;
Branch: 1 branch
BranchTrueFalseTotal
unless $variables and keys %$variables 286 119 405
Condition66%2/3
$variables and keys %$variables
!ll&&!rl&&r
2860119
MC/DC50%1/2
$variables and keys %$variables
$variables keys %$variables
Truth table66%2/3
A and B
A= $variablesB= keys %$variables
ABresult
0X0
100
111
713 119 my %defs;
714 119 for my $name (sort keys %$variables) {
715 151 ▶ my $def = $variables->{$name} || {};
Condition50%1/2
$variables->{$name} || {}
l!l
1510
MC/DC0%0/1
$variables->{$name} || {}
$variables->{$name}
Truth table50%1/2
A
A= $variables->{$name}
Aresult
11
00
716 $defs{$name} = {
717 type => { type => _clone_argument_value($def->{type}) },
718 has_default => exists $def->{default_value} ? 1 : 0,
719 default_value => exists $def->{default_value}
720 ? _materialize_static_value($def->{default_value})
721 151 ▶ : undef,
Branch: 2 branches
BranchTrueFalseTotal
exists $def->{'default_value'} ? : 12 139 151
exists $def->{'default_value'} ? : 12 139 151
722 };
723 }
724 119 return \%defs;
725 }
726  
727 3902 ▶sub _lower_directives {
Subroutine _lower_directives: called CC=4 SCAR=13.9
728 3902 my ($directives) = @_;
729 3902 ▶ return ('NONE', undef) if !$directives || !@$directives;
Branch: 1 branch
BranchTrueFalseTotal
unless $directives and @$directives 3883 19 3902
Condition66%2/3
$directives and @$directives
!ll&&!rl&&r
3883019
MC/DC50%1/2
$directives and @$directives
$directives @$directives
Truth table66%2/3
A and B
A= $directivesB= @$directives
ABresult
0X0
100
111
730 19 ▶ return ('STATIC', _materialize_static_value($directives))
Branch: 1 branch
BranchTrueFalseTotal
unless _contains_variable_refs($directives) 2 17 19
731 if !_contains_variable_refs($directives);
732 17 return ('DYNAMIC', _clone_argument_value($directives));
733 }
734  
735 2032 ▶sub _partition_runtime_guards {
Subroutine _partition_runtime_guards: called CC=15 SCAR=30.2
736 2032 my ($directives) = @_;
737 2032 ▶ return (1, [], []) if !$directives || !@$directives;
Branch: 1 branch
BranchTrueFalseTotal
unless $directives and @$directives 2011 21 2032
Condition66%2/3
$directives and @$directives
!ll&&!rl&&r
2011021
MC/DC50%1/2
$directives and @$directives
$directives @$directives
Truth table66%2/3
A and B
A= $directivesB= @$directives
ABresult
0X0
100
111
738 21 my @dynamic;
739 my @runtime_directives;
740 21 for my $directive (@$directives) {
741 22 ▶ next if !$directive;
Branch: 1 branch
BranchTrueFalseTotal
unless $directive 0 22 22
742 22 ▶ my $name = $directive->{name} || '';
Condition50%1/2
$directive->{'name'} || ''
l!l
220
MC/DC0%0/1
$directive->{'name'} || ''
$directive->{'name'}
Truth table50%1/2
A
A= $directive->{'name'}
Aresult
11
00
743 22 ▶ if ($name ne 'include' && $name ne 'skip') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name ne "include" and $name ne "skip") 5 17 22
Condition100%3/3
$name ne "include" and $name ne "skip"
!ll&&!rl&&r
895
MC/DC100%2/2
$name ne "include" and $name ne "skip"
$name ne "include" $name ne "skip"
Truth table100%3/3
A and B
A= $name ne "include"B= $name ne "skip"
ABresult
0X0
100
111
744 push @runtime_directives, {
745 name => $name,
746 5 ▶ arguments => _clone_argument_value($directive->{arguments} || {}),
Condition100%2/2
$directive->{'arguments'} || {}
l!l
23
MC/DC100%1/1
$directive->{'arguments'} || {}
$directive->{'arguments'}
Truth table100%2/2
A
A= $directive->{'arguments'}
Aresult
11
00
747 };
748 5 next;
749 }
750 17 ▶ my $arguments = $directive->{arguments} || {};
Condition50%1/2
$directive->{'arguments'} || {}
l!l
170
MC/DC0%0/1
$directive->{'arguments'} || {}
$directive->{'arguments'}
Truth table50%1/2
A
A= $directive->{'arguments'}
Aresult
11
00
751 17 my $if_value = $arguments->{if};
752 17 ▶ if (!_contains_variable_refs($if_value)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (_contains_variable_refs($if_value)) 2 15 17
753 2 my $bool = _directive_truthy(_materialize_static_value($if_value));
754 2 ▶ return (0, [], []) if $name eq 'skip' && $bool;
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "skip" and $bool 2 0 2
Condition33%1/3
$name eq "skip" and $bool
!ll&&!rl&&r
002
MC/DC0%0/2
$name eq "skip" and $bool
$name eq "skip" $bool
Truth table33%1/3
A and B
A= $name eq "skip"B= $bool
ABresult
0X0
100
111
755 0 ▶ return (0, [], []) if $name eq 'include' && !$bool;
Branch: 1 branch
BranchTrueFalseTotal
if $name eq "include" and not $bool 0 0 0
Condition0%0/3
$name eq "include" and not $bool
!ll&&!rl&&r
000
MC/DC0%0/2
$name eq "include" and not $bool
$name eq "include" not $bool
Truth table0%0/3
A and not(B)
A= $name eq "include"B= not $bool
ABresult
0X0
100
111
756 0 next;
757 }
758 15 push @dynamic, {
759 name => $name,
760 arguments => _clone_argument_value($arguments),
761 };
762 }
763 19 return (1, \@dynamic, \@runtime_directives);
764 }
765  
766 2 ▶sub _directive_truthy {
Subroutine _directive_truthy: called CC=2 SCAR=7.2
767 2 my ($value) = @_;
768 2 ▶ return $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 2 0 2
769 }
770  
771 1922 ▶sub _lower_arguments {
Subroutine _lower_arguments: called CC=4 SCAR=13.9
772 1922 my ($arguments) = @_;
773 1922 ▶ return ('NONE', undef) if !$arguments || !keys %$arguments;
Branch: 1 branch
BranchTrueFalseTotal
unless $arguments and keys %$arguments 1672 250 1922
Condition66%2/3
$arguments and keys %$arguments
!ll&&!rl&&r
16720250
MC/DC50%1/2
$arguments and keys %$arguments
$arguments keys %$arguments
Truth table66%2/3
A and B
A= $argumentsB= keys %$arguments
ABresult
0X0
100
111
774 250 ▶ return ('STATIC', _materialize_static_value($arguments))
Branch: 1 branch
BranchTrueFalseTotal
unless _contains_variable_refs($arguments) 114 136 250
775 if !_contains_variable_refs($arguments);
776 136 return ('DYNAMIC', _clone_argument_value($arguments));
777 }
778  
779 628 ▶sub _contains_variable_refs {
Subroutine _contains_variable_refs: called CC=10 SCAR=23.0
780 628 my ($value) = @_;
781 628 my $ref = ref($value);
782 628 ▶ return 0 if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 108 520 628
783 520 ▶ return 1 if $ref eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "SCALAR" 168 352 520
784 # A REF (\\'NAME') is the parser's enum-literal marker, not a variable:
785 # recursing into it would misread the inner scalar ref as a variable and
786 # send the argument down the dynamic path, where 'NAME' gets looked up
787 # as a (missing) variable and the argument silently becomes undef.
788 352 ▶ return 0 if $ref eq 'REF';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "REF" 4 348 352
789 348 ▶ if ($ref eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref eq "ARRAY") 21 327 348
790 21 for my $item (@$value) {
791 25 ▶ return 1 if _contains_variable_refs($item);
Branch: 1 branch
BranchTrueFalseTotal
if _contains_variable_refs($item) 17 8 25
792 }
793 4 return 0;
794 }
795 327 ▶ if ($ref eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref eq "HASH") 303 24 327
796 303 for my $key (keys %$value) {
797 317 ▶ return 1 if _contains_variable_refs($value->{$key});
Branch: 1 branch
BranchTrueFalseTotal
if _contains_variable_refs($value->{$key}) 172 145 317
798 }
799 131 return 0;
800 }
801 24 return 0;
802 }
803  
804 276 ▶sub _materialize_static_value {
Subroutine _materialize_static_value: called CC=8 SCAR=21.4
805 276 my ($value) = @_;
806 276 my $ref = ref($value);
807 276 ▶ return $value if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 109 167 276
808 167 ▶ return $value ? 1 : 0 if is_bool($value);
Branch: 2 branches
BranchTrueFalseTotal
if is_bool($value) 28 139 167
$value ? : 25 3 28
809 139 ▶ return $$$value if $ref eq 'REF';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "REF" 4 135 139
810 135 ▶ return [ map { _materialize_static_value($_) } @$value ] if $ref eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "ARRAY" 4 131 135
811 131 ▶ return { map { $_ => _materialize_static_value($value->{$_}) } keys %$value } if $ref eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "HASH" 131 0 131
812 0 ▶ die "Unsupported static argument value ref '$ref' in runtime compiler.\n"
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "SCALAR" 0 0 0
813 if $ref eq 'SCALAR';
814 0 return $value;
815 }
816  
817 1311 ▶sub _clone_argument_value {
Subroutine _clone_argument_value: called CC=6 SCAR=18.1
818 1311 my ($value) = @_;
819 1311 my $ref = ref($value);
820 1311 ▶ return $value if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 361 950 1311
821 950 ▶ return $value if $ref eq 'REF' || $ref eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "REF" or $ref eq "SCALAR" 322 628 950
Condition66%2/3
$ref eq "REF" or $ref eq "SCALAR"
l!l&&r!l&&!r
0322628
MC/DC50%1/2
$ref eq "REF" or $ref eq "SCALAR"
$ref eq "REF" $ref eq "SCALAR"
Truth table66%2/3
A or B
A= $ref eq "REF"B= $ref eq "SCALAR"
ABresult
1X1
011
000
822 628 ▶ return [ map { _clone_argument_value($_) } @$value ] if $ref eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "ARRAY" 96 532 628
823 532 ▶ return { map { $_ => _clone_argument_value($value->{$_}) } keys %$value } if $ref eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "HASH" 532 0 532
824 0 return $value;
825 }
826  
827 3871 ▶sub _intern_compact_payload {
Subroutine _intern_compact_payload: called CC=3 SCAR=11.0
828 3871 my ($payloads, $index, $payload) = @_;
829 3871 ▶ return undef if !_payload_present($payload);
Branch: 1 branch
BranchTrueFalseTotal
unless _payload_present($payload) 3606 265 3871
830 265 my $key = _compact_payload_key($payload);
831 265 ▶ return $index->{$key} if exists $index->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $index->{$key} 15 250 265
832 250 my $slot = @$payloads;
833 250 push @$payloads, _clone_argument_value($payload);
834 250 $index->{$key} = $slot;
835 250 return $slot;
836 }
837  
838 3871 ▶sub _payload_present {
Subroutine _payload_present: called CC=7 SCAR=20.7
839 3871 my ($value) = @_;
840 3871 ▶ return 0 if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 3606 265 3871
841 265 my $ref = ref($value);
842 265 ▶ return 1 if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 0 265 265
843 265 ▶ return scalar(@$value) ? 1 : 0 if $ref eq 'ARRAY';
Branch: 2 branches
BranchTrueFalseTotal
if $ref eq "ARRAY" 15 250 265
scalar @$value ? : 15 0 15
844 250 ▶ return scalar(keys %$value) ? 1 : 0 if $ref eq 'HASH';
Branch: 2 branches
BranchTrueFalseTotal
if $ref eq "HASH" 250 0 250
scalar keys %$value ? : 250 0 250
845 0 return 1;
846 }
847  
848 604 ▶sub _compact_payload_key {
Subroutine _compact_payload_key: called CC=7 SCAR=19.6
849 604 my ($value) = @_;
850 604 my $ref = ref($value);
851 604 ▶ return '!undef' if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 1 603 604
852 603 ▶ return "S:$value" if !$ref;
Branch: 1 branch
BranchTrueFalseTotal
unless $ref 139 464 603
853 464 ▶ return "R:${$value}" if $ref eq 'REF' || $ref eq 'SCALAR';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "REF" or $ref eq "SCALAR" 154 310 464
Condition66%2/3
$ref eq "REF" or $ref eq "SCALAR"
l!l&&r!l&&!r
0154310
MC/DC50%1/2
$ref eq "REF" or $ref eq "SCALAR"
$ref eq "REF" $ref eq "SCALAR"
Truth table66%2/3
A or B
A= $ref eq "REF"B= $ref eq "SCALAR"
ABresult
1X1
011
000
854 310 ▶ return 'A:[' . join(',', map { _compact_payload_key($_) } @$value) . ']' if $ref eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "ARRAY" 17 293 310
855 293 ▶ return 'H:{' . join(',', map { $_ . '=>' . _compact_payload_key($value->{$_}) } sort keys %$value) . '}' if $ref eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if $ref eq "HASH" 293 0 293
856 0 return "$ref:$value";
857 }
858  
859 1922 ▶sub _complete_op_for_slot {
Subroutine _complete_op_for_slot: called CC=5 SCAR=16.1
860 1922 my ($slot) = @_;
861 1922 ▶ my $family = $slot->completion_family || 'GENERIC';
Condition50%1/2
$slot->completion_family || 'GENERIC'
l!l
19220
MC/DC0%0/1
$slot->completion_family || 'GENERIC'
$slot->completion_family
Truth table50%1/2
A
A= $slot->completion_family
Aresult
11
00
862 1922 ▶ return 'COMPLETE_OBJECT' if $family eq 'OBJECT';
Branch: 1 branch
BranchTrueFalseTotal
if $family eq "OBJECT" 381 1541 1922
863 1541 ▶ return 'COMPLETE_LIST' if $family eq 'LIST';
Branch: 1 branch
BranchTrueFalseTotal
if $family eq "LIST" 193 1348 1541
864 1348 ▶ return 'COMPLETE_ABSTRACT' if $family eq 'ABSTRACT';
Branch: 1 branch
BranchTrueFalseTotal
if $family eq "ABSTRACT" 37 1311 1348
865 1311 return 'COMPLETE_GENERIC';
866 }
867  
868 62 1;
« blib/lib/GraphQL/Houtou/Type/Object.pm ↑ Summary blib/lib/GraphQL/Houtou/Runtime/DirectiveRuntime.pm »