« blib/lib/GraphQL/Houtou/Runtime/OperationCompiler.pm
↑ Summary
blib/lib/GraphQL/Houtou/Type/Interface.pm »
| 1 | package GraphQL::Houtou::Runtime::DirectiveRuntime; | ||||||||||||||||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 62 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 62 | ▶ | use JSON::MaybeXS qw(is_bool); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 62 | ▶ | use Scalar::Util qw(blessed refaddr reftype); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 62 | ▶ | use overload (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 62 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||
| 13 | has_runtime_directives | ||||||||||||||||||||||||||||||||||||||||||
| 14 | apply_runtime_directives | ||||||||||||||||||||||||||||||||||||||||||
| 15 | slot_needs_runtime_wrapper | ||||||||||||||||||||||||||||||||||||||||||
| 16 | wrap_field_resolver | ||||||||||||||||||||||||||||||||||||||||||
| 17 | materialize_runtime_directives | ||||||||||||||||||||||||||||||||||||||||||
| 18 | materialize_program_runtime_directives | ||||||||||||||||||||||||||||||||||||||||||
| 19 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | 62 | my %RUNTIME_DIRECTIVE_ENTRIES_CACHE; | |||||||||||||||||||||||||||||||||||||||||
| 22 | 62 | our $CURRENT_DIRECTIVE_FRAME; | |||||||||||||||||||||||||||||||||||||||||
| 23 | 62 | our $NEXT_DIRECTIVE_VALUE; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 62 | our $CURRENT_SINGLE_DIRECTIVE_VALUE; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | ▶ | our $NEXT_SINGLE_DIRECTIVE_VALUE = sub { return $CURRENT_SINGLE_DIRECTIVE_VALUE }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | $NEXT_DIRECTIVE_VALUE = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | my $frame = $CURRENT_DIRECTIVE_FRAME || return undef; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$GraphQL::Houtou::Runtime::DirectiveRuntime::CURRENT_DIRECTIVE_FRAME || (return undef)
MC/DC0%0/1
$GraphQL::Houtou::Runtime::DirectiveRuntime::CURRENT_DIRECTIVE_FRAME || (return undef)
$GraphQL::Houtou::Runtime::DirectiveRuntime::CURRENT_DIRECTIVE_FRAME
Truth table50%1/2
A
A= $GraphQL::Houtou::Runtime::DirectiveRuntime::CURRENT_DIRECTIVE_FRAME
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | my $index = $frame->{index}++; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | return $frame->{final_cb}->() if $index >= @{ $frame->{entries} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 2 | my ($mode, $code, $directive_args, $directive) = @{ $frame->{entries}[$index] }; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | if ($mode eq 'transform') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | return $code->( | ||||||||||||||||||||||||||||||||||||||||||
| 34 | scalar($NEXT_DIRECTIVE_VALUE->()), | ||||||||||||||||||||||||||||||||||||||||||
| 35 | $frame->{source}, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | $frame->{field_args}, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | $frame->{context}, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | $frame->{info}, | ||||||||||||||||||||||||||||||||||||||||||
| 39 | $frame->{return_type}, | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 2 | $directive_args, | |||||||||||||||||||||||||||||||||||||||||
| 41 | $directive, | ||||||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||||||||||||||||
| 44 | return $code->( | ||||||||||||||||||||||||||||||||||||||||||
| 45 | $NEXT_DIRECTIVE_VALUE, | ||||||||||||||||||||||||||||||||||||||||||
| 46 | $frame->{source}, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | $frame->{field_args}, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | $frame->{context}, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | $frame->{info}, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | $frame->{return_type}, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | $directive_args, | |||||||||||||||||||||||||||||||||||||||||
| 52 | $directive, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 54 | 62 | }; | |||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | sub has_runtime_directives { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_runtime_directives: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | my ($schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | return 0 if !$schema; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | ▶ | for my $directive (@{ $schema->directives || [] }) { | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$schema->directives || []
MC/DC0%0/1
$schema->directives || []
$schema->directives
Truth table0%0/2
A
A= $schema->directives
| |||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | ▶ | next if !$directive; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | next if !$directive->can('has_runtime_hook') || !$directive->has_runtime_hook; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$directive->can("has_runtime_hook") and $directive->has_runtime_hook
MC/DC0%0/2
$directive->can("has_runtime_hook") and $directive->has_runtime_hook
$directive->can("has_runtime_hook")
$directive->has_runtime_hook
Truth table0%0/3
A and B
A= $directive->can("has_runtime_hook")B= $directive->has_runtime_hook
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | return 1 if $directive->has_executable_location; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 16947 | ▶ | sub slot_needs_runtime_wrapper { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
slot_needs_runtime_wrapper: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 16947 | my (%args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 16947 | ▶ | my $field = $args{field} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'field'} || {}
MC/DC0%0/1
$args{'field'} || {}
$args{'field'}
Truth table50%1/2
A
A= $args{'field'}
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 16947 | ▶ | return 0 if ref($field) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 16947 | ▶ | return @{ $field->{directives} || [] } ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$field->{'directives'} || []
MC/DC100%1/1
$field->{'directives'} || []
$field->{'directives'}
Truth table100%2/2
A
A= $field->{'directives'}
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 488 | ▶ | sub wrap_field_resolver { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
wrap_field_resolver: called CC=7 SCAR=19.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 75 | 488 | my (%args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 76 | 488 | my $schema = $args{schema}; | |||||||||||||||||||||||||||||||||||||||||
| 77 | 488 | my $field_name = $args{field_name}; | |||||||||||||||||||||||||||||||||||||||||
| 78 | 488 | ▶ | my $field = $args{field} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$args{'field'} || {}
MC/DC0%0/1
$args{'field'} || {}
$args{'field'}
Truth table50%1/2
A
A= $args{'field'}
| |||||||||||||||||||||||||||||||||||||||||||
| 79 | 488 | my $base_resolver = $args{resolver}; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 488 | ▶ | my $is_typename = ($field_name || q()) eq '__typename' ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$field_name || ''
MC/DC0%0/1
$field_name || ''
$field_name
Truth table50%1/2
A
A= $field_name
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 488 | ▶ | my $directive_defs = $schema ? ($schema->name2directive || {}) : {}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$schema->name2directive or {}
MC/DC0%0/1
$schema->name2directive or {}
$schema->name2directive
Truth table50%1/2
A
A= $schema->name2directive
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 488 | ▶ | my $schema_directives = $field->{directives} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$field->{'directives'} || []
MC/DC100%1/1
$field->{'directives'} || []
$field->{'directives'}
Truth table100%2/2
A
A= $field->{'directives'}
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 488 | my $compiled_schema_directives = _compile_directive_entries($directive_defs, $schema_directives); | |||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | 36 | ▶ | return sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 87 | 36 | my ($source, $field_args, $context, $info, $return_type) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 88 | 36 | ▶ | my $final_cb = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 89 | 36 | ▶ | return _default_field_resolver( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | $source, $field_name, $field_args, $context, $info, | ||||||||||||||||||||||||||||||||||||||||||
| 91 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 92 | if !$base_resolver; | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 34 | return $base_resolver->($source, $field_args, $context, $info, $return_type); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 36 | }; | |||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | 36 | ▶ | return $final_cb->() if !@$compiled_schema_directives && !$is_typename; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@$compiled_schema_directives or $is_typename
MC/DC50%1/2
@$compiled_schema_directives or $is_typename
@$compiled_schema_directives
$is_typename
Truth table66%2/3
A or B
A= @$compiled_schema_directivesB= $is_typename
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 2 | return _apply_compiled_directive_entries( | |||||||||||||||||||||||||||||||||||||||||
| 99 | $compiled_schema_directives, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | $source, | ||||||||||||||||||||||||||||||||||||||||||
| 101 | $field_args, | ||||||||||||||||||||||||||||||||||||||||||
| 102 | $context, | ||||||||||||||||||||||||||||||||||||||||||
| 103 | $info, | ||||||||||||||||||||||||||||||||||||||||||
| 104 | $return_type, | ||||||||||||||||||||||||||||||||||||||||||
| 105 | $final_cb, | ||||||||||||||||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 107 | 488 | }; | |||||||||||||||||||||||||||||||||||||||||
| 108 | } | ||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 5 | ▶ | sub apply_runtime_directives { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
apply_runtime_directives: called CC=4 SCAR=14.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 5 | my ($runtime_schema, $source, $field_args, $context, $info, $return_type, $resolved_value) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 5 | my $schema = _resolve_schema($runtime_schema); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 5 | ▶ | return $resolved_value if !$schema; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 5 | my $runtime_directives = _runtime_directives_from_info($info); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 5 | ▶ | return $resolved_value if !@$runtime_directives; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 5 | my $compiled_runtime_directives = _compiled_runtime_directive_entries($schema, $runtime_directives); | |||||||||||||||||||||||||||||||||||||||||
| 118 | 5 | ▶ | return $resolved_value if !@$compiled_runtime_directives; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | return _apply_compiled_directive_entries( | ||||||||||||||||||||||||||||||||||||||||||
| 121 | $compiled_runtime_directives, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | $source, | ||||||||||||||||||||||||||||||||||||||||||
| 123 | $field_args, | ||||||||||||||||||||||||||||||||||||||||||
| 124 | $context, | ||||||||||||||||||||||||||||||||||||||||||
| 125 | $info, | ||||||||||||||||||||||||||||||||||||||||||
| 126 | $return_type, | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 5 | ▶ | sub { $resolved_value }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 5 | ); | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 5 | ▶ | sub _runtime_directives_from_info { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_runtime_directives_from_info: called CC=7 SCAR=31.1
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 5 | my ($info) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 5 | ▶ | return [] if !$info; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 5 | ▶ | my $runtime_directives = $info->{directives} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$info->{'directives'} || []
MC/DC0%0/1
$info->{'directives'} || []
$info->{'directives'}
Truth table50%1/2
A
A= $info->{'directives'}
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 5 | ▶ | return $runtime_directives if @$runtime_directives; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $program = $info->{operation}; | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my $block_index = $info->{block_index}; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $op_index = $info->{op_index}; | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | ▶ | return [] if !defined $block_index || !defined $op_index; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $block_index and defined $op_index
MC/DC0%0/2
defined $block_index and defined $op_index
defined $block_index
defined $op_index
Truth table0%0/3
A and B
A= defined $block_indexB= defined $op_index
| |||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | return materialize_program_runtime_directives( | ||||||||||||||||||||||||||||||||||||||||||
| 144 | $program, | ||||||||||||||||||||||||||||||||||||||||||
| 145 | $block_index, | ||||||||||||||||||||||||||||||||||||||||||
| 146 | $op_index, | ||||||||||||||||||||||||||||||||||||||||||
| 147 | $info->{variable_values} || {}, | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$info->{'variable_values'} || {}
MC/DC0%0/1
$info->{'variable_values'} || {}
$info->{'variable_values'}
Truth table0%0/2
A
A= $info->{'variable_values'}
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 4 | ▶ | sub materialize_runtime_directives { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
materialize_runtime_directives: called CC=3 SCAR=11.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 4 | my ($payload, $variables) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 4 | ▶ | return [] if !$payload; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 154 | 4 | ▶ | return _materialize_value($payload, $variables || {}); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$variables || {}
MC/DC0%0/1
$variables || {}
$variables
Truth table50%1/2
A
A= $variables
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub materialize_program_runtime_directives { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
materialize_program_runtime_directives: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my ($program, $block_index, $op_index, $variables) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | return [] if !defined $block_index || !defined $op_index; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $block_index and defined $op_index
MC/DC0%0/2
defined $block_index and defined $op_index
defined $block_index
defined $op_index
Truth table0%0/3
A and B
A= defined $block_indexB= defined $op_index
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $descriptor = _program_descriptor($program); | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | return [] if !$descriptor; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | my $blocks = $descriptor->{blocks_compact} || $descriptor->{blocks} || []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/5
$descriptor->{'blocks_compact'} || $descriptor->{'blocks'} || []
$descriptor->{"blocks_compact"} or $descriptor->{"blocks"}
MC/DC0%0/2
$descriptor->{'blocks_compact'} || $descriptor->{'blocks'} || []
$descriptor->{"blocks_compact"}
$descriptor->{"blocks"}
Truth table0%0/3
A or B
A= $descriptor->{"blocks_compact"}B= $descriptor->{"blocks"}
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | my $block = $blocks->[$block_index] || return []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$blocks->[$block_index] || (return [])
MC/DC0%0/1
$blocks->[$block_index] || (return [])
$blocks->[$block_index]
Truth table0%0/2
A
A= $blocks->[$block_index]
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | ▶ | my $ops = ref($block) eq 'ARRAY' ? ($block->[4] || []) : ($block->{ops} || []); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/4
$block->[4] or []
$block->{"ops"} or []
MC/DC0%0/1
$block->[4] or []
$block->[4]
MC/DC0%0/1
$block->{"ops"} or []
$block->{"ops"}
Truth table0%0/2
A
A= $block->[4]
Truth table0%0/2
A
A= $block->{"ops"}
| |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | ▶ | my $op = $ops->[$op_index] || return []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$ops->[$op_index] || (return [])
MC/DC0%0/1
$ops->[$op_index] || (return [])
$ops->[$op_index]
Truth table0%0/2
A
A= $ops->[$op_index]
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if (ref($op) eq 'ARRAY') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ▶ | return [] if !$op->[20]; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | return materialize_runtime_directives($op->[19], $variables); | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | return [] if !$op->{has_runtime_directives}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return materialize_runtime_directives($op->{runtime_directives_payload}, $variables); | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 2 | ▶ | sub _default_field_resolver { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_default_field_resolver: called CC=14 SCAR=41.4
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 2 | my ($source, $field_name, $args, $context, $info) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 2 | ▶ | return undef if !defined $field_name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 2 | ▶ | if ($field_name eq '__typename') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | ▶ | my $parent_type = $info ? $info->{parent_type} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 0 | ▶ | return $parent_type && $parent_type->can('name') ? $parent_type->name : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$parent_type and $parent_type->can("name")
MC/DC0%0/2
$parent_type and $parent_type->can("name")
$parent_type
$parent_type->can("name")
Truth table0%0/3
A and B
A= $parent_typeB= $parent_type->can("name")
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | ▶ | if (blessed($source) && $source->can($field_name)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($source) and $source->can($field_name)
MC/DC0%0/2
builtin::blessed($source) and $source->can($field_name)
builtin::blessed($source)
$source->can($field_name)
Truth table33%1/3
A and B
A= builtin::blessed($source)B= $source->can($field_name)
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | return $source->$field_name($args, $context, $info); | |||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 2 | ▶ | if ($source && (reftype($source) || '') eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
$source and (builtin::reftype($source) || "") eq "HASH"
builtin::reftype($source) || ''
MC/DC0%0/2
$source and (builtin::reftype($source) || "") eq "HASH"
$source
builtin::reftype($source)
Truth table33%1/3
A and B
A= $sourceB= builtin::reftype($source)
| |||||||||||||||||||||||||||||||||||||||||||
| 190 | 2 | my $value = $source->{$field_name}; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | return $value->($args, $context, $info) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
ref $value eq "CODE" or builtin::blessed($value) and overload::Method($value, "&{}")
builtin::blessed($value) and overload::Method($value, "&{}")
MC/DC0%0/3
ref $value eq "CODE" or builtin::blessed($value) and overload::Method($value, "&{}")
ref $value eq "CODE"
builtin::blessed($value)
overload::Method($value, "&{}")
Truth table25%1/4
A or B and C
A= ref $value eq "CODE"B= builtin::blessed($value)C= overload::Method($value, "&{}")
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | if ref($value) eq 'CODE' | ||||||||||||||||||||||||||||||||||||||||||
| 193 | || (blessed($value) && overload::Method($value, '&{}')); | ||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||
| 199 | 1 | ▶ | sub _resolve_default_property_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_default_property_value: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 200 | 1 | my ($value, $args, $context, $info) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 1 | ▶ | return $value->($args, $context, $info) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($value) and overload::Method($value, "&{}")
MC/DC0%0/2
builtin::blessed($value) and overload::Method($value, "&{}")
builtin::blessed($value)
overload::Method($value, "&{}")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= overload::Method($value, "&{}")
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | if blessed($value) && overload::Method($value, '&{}'); | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | ▶ | sub _program_descriptor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_program_descriptor: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my ($program) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | return if !$program; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | if (ref($program) && eval { $program->isa('GraphQL::Houtou::Runtime::NativeProgram') }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $program and eval {
do {
$program->isa("GraphQL::Houtou::Runtime::NativeProgram")
}
}
MC/DC0%0/2
ref $program and eval {
do {
$program->isa("GraphQL::Houtou::Runtime::NativeProgram")
}
}
ref $program
eval {
do {
$program->isa("GraphQL::Houtou::Runtime::NativeProgram")
}
}
Truth table0%0/3
A and B
A= ref $programB= eval {
do {
$program->isa("GraphQL::Houtou::Runtime::NativeProgram")
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | GraphQL::Houtou::_bootstrap_xs(); | |||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | return GraphQL::Houtou::XS::VM::native_program_descriptor_xs($program); | |||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | return $program if ref($program) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | 5 | ▶ | sub _resolve_schema { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolve_schema: called CC=7 SCAR=24.5
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | 5 | my ($runtime_schema) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 5 | ▶ | return if !$runtime_schema; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 5 | ▶ | return $runtime_schema if ref($runtime_schema) && eval { $runtime_schema->can('name2directive') }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $runtime_schema and eval {
do {
$runtime_schema->can("name2directive")
}
}
MC/DC0%0/2
ref $runtime_schema and eval {
do {
$runtime_schema->can("name2directive")
}
}
ref $runtime_schema
eval {
do {
$runtime_schema->can("name2directive")
}
}
Truth table33%1/3
A and B
A= ref $runtime_schemaB= eval {
do {
$runtime_schema->can("name2directive")
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | return $runtime_schema->{schema} | ||||||||||||||||||||||||||||||||||||||||||
| 222 | if ref($runtime_schema) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||
| 223 | && ref($runtime_schema->{schema}) | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 5 | ▶ | && eval { $runtime_schema->{schema}->can('name2directive') }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
ref $runtime_schema eq "HASH" and ref $runtime_schema->{"schema"} and eval {
do {
$runtime_schema->{"schema"}->can("name2directive")
}
}
ref $runtime_schema eq "HASH" and ref $runtime_schema->{"schema"}
MC/DC0%0/3
ref $runtime_schema eq "HASH" and ref $runtime_schema->{"schema"} and eval {
do {
$runtime_schema->{"schema"}->can("name2directive")
}
}
ref $runtime_schema eq "HASH"
ref $runtime_schema->{"schema"}
eval {
do {
$runtime_schema->{"schema"}->can("name2directive")
}
}
Truth table25%1/4
A and B and C
A= ref $runtime_schema eq "HASH"B= ref $runtime_schema->{"schema"}C= eval {
do {
$runtime_schema->{"schema"}->can("name2directive")
}
}
| |||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 5 | ▶ | sub _compiled_runtime_directive_entries { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compiled_runtime_directive_entries: called CC=10 SCAR=27.8
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 5 | my ($schema, $runtime_directives) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 230 | 5 | ▶ | return [] if !$schema || !$runtime_directives || !@$runtime_directives; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$schema and $runtime_directives and @$runtime_directives
$schema and $runtime_directives
MC/DC0%0/3
$schema and $runtime_directives and @$runtime_directives
$schema
$runtime_directives
@$runtime_directives
Truth table25%1/4
A and B and C
A= $schemaB= $runtime_directivesC= @$runtime_directives
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 5 | my $schema_key = refaddr($schema); | |||||||||||||||||||||||||||||||||||||||||
| 233 | 5 | my $directives_key = refaddr($runtime_directives); | |||||||||||||||||||||||||||||||||||||||||
| 234 | 5 | ▶ | if ($schema_key && $directives_key) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$schema_key and $directives_key
MC/DC0%0/2
$schema_key and $directives_key
$schema_key
$directives_key
Truth table33%1/3
A and B
A= $schema_keyB= $directives_key
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 5 | my $cached = $RUNTIME_DIRECTIVE_ENTRIES_CACHE{$schema_key}{$directives_key}; | |||||||||||||||||||||||||||||||||||||||||
| 236 | 5 | ▶ | return $cached if $cached; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 5 | ▶ | my $compiled = _compile_directive_entries($schema->name2directive || {}, $runtime_directives); | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$schema->name2directive || {}
MC/DC0%0/1
$schema->name2directive || {}
$schema->name2directive
Truth table50%1/2
A
A= $schema->name2directive
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 5 | ▶ | if ($schema_key && $directives_key) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$schema_key and $directives_key
MC/DC0%0/2
$schema_key and $directives_key
$schema_key
$directives_key
Truth table33%1/3
A and B
A= $schema_keyB= $directives_key
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 5 | $RUNTIME_DIRECTIVE_ENTRIES_CACHE{$schema_key}{$directives_key} = $compiled; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 5 | return $compiled; | |||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | 493 | ▶ | sub _compile_directive_entries { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_compile_directive_entries: called CC=13 SCAR=28.3
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 493 | my ($directive_defs, $instances) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 493 | ▶ | return [] if !$instances || !@$instances; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$instances and @$instances
MC/DC50%1/2
$instances and @$instances
$instances
@$instances
Truth table66%2/3
A and B
A= $instancesB= @$instances
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 7 | my @entries; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 7 | for my $instance (@$instances) { | |||||||||||||||||||||||||||||||||||||||||
| 252 | 8 | ▶ | next if !$instance || ref($instance) ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $instance or ref $instance ne "HASH"
MC/DC0%0/2
not $instance or ref $instance ne "HASH"
not $instance
ref $instance ne "HASH"
Truth table33%1/3
not(A) or B
A= not $instanceB= ref $instance ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 8 | ▶ | my $name = $instance->{name} || next; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$instance->{'name'} || (next)
MC/DC0%0/1
$instance->{'name'} || (next)
$instance->{'name'}
Truth table50%1/2
A
A= $instance->{'name'}
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 8 | ▶ | my $directive = $directive_defs->{$name} || next; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$directive_defs->{$name} || (next)
MC/DC0%0/1
$directive_defs->{$name} || (next)
$directive_defs->{$name}
Truth table50%1/2
A
A= $directive_defs->{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 255 | 8 | my ($mode, $code); | |||||||||||||||||||||||||||||||||||||||||
| 256 | 8 | ▶ | if ($directive->can('apply_field_result') && $directive->apply_field_result) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$directive->can("apply_field_result") and $directive->apply_field_result
MC/DC50%1/2
$directive->can("apply_field_result") and $directive->apply_field_result
$directive->can("apply_field_result")
$directive->apply_field_result
Truth table66%2/3
A and B
A= $directive->can("apply_field_result")B= $directive->apply_field_result
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 5 | $mode = 'transform'; | |||||||||||||||||||||||||||||||||||||||||
| 258 | 5 | $code = $directive->apply_field_result; | |||||||||||||||||||||||||||||||||||||||||
| 259 | ▶ | } elsif ($directive->can('resolve_field') && $directive->resolve_field) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$directive->can("resolve_field") and $directive->resolve_field
MC/DC0%0/2
$directive->can("resolve_field") and $directive->resolve_field
$directive->can("resolve_field")
$directive->resolve_field
Truth table33%1/3
A and B
A= $directive->can("resolve_field")B= $directive->resolve_field
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 3 | $mode = 'middleware'; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 3 | $code = $directive->resolve_field; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||||||||||||||||
| 265 | push @entries, [ | ||||||||||||||||||||||||||||||||||||||||||
| 266 | $mode, | ||||||||||||||||||||||||||||||||||||||||||
| 267 | $code, | ||||||||||||||||||||||||||||||||||||||||||
| 268 | 8 | ▶ | ($instance->{arguments} || {}), | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$instance->{'arguments'} || {}
MC/DC0%0/1
$instance->{'arguments'} || {}
$instance->{'arguments'}
Truth table50%1/2
A
A= $instance->{'arguments'}
| |||||||||||||||||||||||||||||||||||||||||||
| 269 | $directive, | ||||||||||||||||||||||||||||||||||||||||||
| 270 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 7 | return \@entries; | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 7 | ▶ | sub _apply_compiled_directive_entries { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_compiled_directive_entries: called CC=5 SCAR=16.3
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 7 | my ($entries, $source, $field_args, $context, $info, $return_type, $final_cb) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 277 | 7 | ▶ | return $final_cb->() if !$entries || !@$entries; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$entries and @$entries
MC/DC0%0/2
$entries and @$entries
$entries
@$entries
Truth table33%1/3
A and B
A= $entriesB= @$entries
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 7 | ▶ | if (@$entries == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 6 | my ($mode, $code, $directive_args, $directive) = @{ $entries->[0] }; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 6 | ▶ | if ($mode eq 'transform') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 281 | 3 | return $code->( | |||||||||||||||||||||||||||||||||||||||||
| 282 | scalar($final_cb->()), | ||||||||||||||||||||||||||||||||||||||||||
| 283 | $source, | ||||||||||||||||||||||||||||||||||||||||||
| 284 | $field_args, | ||||||||||||||||||||||||||||||||||||||||||
| 285 | $context, | ||||||||||||||||||||||||||||||||||||||||||
| 286 | $info, | ||||||||||||||||||||||||||||||||||||||||||
| 287 | $return_type, | ||||||||||||||||||||||||||||||||||||||||||
| 288 | $directive_args, | ||||||||||||||||||||||||||||||||||||||||||
| 289 | $directive, | ||||||||||||||||||||||||||||||||||||||||||
| 290 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 3 | local $CURRENT_SINGLE_DIRECTIVE_VALUE = $final_cb->(); | |||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | return $code->( | |||||||||||||||||||||||||||||||||||||||||
| 294 | $NEXT_SINGLE_DIRECTIVE_VALUE, | ||||||||||||||||||||||||||||||||||||||||||
| 295 | $source, | ||||||||||||||||||||||||||||||||||||||||||
| 296 | $field_args, | ||||||||||||||||||||||||||||||||||||||||||
| 297 | $context, | ||||||||||||||||||||||||||||||||||||||||||
| 298 | $info, | ||||||||||||||||||||||||||||||||||||||||||
| 299 | $return_type, | ||||||||||||||||||||||||||||||||||||||||||
| 300 | $directive_args, | ||||||||||||||||||||||||||||||||||||||||||
| 301 | $directive, | ||||||||||||||||||||||||||||||||||||||||||
| 302 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | local $CURRENT_DIRECTIVE_FRAME = { | |||||||||||||||||||||||||||||||||||||||||
| 306 | entries => $entries, | ||||||||||||||||||||||||||||||||||||||||||
| 307 | index => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 308 | source => $source, | ||||||||||||||||||||||||||||||||||||||||||
| 309 | field_args => $field_args, | ||||||||||||||||||||||||||||||||||||||||||
| 310 | context => $context, | ||||||||||||||||||||||||||||||||||||||||||
| 311 | info => $info, | ||||||||||||||||||||||||||||||||||||||||||
| 312 | return_type => $return_type, | ||||||||||||||||||||||||||||||||||||||||||
| 313 | final_cb => $final_cb, | ||||||||||||||||||||||||||||||||||||||||||
| 314 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 1 | return $NEXT_DIRECTIVE_VALUE->(); | |||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 20 | ▶ | sub _materialize_value { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_materialize_value: called CC=8 SCAR=21.8
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | 20 | my ($value, $variables) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 320 | 20 | my $ref = ref($value); | |||||||||||||||||||||||||||||||||||||||||
| 321 | 20 | ▶ | return $value if !$ref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 322 | 16 | ▶ | return $value ? 1 : 0 if is_bool($value); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 16 | ▶ | return _materialize_variable($$value, $variables) if $ref eq 'SCALAR'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 12 | ▶ | return _materialize_value($$value, $variables) if $ref eq 'REF'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 12 | ▶ | return [ map { _materialize_value($_, $variables) } @$value ] if $ref eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 8 | ▶ | map { $_ => _materialize_value($value->{$_}, $variables) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | keys %$value | ||||||||||||||||||||||||||||||||||||||||||
| 329 | } if $ref eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 4 | ▶ | sub _materialize_variable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_materialize_variable: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||
| 334 | 4 | my ($name, $variables) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 335 | 4 | ▶ | return undef if !defined $name; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 336 | 4 | ▶ | return exists $variables->{$name} ? $variables->{$name} : undef; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 62 | 1; | |||||||||||||||||||||||||||||||||||||||||