blib/lib/Zuzu/Module/Marshal.pm

filter: Statementstmt 65.2% 1222 / 1872 Branchbran 45.9% 476 / 1036 Conditioncond 34.0% 239 / 703 MC/DCmcdc 7.5% 29 / 385 Subroutinesub 80.9% 140 / 173 Podpod 0.0% 0 / 3 totaltotal 50.4% 2106 / 4172 CC 835 SCAR 54.7
CC
835
Cov
54%
_source_expr
1441.0
_source_binary_prec
1033.8
_source_stmt
703.3
CRAP 236.5
« blib/lib/Zuzu/Module/Proc.pm ↑ Summary blib/script/zuzu-highlight.pl »
1 package Zuzu::Module::Marshal;
2  
3 7 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 7 our $VERSION = '0.007002';
6  
7 7 ▶use Scalar::Util qw( blessed looks_like_number refaddr );
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 7 ▶use Zuzu::Marshal::CBOR qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
10 byte_string
11 bytes_value
12 cbor_false
13 cbor_true
14 decode_one
15 encode_one
16 is_byte_string
17 is_cbor_bool
18 is_tagged
19 is_text_string
20 tag
21 tag_number
22 tag_value
23 text_string
24 text_value
25 7 );
26 7 ▶use Zuzu::Util::NativeHelpers qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 native_class
28 native_function
29 7 );
30 7 ▶use Zuzu::Util::Number qw( is_finite_number );
Subroutine BEGIN: called CC=1 SCAR=0.0
31 7 ▶use Zuzu::Env;
Subroutine BEGIN: called CC=1 SCAR=0.0
32 7 ▶use Zuzu::Value::BinaryString;
Subroutine BEGIN: called CC=1 SCAR=0.0
33 7 ▶use Zuzu::Value::Boolean;
Subroutine BEGIN: called CC=1 SCAR=0.0
34 7 ▶use Zuzu::Value::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 7 ▶use Zuzu::Value::Dict;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 7 ▶use Zuzu::Value::PairList;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 7 ▶use Zuzu::Value::Set;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 7 ▶use Zuzu::Value::Bag;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 7 ▶use Zuzu::Value::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
40 7 ▶use Zuzu::Value::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
41 7 ▶use Zuzu::Value::Function;
Subroutine BEGIN: called CC=1 SCAR=0.0
42 7 ▶use Zuzu::Value::Trait;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 7 ▶use Zuzu::Weak qw( slot_value store_value );
Subroutine BEGIN: called CC=1 SCAR=0.0
44 7 ▶use Path::Tiny qw( path );
Subroutine BEGIN: called CC=1 SCAR=0.0
45  
46 7 ▶use constant MAX_SAFE_INTEGER => 9007199254740991;
Subroutine BEGIN: called CC=1 SCAR=0.0
47 7 ▶use constant KIND_PAIR => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
48 7 ▶use constant KIND_ARRAY => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
49 7 ▶use constant KIND_DICT => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
50 7 ▶use constant KIND_PAIRLIST => 4;
Subroutine BEGIN: called CC=1 SCAR=0.0
51 7 ▶use constant KIND_SET => 5;
Subroutine BEGIN: called CC=1 SCAR=0.0
52 7 ▶use constant KIND_BAG => 6;
Subroutine BEGIN: called CC=1 SCAR=0.0
53 7 ▶use constant KIND_OBJECT => 7;
Subroutine BEGIN: called CC=1 SCAR=0.0
54 7 ▶use constant KIND_FUNCTION => 8;
Subroutine BEGIN: called CC=1 SCAR=0.0
55 7 ▶use constant KIND_CLASS => 9;
Subroutine BEGIN: called CC=1 SCAR=0.0
56 7 ▶use constant KIND_TRAIT => 10;
Subroutine BEGIN: called CC=1 SCAR=0.0
57 7 ▶use constant KIND_BOUND_METHOD => 11;
Subroutine BEGIN: called CC=1 SCAR=0.0
58 7 ▶use constant KIND_TIME => 12;
Subroutine BEGIN: called CC=1 SCAR=0.0
59 7 ▶use constant KIND_PATH => 13;
Subroutine BEGIN: called CC=1 SCAR=0.0
60 7 ▶use constant CODE_FUNCTION => 1;
Subroutine BEGIN: called CC=1 SCAR=0.0
61 7 ▶use constant CODE_CLASS => 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
62 7 ▶use constant CODE_TRAIT => 3;
Subroutine BEGIN: called CC=1 SCAR=0.0
63 7 ▶use constant EDGE_STRONG => 'strong';
Subroutine BEGIN: called CC=1 SCAR=0.0
64 7 ▶use constant EDGE_WEAK => 'weak';
Subroutine BEGIN: called CC=1 SCAR=0.0
65  
66 7 my $TRUE = Zuzu::Value::Boolean->new( value => 1 );
67 7 my $FALSE = Zuzu::Value::Boolean->new( value => 0 );
68  
69 7 ▶sub _call_file {
Subroutine _call_file: called CC=2 SCAR=7.2
70 7 my ( $runtime ) = @_;
71 7 ▶ return $runtime->{_native_call_file} // '<std/marshal>';
Condition50%1/2
$runtime->{"_native_call_file"} // "<std/marshal>"
l!l
70
MC/DC0%0/1
$runtime->{"_native_call_file"} // "<std/marshal>"
$runtime->{"_native_call_file"}
Truth table50%1/2
A
A= $runtime->{"_native_call_file"}
Aresult
11
00
72 }
73  
74 7 ▶sub _call_line {
Subroutine _call_line: called CC=2 SCAR=7.2
75 7 my ( $runtime ) = @_;
76 7 ▶ return $runtime->{_native_call_line} // 0;
Condition50%1/2
$runtime->{"_native_call_line"} // 0
l!l
70
MC/DC0%0/1
$runtime->{"_native_call_line"} // 0
$runtime->{"_native_call_line"}
Truth table50%1/2
A
A= $runtime->{"_native_call_line"}
Aresult
11
00
77 }
78  
79 1 ▶sub _throw_object {
Subroutine _throw_object: called CC=1 SCAR=0.0
80 1 my ( $runtime, $class, $message ) = @_;
81  
82 1 die {
83 _zuzu_throw => 1,
84 value => $runtime->_instantiate_builtin_object(
85 $class,
86 {
87 message => $message,
88 file => _call_file($runtime),
89 line => _call_line($runtime),
90 },
91 ),
92 };
93 }
94  
95 0 ▶sub _throw_type {
Subroutine _throw_type: not called CC=2 SCAR=17.9
96 0 my ( $runtime, $message ) = @_;
97  
98 my $class = $runtime->{_builtin_classes}{TypeException}
99 0 ▶ // $runtime->{_builtin_classes}{Exception};
Condition0%0/3
$runtime->{"_builtin_classes"}{"TypeException"} // $runtime->{"_builtin_classes"}{"Exception"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$runtime->{"_builtin_classes"}{"TypeException"} // $runtime->{"_builtin_classes"}{"Exception"}
$runtime->{"_builtin_classes"}{"TypeException"} $runtime->{"_builtin_classes"}{"Exception"}
Truth table0%0/3
A // B
A= $runtime->{"_builtin_classes"}{"TypeException"}B= $runtime->{"_builtin_classes"}{"Exception"}
ABresult
1X1
011
000
100 0 _throw_object( $runtime, $class, $message );
101 }
102  
103 18 ▶sub _assert_arity {
Subroutine _assert_arity: called CC=4 SCAR=17.1
104 18 my ( $runtime, $name, $args, $expected ) = @_;
105  
106 18 ▶ my $got = scalar @{ $args // [] };
Condition50%1/2
$args // []
l!l
180
MC/DC0%0/1
$args // []
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
107 18 ▶ return if $got == $expected;
Branch: 1 branch
BranchTrueFalseTotal
if $got == $expected 18 0 18
108  
109 0 ▶ _throw_type(
Branch: 1 branch
BranchTrueFalseTotal
$expected == 1 ? : 0 0 0
110 $runtime,
111 "TypeException: std/marshal.$name expects $expected argument"
112 . ( $expected == 1 ? '' : 's' )
113 . ", got $got",
114 );
115 }
116  
117 9 ▶sub _assert_binary_string {
Subroutine _assert_binary_string: called CC=3 SCAR=15.1
118 9 my ( $runtime, $name, $value ) = @_;
119  
120 9 ▶ return if blessed($value) and $value->isa('Zuzu::Value::BinaryString');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString") 9 0 9
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
009
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
builtin::blessed($value) $value->isa("Zuzu::Value::BinaryString")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
121  
122 0 my $type = $runtime->_type_name($value);
123  
124 0 _throw_type(
125 $runtime,
126 "TypeException: std/marshal.$name expects BinaryString, got $type",
127 );
128 }
129  
130 0 ▶sub _zuzu_bool {
Subroutine _zuzu_bool: not called CC=2 SCAR=17.9
131 0 my ( $value ) = @_;
132 0 ▶ return $value ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
$value ? : 0 0 0
133 }
134  
135 0 ▶sub _safe_to_dump {
Subroutine _safe_to_dump: not called CC=2 SCAR=17.9
136 0 my ( $runtime, $value ) = @_;
137  
138 0 ▶ return eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { dump_value($runtime, $value); 1 } } ? : 0 0 0
139 0 dump_value( $runtime, $value );
140 0 1;
141 } ? 1 : 0;
142 }
143  
144 9 ▶sub dump_value {
Subroutine dump_value: called CC=1 SCAR=0.0
Pod undocumented
145 9 my ( $runtime, $value ) = @_;
146  
147 9 my $envelope = _encode_envelope( $runtime, $value );
148  
149 9 return encode_one($envelope);
150 }
151  
152 9 ▶sub load_value {
Subroutine load_value: called CC=1 SCAR=0.0
Pod undocumented
153 9 my ( $runtime, $bytes ) = @_;
154  
155 9 my $decoded = decode_one($bytes);
156  
157 9 return _decode_envelope( $runtime, $decoded );
158 }
159  
160 9 ▶sub _function_expression_source {
Subroutine _function_expression_source: called CC=8 SCAR=22.4
161 9 my ( $runtime, $fn ) = @_;
162  
163 9 ▶ die "Function source extraction expects a Function value"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function") 0 9 9
Condition33%1/3
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
!ll&&!rl&&r
009
MC/DC0%0/2
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
builtin::blessed($fn) $fn->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($fn)B= $fn->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
164 if !blessed($fn) or !$fn->isa('Zuzu::Value::Function');
165 die "Native functions do not have ZuzuScript source"
166 9 ▶ if $fn->{_native};
Branch: 1 branch
BranchTrueFalseTotal
if $fn->{"_native"} 0 9 9
167 9 ▶ die "Function value has no AST body for source extraction"
Branch: 1 branch
BranchTrueFalseTotal
unless $fn->body 0 9 9
168 if !$fn->body;
169  
170 9 ▶ my $prefix = $fn->is_async ? 'async function' : 'function';
Branch: 1 branch
BranchTrueFalseTotal
$fn->is_async ? : 0 9 9
171 9 my $source = $prefix . ' (' . _source_param_list($fn) . ')';
172 9 ▶ my $return_type = $fn->return_type // 'Any';
Condition50%1/2
$fn->return_type // "Any"
l!l
90
MC/DC0%0/1
$fn->return_type // "Any"
$fn->return_type
Truth table50%1/2
A
A= $fn->return_type
Aresult
11
00
173 9 ▶ $source .= ' -> ' . $return_type if $return_type ne 'Any';
Branch: 1 branch
BranchTrueFalseTotal
if $return_type ne "Any" 1 8 9
174 9 $source .= ' ' . _source_block( $fn->body );
175  
176 9 return $source;
177 }
178  
179 7 ▶sub _analyse_function_value {
Subroutine _analyse_function_value: called CC=9 SCAR=22.0
180 7 my ( $runtime, $fn ) = @_;
181  
182 7 my $source = _function_expression_source( $runtime, $fn );
183 7 my %free;
184 7 my %bound = _function_initial_bindings($fn);
185 7 _collect_free_names_from_block( $fn->body, \%bound, \%free );
186  
187 7 my @captures;
188 my @internal_dependencies;
189 7 my @external_dependencies;
190 7 for my $name ( sort keys %free ) {
191 5 ▶ next if _is_builtin_name( $runtime, $name );
Branch: 1 branch
BranchTrueFalseTotal
if _is_builtin_name($runtime, $name) 0 5 5
192  
193 5 my $binding = _find_function_binding( $fn, $name );
194 5 ▶ die "Function source references unresolved name '$name'"
Branch: 1 branch
BranchTrueFalseTotal
unless $binding 0 5 5
195 if !$binding;
196  
197 5 my $value = ${ $binding->{ref} };
198 5 ▶ if ( my $external = _external_std_dependency(
Branch: 1 branch
BranchTrueFalseTotal
if (my $external = _external_std_dependency($runtime, $name, $binding->{"ref"})) 1 4 5
199 $runtime,
200 $name,
201 $binding->{ref},
202 ) ) {
203 1 push @external_dependencies, $external;
204 1 next;
205 }
206 4 ▶ if ( _is_internal_dependency_value($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_internal_dependency_value($value)) 1 3 4
207 die "Function dependency '$name' is not const"
208 1 ▶ if !$binding->{const};
Branch: 1 branch
BranchTrueFalseTotal
unless $binding->{"const"} 0 1 1
209 1 push @internal_dependencies, {
210 name => $name,
211 value => $value,
212 };
213 1 next;
214 }
215 die "Function capture '$name' is not const"
216 3 ▶ if !$binding->{const};
Branch: 1 branch
BranchTrueFalseTotal
unless $binding->{"const"} 1 2 3
217 2 ▶ die "Function capture '$name' is not a scalar value"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_scalar_capture_value($runtime, $value) 1 1 2
218 if !_is_scalar_capture_value( $runtime, $value );
219 1 push @captures, {
220 name => $name,
221 value => $value,
222 };
223 }
224  
225 return {
226 5 source => $source,
227 free_names => [ sort keys %free ],
228 captures => \@captures,
229 internal_dependencies => \@internal_dependencies,
230 external_dependencies => \@external_dependencies,
231 };
232 }
233  
234 2 ▶sub _analyse_class_value {
Subroutine _analyse_class_value: called CC=9 SCAR=37.4
235 2 my ( $runtime, $class_value ) = @_;
236  
237 2 my $source = _class_declaration_source( $runtime, $class_value );
238 2 my $node = $class_value->source_node;
239 2 my %free;
240 2 my %bound = _class_initial_bindings($node);
241 2 _collect_class_free_names( $node, \%bound, \%free );
242  
243 2 my @captures;
244 my @internal_dependencies;
245 2 my @external_dependencies;
246 2 for my $name ( sort keys %free ) {
247 0 ▶ next if _is_builtin_name( $runtime, $name );
Branch: 1 branch
BranchTrueFalseTotal
if _is_builtin_name($runtime, $name) 0 0 0
248  
249 0 my $binding = _find_class_binding( $class_value, $name );
250 0 ▶ die "Class source references unresolved name '$name'"
Branch: 1 branch
BranchTrueFalseTotal
unless $binding 0 0 0
251 if !$binding;
252  
253 0 my $value = ${ $binding->{ref} };
254 0 ▶ if ( my $external = _external_std_dependency(
Branch: 1 branch
BranchTrueFalseTotal
if (my $external = _external_std_dependency($runtime, $name, $binding->{"ref"})) 0 0 0
255 $runtime,
256 $name,
257 $binding->{ref},
258 ) ) {
259 0 push @external_dependencies, $external;
260 0 next;
261 }
262 0 ▶ if ( _is_internal_dependency_value($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_internal_dependency_value($value)) 0 0 0
263 die "Class dependency '$name' is not const"
264 0 ▶ if !$binding->{const};
Branch: 1 branch
BranchTrueFalseTotal
unless $binding->{"const"} 0 0 0
265 0 push @internal_dependencies, {
266 name => $name,
267 value => $value,
268 };
269 0 next;
270 }
271 die "Class capture '$name' is not const"
272 0 ▶ if !$binding->{const};
Branch: 1 branch
BranchTrueFalseTotal
unless $binding->{"const"} 0 0 0
273 0 ▶ die "Class capture '$name' is not a scalar value"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_scalar_capture_value($runtime, $value) 0 0 0
274 if !_is_scalar_capture_value( $runtime, $value );
275 0 push @captures, {
276 name => $name,
277 value => $value,
278 };
279 }
280  
281 return {
282 2 source => $source,
283 free_names => [ sort keys %free ],
284 captures => \@captures,
285 internal_dependencies => \@internal_dependencies,
286 external_dependencies => \@external_dependencies,
287 };
288 }
289  
290 0 ▶sub _analyse_trait_value {
Subroutine _analyse_trait_value: not called CC=9 SCAR=45.0
291 0 my ( $runtime, $trait_value ) = @_;
292  
293 0 my $source = _trait_declaration_source( $runtime, $trait_value );
294 0 my $node = $trait_value->source_node;
295 0 my %free;
296 0 my %bound = _trait_initial_bindings($node);
297 0 _collect_trait_free_names( $node, \%bound, \%free );
298  
299 0 my @captures;
300 my @internal_dependencies;
301 0 my @external_dependencies;
302 0 for my $name ( sort keys %free ) {
303 0 ▶ next if _is_builtin_name( $runtime, $name );
Branch: 1 branch
BranchTrueFalseTotal
if _is_builtin_name($runtime, $name) 0 0 0
304  
305 0 my $binding = _find_trait_binding( $trait_value, $name );
306 0 ▶ die "Trait source references unresolved name '$name'"
Branch: 1 branch
BranchTrueFalseTotal
unless $binding 0 0 0
307 if !$binding;
308  
309 0 my $value = ${ $binding->{ref} };
310 0 ▶ if ( my $external = _external_std_dependency(
Branch: 1 branch
BranchTrueFalseTotal
if (my $external = _external_std_dependency($runtime, $name, $binding->{"ref"})) 0 0 0
311 $runtime,
312 $name,
313 $binding->{ref},
314 ) ) {
315 0 push @external_dependencies, $external;
316 0 next;
317 }
318 0 ▶ if ( _is_internal_dependency_value($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_internal_dependency_value($value)) 0 0 0
319 die "Trait dependency '$name' is not const"
320 0 ▶ if !$binding->{const};
Branch: 1 branch
BranchTrueFalseTotal
unless $binding->{"const"} 0 0 0
321 0 push @internal_dependencies, {
322 name => $name,
323 value => $value,
324 };
325 0 next;
326 }
327 die "Trait capture '$name' is not const"
328 0 ▶ if !$binding->{const};
Branch: 1 branch
BranchTrueFalseTotal
unless $binding->{"const"} 0 0 0
329 0 ▶ die "Trait capture '$name' is not a scalar value"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_scalar_capture_value($runtime, $value) 0 0 0
330 if !_is_scalar_capture_value( $runtime, $value );
331 0 push @captures, {
332 name => $name,
333 value => $value,
334 };
335 }
336  
337 return {
338 0 source => $source,
339 free_names => [ sort keys %free ],
340 captures => \@captures,
341 internal_dependencies => \@internal_dependencies,
342 external_dependencies => \@external_dependencies,
343 };
344 }
345  
346 7 ▶sub _function_initial_bindings {
Subroutine _function_initial_bindings: called CC=4 SCAR=14.2
347 7 my ( $fn ) = @_;
348  
349 7 ▶ my %bound = map { $_ => 1 } @{ $fn->params // [] };
Condition50%1/2
$fn->params // []
l!l
70
MC/DC0%0/1
$fn->params // []
$fn->params
Truth table50%1/2
A
A= $fn->params
Aresult
11
00
350 7 ▶ $bound{ $fn->vararg } = 1 if defined $fn->vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fn->vararg 0 7 7
351 7 ▶ $bound{ $fn->named_vararg } = 1 if defined $fn->named_vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $fn->named_vararg 0 7 7
352 7 $bound{__argc__} = 1;
353  
354 7 return %bound;
355 }
356  
357 0 ▶sub _trait_initial_bindings {
Subroutine _trait_initial_bindings: not called CC=1 SCAR=6.9
358 0 my ( $node ) = @_;
359  
360 0 return ( $node->name => 1 );
361 }
362  
363 0 ▶sub _collect_trait_free_names {
Subroutine _collect_trait_free_names: not called CC=4 SCAR=30.0
364 0 my ( $node, $bound, $free ) = @_;
365  
366 my %method_base_bound = (
367 0 ▶ %{ $bound // {} },
Condition0%0/2
$bound // {}
l!l
00
MC/DC0%0/1
$bound // {}
$bound
Truth table0%0/2
A
A= $bound
Aresult
11
00
368 self => 1,
369 super => 1,
370 );
371 0 ▶ for my $method ( @{ $node->methods // [] } ) {
Condition0%0/2
$node->methods // []
l!l
00
MC/DC0%0/1
$node->methods // []
$node->methods
Truth table0%0/2
A
A= $node->methods
Aresult
11
00
372 0 my %method_bound = (
373 %method_base_bound,
374 _function_method_bindings($method),
375 );
376 0 _collect_free_names_from_block(
377 $method->body,
378 \%method_bound,
379 $free,
380 );
381 }
382  
383 0 return;
384 }
385  
386 2 ▶sub _class_initial_bindings {
Subroutine _class_initial_bindings: called CC=3 SCAR=11.4
387 2 my ( $node ) = @_;
388  
389 2 my %bound = ( $node->name => 1 );
390 2 ▶ for my $nested ( @{ $node->classes // [] } ) {
Condition50%1/2
$node->classes // []
l!l
20
MC/DC0%0/1
$node->classes // []
$node->classes
Truth table50%1/2
A
A= $node->classes
Aresult
11
00
391 0 $bound{ $nested->name } = 1;
392 }
393  
394 2 return %bound;
395 }
396  
397 2 ▶sub _collect_class_free_names {
Subroutine _collect_class_free_names: called CC=17 SCAR=34.2
398 2 my ( $node, $bound, $free ) = @_;
399  
400 2 ▶ _collect_free_names_from_expr( $node->parent, $bound, $free )
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->parent 0 2 2
401 if defined $node->parent;
402 2 ▶ for my $trait ( @{ $node->traits // [] } ) {
Condition50%1/2
$node->traits // []
l!l
20
MC/DC0%0/1
$node->traits // []
$node->traits
Truth table50%1/2
A
A= $node->traits
Aresult
11
00
403 0 _collect_free_names_from_expr( $trait, $bound, $free );
404 }
405 2 ▶ for my $field ( @{ $node->fields // [] } ) {
Condition50%1/2
$node->fields // []
l!l
20
MC/DC0%0/1
$node->fields // []
$node->fields
Truth table50%1/2
A
A= $node->fields
Aresult
11
00
406 _collect_free_names_from_expr( $field->{init}, $bound, $free )
407 1 ▶ if defined $field->{init};
Branch: 1 branch
BranchTrueFalseTotal
if defined $field->{"init"} 0 1 1
408 }
409  
410 my %instance_bound = (
411 2 ▶ %{ $bound // {} },
Condition50%1/2
$bound // {}
l!l
20
MC/DC0%0/1
$bound // {}
$bound
Truth table50%1/2
A
A= $bound
Aresult
11
00
412 self => 1,
413 super => 1,
414 2 ▶ map { $_->{name} => 1 } @{ $node->fields // [] },
Condition50%1/2
$node->fields // []
l!l
20
MC/DC0%0/1
$node->fields // []
$node->fields
Truth table50%1/2
A
A= $node->fields
Aresult
11
00
415 );
416 2 ▶ for my $method ( @{ $node->methods // [] } ) {
Condition50%1/2
$node->methods // []
l!l
20
MC/DC0%0/1
$node->methods // []
$node->methods
Truth table50%1/2
A
A= $node->methods
Aresult
11
00
417 2 my %method_bound = (
418 %instance_bound,
419 _function_method_bindings($method),
420 );
421 2 _collect_free_names_from_block(
422 $method->body,
423 \%method_bound,
424 $free,
425 );
426 }
427  
428 2 ▶ my %static_bound = ( %{ $bound // {} }, self => 1, super => 1 );
Condition50%1/2
$bound // {}
l!l
20
MC/DC0%0/1
$bound // {}
$bound
Truth table50%1/2
A
A= $bound
Aresult
11
00
429 2 ▶ for my $method ( @{ $node->static_methods // [] } ) {
Condition50%1/2
$node->static_methods // []
l!l
20
MC/DC0%0/1
$node->static_methods // []
$node->static_methods
Truth table50%1/2
A
A= $node->static_methods
Aresult
11
00
430 0 my %method_bound = (
431 %static_bound,
432 _function_method_bindings($method),
433 );
434 0 _collect_free_names_from_block(
435 $method->body,
436 \%method_bound,
437 $free,
438 );
439 }
440  
441 2 ▶ for my $nested ( @{ $node->classes // [] } ) {
Condition50%1/2
$node->classes // []
l!l
20
MC/DC0%0/1
$node->classes // []
$node->classes
Truth table50%1/2
A
A= $node->classes
Aresult
11
00
442 0 ▶ my %nested_bound = ( %{ $bound // {} }, _class_initial_bindings($nested) );
Condition0%0/2
$bound // {}
l!l
00
MC/DC0%0/1
$bound // {}
$bound
Truth table0%0/2
A
A= $bound
Aresult
11
00
443 0 _collect_class_free_names( $nested, \%nested_bound, $free );
444 }
445  
446 2 return;
447 }
448  
449 2 ▶sub _function_method_bindings {
Subroutine _function_method_bindings: called CC=4 SCAR=14.2
450 2 my ( $method ) = @_;
451  
452 2 ▶ my %bound = map { $_ => 1 } @{ $method->params // [] };
Condition50%1/2
$method->params // []
l!l
20
MC/DC0%0/1
$method->params // []
$method->params
Truth table50%1/2
A
A= $method->params
Aresult
11
00
453 2 ▶ $bound{ $method->vararg } = 1 if defined $method->vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $method->vararg 0 2 2
454 2 ▶ $bound{ $method->named_vararg } = 1 if defined $method->named_vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $method->named_vararg 0 2 2
455 2 $bound{__argc__} = 1;
456  
457 2 return %bound;
458 }
459  
460 9 ▶sub _collect_free_names_from_block {
Subroutine _collect_free_names_from_block: called CC=4 SCAR=14.1
461 9 my ( $block, $bound, $free ) = @_;
462  
463 9 ▶ my %local = %{ $bound // {} };
Condition50%1/2
$bound // {}
l!l
90
MC/DC0%0/1
$bound // {}
$bound
Truth table50%1/2
A
A= $bound
Aresult
11
00
464 9 ▶ for my $stmt ( @{ $block->statements // [] } ) {
Condition50%1/2
$block->statements // []
l!l
90
MC/DC0%0/1
$block->statements // []
$block->statements
Truth table50%1/2
A
A= $block->statements
Aresult
11
00
465 10 _collect_free_names_from_stmt( $stmt, \%local, $free );
466 }
467  
468 9 return;
469 }
470  
471 10 ▶sub _collect_free_names_from_stmt {
Subroutine _collect_free_names_from_stmt: called CC=30 SCAR=63.6
472 10 my ( $stmt, $bound, $free ) = @_;
473  
474 10 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Return') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Return")) 9 1 10
475 9 ▶ _collect_free_names_from_expr( $stmt->expr, $bound, $free )
Branch: 1 branch
BranchTrueFalseTotal
if defined $stmt->expr 9 0 9
476 if defined $stmt->expr;
477 9 return;
478 }
479 1 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Expr') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Expr")) 0 1 1
480 0 _collect_free_names_from_expr( $stmt->expr, $bound, $free );
481 0 return;
482 }
483 1 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Let') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Let")) 0 1 1
484 0 ▶ _collect_free_names_from_expr( $stmt->init, $bound, $free )
Branch: 1 branch
BranchTrueFalseTotal
if defined $stmt->init 0 0 0
485 if defined $stmt->init;
486 0 $bound->{ $stmt->name } = 1;
487 0 return;
488 }
489 1 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Assign') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Assign")) 1 0 1
490 1 _collect_free_names_from_expr( $stmt->target, $bound, $free );
491 1 ▶ if ( ( $stmt->op // '' ) eq '~=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($stmt->op // "") eq "~=") 0 1 1
Condition50%1/2
$stmt->op // ""
l!l
10
MC/DC0%0/1
$stmt->op // ""
$stmt->op
Truth table50%1/2
A
A= $stmt->op
Aresult
11
00
492 0 _collect_free_names_from_expr( $stmt->match_expr, $bound, $free );
493 0 ▶ my %replace_bound = ( %{ $bound // {} }, m => 1 );
Condition0%0/2
$bound // {}
l!l
00
MC/DC0%0/1
$bound // {}
$bound
Truth table0%0/2
A
A= $bound
Aresult
11
00
494 0 _collect_free_names_from_expr(
495 $stmt->replace_expr,
496 \%replace_bound,
497 $free,
498 );
499 0 return;
500 }
501 1 _collect_free_names_from_expr( $stmt->expr, $bound, $free );
502 1 return;
503 }
504 0 ▶ if ( $stmt->isa('Zuzu::AST::Block') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Block")) 0 0 0
505 0 _collect_free_names_from_block( $stmt, $bound, $free );
506 0 return;
507 }
508 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::If') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::If")) 0 0 0
509 0 _collect_free_names_from_expr( $stmt->cond, $bound, $free );
510 0 _collect_free_names_from_block( $stmt->then_block, $bound, $free );
511 0 ▶ _collect_free_names_from_else( $stmt->else_branch, $bound, $free )
Branch: 1 branch
BranchTrueFalseTotal
if $stmt->else_branch 0 0 0
512 if $stmt->else_branch;
513 0 return;
514 }
515 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::While') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::While")) 0 0 0
516 0 _collect_free_names_from_expr( $stmt->cond, $bound, $free );
517 0 _collect_free_names_from_block( $stmt->body, $bound, $free );
518 0 return;
519 }
520 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::For') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::For")) 0 0 0
521 0 _collect_free_names_from_expr( $stmt->collection, $bound, $free );
522 0 ▶ my %loop_bound = %{ $bound // {} };
Condition0%0/2
$bound // {}
l!l
00
MC/DC0%0/1
$bound // {}
$bound
Truth table0%0/2
A
A= $bound
Aresult
11
00
523 0 ▶ $loop_bound{ $stmt->var } = 1 if $stmt->declare_loop_var;
Branch: 1 branch
BranchTrueFalseTotal
if $stmt->declare_loop_var 0 0 0
524 0 _collect_free_names_from_block( $stmt->body, \%loop_bound, $free );
525 0 ▶ _collect_free_names_from_block(
Branch: 1 branch
BranchTrueFalseTotal
if $stmt->else_block 0 0 0
526 $stmt->else_block,
527 $bound,
528 $free,
529 ) if $stmt->else_block;
530 0 return;
531 }
532 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Try') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Try")) 0 0 0
533 0 _collect_free_names_from_block( $stmt->block, $bound, $free );
534 0 ▶ for my $catch ( @{ $stmt->catches // [] } ) {
Condition0%0/2
$stmt->catches // []
l!l
00
MC/DC0%0/1
$stmt->catches // []
$stmt->catches
Truth table0%0/2
A
A= $stmt->catches
Aresult
11
00
535 0 _collect_free_names_from_expr( $catch->type_expr, $bound, $free );
536 0 ▶ my %catch_bound = ( %{ $bound // {} }, $catch->name => 1 );
Condition0%0/2
$bound // {}
l!l
00
MC/DC0%0/1
$bound // {}
$bound
Truth table0%0/2
A
A= $bound
Aresult
11
00
537 0 _collect_free_names_from_block(
538 $catch->block,
539 \%catch_bound,
540 $free,
541 );
542 }
543 0 return;
544 }
545 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Import') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Import")) 0 0 0
546 0 _collect_import_bound_names( $stmt, $bound );
547 0 ▶ _collect_free_names_from_expr(
Branch: 1 branch
BranchTrueFalseTotal
if defined $stmt->condition_expr 0 0 0
548 $stmt->condition_expr,
549 $bound,
550 $free,
551 ) if defined $stmt->condition_expr;
552 0 return;
553 }
554 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Function")) 0 0 0
555 0 $bound->{ $stmt->name } = 1;
556 0 return;
557 }
558 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Die') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Die")) 0 0 0
559 0 _collect_free_names_from_expr( $stmt->expr, $bound, $free );
560 0 return;
561 }
562 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Throw') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Throw")) 0 0 0
563 0 _collect_free_names_from_expr( $stmt->expr, $bound, $free );
564 0 return;
565 }
566 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Next") or $stmt->isa("Zuzu::AST::Stmt::Last") or $stmt->isa("Zuzu::AST::Stmt::Continue")) 0 0 0
Condition0%0/6
$stmt->isa("Zuzu::AST::Stmt::Next") or $stmt->isa("Zuzu::AST::Stmt::Last") or $stmt->isa("Zuzu::AST::Stmt::Continue")
l!l&&r!l&&!r
000
$stmt->isa("Zuzu::AST::Stmt::Next") or $stmt->isa("Zuzu::AST::Stmt::Last")
l!l&&r!l&&!r
000
MC/DC0%0/3
$stmt->isa("Zuzu::AST::Stmt::Next") or $stmt->isa("Zuzu::AST::Stmt::Last") or $stmt->isa("Zuzu::AST::Stmt::Continue")
$stmt->isa("Zuzu::AST::Stmt::Next") $stmt->isa("Zuzu::AST::Stmt::Last") $stmt->isa("Zuzu::AST::Stmt::Continue")
Truth table0%0/4
A or B or C
A= $stmt->isa("Zuzu::AST::Stmt::Next")B= $stmt->isa("Zuzu::AST::Stmt::Last")C= $stmt->isa("Zuzu::AST::Stmt::Continue")
ABCresult
1XX1
01X1
0011
0000
567 $stmt->isa('Zuzu::AST::Stmt::Next')
568 or $stmt->isa('Zuzu::AST::Stmt::Last')
569 or $stmt->isa('Zuzu::AST::Stmt::Continue')
570 ) {
571 0 return;
572 }
573  
574 0 die "Unsupported function body statement for capture analysis: "
575 . ref($stmt);
576 }
577  
578 0 ▶sub _collect_free_names_from_else {
Subroutine _collect_free_names_from_else: not called CC=3 SCAR=24.8
579 0 my ( $branch, $bound, $free ) = @_;
580  
581 0 ▶ if ( $branch->isa('Zuzu::AST::Block') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($branch->isa("Zuzu::AST::Block")) 0 0 0
582 0 _collect_free_names_from_block( $branch, $bound, $free );
583 0 return;
584 }
585 0 ▶ if ( $branch->isa('Zuzu::AST::Stmt::If') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($branch->isa("Zuzu::AST::Stmt::If")) 0 0 0
586 0 _collect_free_names_from_stmt( $branch, $bound, $free );
587 0 return;
588 }
589  
590 0 die "Unsupported else branch for capture analysis: " . ref($branch);
591 }
592  
593 27 ▶sub _collect_free_names_from_expr {
Subroutine _collect_free_names_from_expr: called CC=33 SCAR=50.6
594 27 my ( $expr, $bound, $free ) = @_;
595  
596 27 ▶ return if !defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 27 27
597 27 ▶ if ( $expr->isa('Zuzu::AST::Expr::Var') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Var")) 14 13 27
598 14 ▶ $free->{ $expr->name } = 1 if !$bound->{ $expr->name };
Branch: 1 branch
BranchTrueFalseTotal
unless $$bound{$expr->name} 5 9 14
599 14 return;
600 }
601 13 ▶ if ( $expr->isa('Zuzu::AST::Expr::Literal') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Literal")) 5 8 13
602 5 return;
603 }
604 8 ▶ if ( $expr->isa('Zuzu::AST::Expr::TypeRef') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::TypeRef")) 0 8 8
605 0 ▶ $free->{ $expr->root } = 1 if !$bound->{ $expr->root };
Branch: 1 branch
BranchTrueFalseTotal
unless $$bound{$expr->root} 0 0 0
606 0 return;
607 }
608 8 ▶ if ( $expr->isa('Zuzu::AST::Expr::Binary') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Binary")) 3 5 8
609 3 _collect_free_names_from_expr( $expr->left, $bound, $free );
610 3 _collect_free_names_from_expr( $expr->right, $bound, $free );
611 3 return;
612 }
613 5 ▶ if ( $expr->isa('Zuzu::AST::Expr::Unary') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Unary")) 0 5 5
614 0 _collect_free_names_from_expr( $expr->expr, $bound, $free );
615 0 return;
616 }
617 5 ▶ if ( $expr->isa('Zuzu::AST::Expr::Ternary') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Ternary")) 0 5 5
618 0 _collect_free_names_from_expr( $expr->cond, $bound, $free );
619 0 ▶ _collect_free_names_from_expr( $expr->if_true, $bound, $free )
Branch: 1 branch
BranchTrueFalseTotal
if defined $expr->if_true 0 0 0
620 if defined $expr->if_true;
621 0 _collect_free_names_from_expr( $expr->if_false, $bound, $free );
622 0 return;
623 }
624 5 ▶ if ( $expr->isa('Zuzu::AST::Expr::Call') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Call")) 1 4 5
625 1 _collect_free_names_from_expr( $expr->callee, $bound, $free );
626 1 _collect_free_names_from_args( $expr->args, $bound, $free );
627 1 return;
628 }
629 4 ▶ if ( $expr->isa('Zuzu::AST::Expr::MemberCall') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::MemberCall")) 0 4 4
630 0 _collect_free_names_from_expr( $expr->object, $bound, $free );
631 0 _collect_free_names_from_args( $expr->args, $bound, $free );
632 0 return;
633 }
634 4 ▶ if ( $expr->isa('Zuzu::AST::Expr::DynamicMemberCall') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::DynamicMemberCall")) 0 4 4
635 0 _collect_free_names_from_expr( $expr->object, $bound, $free );
636 0 _collect_free_names_from_expr( $expr->method_expr, $bound, $free );
637 0 _collect_free_names_from_args( $expr->args, $bound, $free );
638 0 return;
639 }
640 4 ▶ if ( $expr->isa('Zuzu::AST::Expr::Index') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Index")) 1 3 4
641 1 _collect_free_names_from_expr( $expr->array, $bound, $free );
642 1 _collect_free_names_from_expr( $expr->index, $bound, $free );
643 1 return;
644 }
645 3 ▶ if ( $expr->isa('Zuzu::AST::Expr::Slice') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Slice")) 0 3 3
646 0 _collect_free_names_from_expr( $expr->collection, $bound, $free );
647 0 _collect_free_names_from_expr( $expr->start, $bound, $free );
648 0 _collect_free_names_from_expr( $expr->length, $bound, $free );
649 0 return;
650 }
651 3 ▶ if ( $expr->isa('Zuzu::AST::Expr::DictGet') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::DictGet")) 0 3 3
652 0 _collect_free_names_from_expr( $expr->dict, $bound, $free );
653 0 _collect_free_names_from_expr( $expr->key, $bound, $free );
654 0 return;
655 }
656 3 ▶ if ( $expr->isa('Zuzu::AST::Expr::New') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::New")) 1 2 3
657 1 _collect_free_names_from_expr( $expr->class_expr, $bound, $free );
658 1 ▶ for my $trait ( @{ $expr->traits // [] } ) {
Condition50%1/2
$expr->traits // []
l!l
10
MC/DC0%0/1
$expr->traits // []
$expr->traits
Truth table50%1/2
A
A= $expr->traits
Aresult
11
00
659 0 _collect_free_names_from_expr( $trait, $bound, $free );
660 }
661 1 _collect_free_names_from_args( $expr->args, $bound, $free );
662 1 return;
663 }
664 2 ▶ if ( $expr->isa('Zuzu::AST::Expr::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Function")) 0 2 2
665 0 ▶ my %nested_bound = ( %{ $bound // {} }, _function_expr_bindings($expr) );
Condition0%0/2
$bound // {}
l!l
00
MC/DC0%0/1
$bound // {}
$bound
Truth table0%0/2
A
A= $bound
Aresult
11
00
666 0 _collect_free_names_from_block( $expr->body, \%nested_bound, $free );
667 0 return;
668 }
669 2 ▶ if ( $expr->isa('Zuzu::AST::Expr::Await') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Await")) 0 2 2
670 0 _collect_free_names_from_block( $expr->block, $bound, $free );
671 0 return;
672 }
673 2 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Array") or $expr->isa("Zuzu::AST::Expr::Set") or $expr->isa("Zuzu::AST::Expr::Bag")) 0 2 2
Condition33%2/6
$expr->isa("Zuzu::AST::Expr::Array") or $expr->isa("Zuzu::AST::Expr::Set") or $expr->isa("Zuzu::AST::Expr::Bag")
l!l&&r!l&&!r
002
$expr->isa("Zuzu::AST::Expr::Array") or $expr->isa("Zuzu::AST::Expr::Set")
l!l&&r!l&&!r
002
MC/DC0%0/3
$expr->isa("Zuzu::AST::Expr::Array") or $expr->isa("Zuzu::AST::Expr::Set") or $expr->isa("Zuzu::AST::Expr::Bag")
$expr->isa("Zuzu::AST::Expr::Array") $expr->isa("Zuzu::AST::Expr::Set") $expr->isa("Zuzu::AST::Expr::Bag")
Truth table25%1/4
A or B or C
A= $expr->isa("Zuzu::AST::Expr::Array")B= $expr->isa("Zuzu::AST::Expr::Set")C= $expr->isa("Zuzu::AST::Expr::Bag")
ABCresult
1XX1
01X1
0011
0000
674 $expr->isa('Zuzu::AST::Expr::Array')
675 or $expr->isa('Zuzu::AST::Expr::Set')
676 or $expr->isa('Zuzu::AST::Expr::Bag')
677 ) {
678 0 ▶ for my $item ( @{ $expr->items // [] } ) {
Condition0%0/2
$expr->items // []
l!l
00
MC/DC0%0/1
$expr->items // []
$expr->items
Truth table0%0/2
A
A= $expr->items
Aresult
11
00
679 0 _collect_free_names_from_expr( $item, $bound, $free );
680 }
681 0 return;
682 }
683 2 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Dict") or $expr->isa("Zuzu::AST::Expr::PairList")) 2 0 2
Condition33%1/3
$expr->isa("Zuzu::AST::Expr::Dict") or $expr->isa("Zuzu::AST::Expr::PairList")
l!l&&r!l&&!r
200
MC/DC0%0/2
$expr->isa("Zuzu::AST::Expr::Dict") or $expr->isa("Zuzu::AST::Expr::PairList")
$expr->isa("Zuzu::AST::Expr::Dict") $expr->isa("Zuzu::AST::Expr::PairList")
Truth table33%1/3
A or B
A= $expr->isa("Zuzu::AST::Expr::Dict")B= $expr->isa("Zuzu::AST::Expr::PairList")
ABresult
1X1
011
000
684 $expr->isa('Zuzu::AST::Expr::Dict')
685 or $expr->isa('Zuzu::AST::Expr::PairList')
686 ) {
687 2 ▶ for my $pair ( @{ $expr->pairs // [] } ) {
Condition50%1/2
$expr->pairs // []
l!l
20
MC/DC0%0/1
$expr->pairs // []
$expr->pairs
Truth table50%1/2
A
A= $expr->pairs
Aresult
11
00
688 2 _collect_free_names_from_expr( $pair->[0], $bound, $free );
689 2 _collect_free_names_from_expr( $pair->[1], $bound, $free );
690 }
691 2 return;
692 }
693 0 ▶ if ( $expr->isa('Zuzu::AST::Expr::Range') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($expr->isa("Zuzu::AST::Expr::Range")) 0 0 0
694 0 _collect_free_names_from_expr( $expr->start, $bound, $free );
695 0 _collect_free_names_from_expr( $expr->end, $bound, $free );
696 0 return;
697 }
698  
699 0 die "Unsupported expression for capture analysis: " . ref($expr);
700 }
701  
702 0 ▶sub _function_expr_bindings {
Subroutine _function_expr_bindings: not called CC=4 SCAR=30.0
703 0 my ( $expr ) = @_;
704  
705 0 ▶ my %bound = map { $_ => 1 } @{ $expr->params // [] };
Condition0%0/2
$expr->params // []
l!l
00
MC/DC0%0/1
$expr->params // []
$expr->params
Truth table0%0/2
A
A= $expr->params
Aresult
11
00
706 0 ▶ $bound{ $expr->vararg } = 1 if defined $expr->vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $expr->vararg 0 0 0
707 0 ▶ $bound{ $expr->named_vararg } = 1 if defined $expr->named_vararg;
Branch: 1 branch
BranchTrueFalseTotal
if defined $expr->named_vararg 0 0 0
708 0 $bound{__argc__} = 1;
709  
710 0 return %bound;
711 }
712  
713 2 ▶sub _collect_free_names_from_args {
Subroutine _collect_free_names_from_args: called CC=4 SCAR=14.0
714 2 my ( $args, $bound, $free ) = @_;
715  
716 2 ▶ for my $arg ( @{ $args // [] } ) {
Condition50%1/2
$args // []
l!l
20
MC/DC0%0/1
$args // []
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
717 2 my ( $name, $value, $dynamic ) = @{ $arg };
718 2 ▶ _collect_free_names_from_expr( $name, $bound, $free )
Branch: 1 branch
BranchTrueFalseTotal
if $dynamic 0 2 2
719 if $dynamic;
720 2 _collect_free_names_from_expr( $value, $bound, $free );
721 }
722  
723 2 return;
724 }
725  
726 0 ▶sub _collect_import_bound_names {
Subroutine _collect_import_bound_names: not called CC=4 SCAR=30.0
727 0 my ( $stmt, $bound ) = @_;
728  
729 0 ▶ for my $item ( @{ $stmt->items // [] } ) {
Condition0%0/2
$stmt->items // []
l!l
00
MC/DC0%0/1
$stmt->items // []
$stmt->items
Truth table0%0/2
A
A= $stmt->items
Aresult
11
00
730 0 ▶ next if $item->{star};
Branch: 1 branch
BranchTrueFalseTotal
if $item->{"star"} 0 0 0
731 0 $bound->{ $item->{alias} } = 1;
732 }
733  
734 0 return;
735 }
736  
737 5 ▶sub _is_builtin_name {
Subroutine _is_builtin_name: called CC=2 SCAR=7.2
738 5 my ( $runtime, $name ) = @_;
739  
740 5 ▶ return $runtime->{_builtin_global_names}{$name} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$runtime->{'_builtin_global_names'}{$name} ? : 0 5 5
741 }
742  
743 5 ▶sub _find_function_binding {
Subroutine _find_function_binding: called CC=5 SCAR=17.8
744 5 my ( $fn, $name ) = @_;
745  
746 5 my $env = $fn->closure_env;
747 5 ▶ while ($env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env) 5 0 5
748 5 ▶ if ( exists $env->slots->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $env->slots->{$name}) 5 0 5
749 return {
750 ref => $env->slots->{$name},
751 const => $env->const->{$name} ? 1 : 0,
752 5 ▶ type => $env->types->{$name} // 'Any',
Branch: 1 branch
BranchTrueFalseTotal
$env->const->{$name} ? : 4 1 5
Condition50%1/2
$env->types->{$name} // "Any"
l!l
50
MC/DC0%0/1
$env->types->{$name} // "Any"
$env->types->{$name}
Truth table50%1/2
A
A= $env->types->{$name}
Aresult
11
00
753 };
754 }
755 0 $env = $env->parent;
756 }
757  
758 0 return undef;
759 }
760  
761 0 ▶sub _find_class_binding {
Subroutine _find_class_binding: not called CC=5 SCAR=34.0
762 0 my ( $class_value, $name ) = @_;
763  
764 0 my $env = $class_value->closure_env;
765 0 ▶ while ($env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env) 0 0 0
766 0 ▶ if ( exists $env->slots->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $env->slots->{$name}) 0 0 0
767 return {
768 ref => $env->slots->{$name},
769 const => $env->const->{$name} ? 1 : 0,
770 0 ▶ type => $env->types->{$name} // 'Any',
Branch: 1 branch
BranchTrueFalseTotal
$env->const->{$name} ? : 0 0 0
Condition0%0/2
$env->types->{$name} // "Any"
l!l
00
MC/DC0%0/1
$env->types->{$name} // "Any"
$env->types->{$name}
Truth table0%0/2
A
A= $env->types->{$name}
Aresult
11
00
771 };
772 }
773 0 $env = $env->parent;
774 }
775  
776 0 return undef;
777 }
778  
779 0 ▶sub _find_trait_binding {
Subroutine _find_trait_binding: not called CC=5 SCAR=34.0
780 0 my ( $trait_value, $name ) = @_;
781  
782 0 my $env = $trait_value->closure_env;
783 0 ▶ while ($env) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env) 0 0 0
784 0 ▶ if ( exists $env->slots->{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $env->slots->{$name}) 0 0 0
785 return {
786 ref => $env->slots->{$name},
787 const => $env->const->{$name} ? 1 : 0,
788 0 ▶ type => $env->types->{$name} // 'Any',
Branch: 1 branch
BranchTrueFalseTotal
$env->const->{$name} ? : 0 0 0
Condition0%0/2
$env->types->{$name} // "Any"
l!l
00
MC/DC0%0/1
$env->types->{$name} // "Any"
$env->types->{$name}
Truth table0%0/2
A
A= $env->types->{$name}
Aresult
11
00
789 };
790 }
791 0 $env = $env->parent;
792 }
793  
794 0 return undef;
795 }
796  
797 5 ▶sub _external_std_dependency {
Subroutine _external_std_dependency: called CC=10 SCAR=24.5
798 5 my ( $runtime, $local_name, $ref ) = @_;
799  
800 5 ▶ return undef if !defined $runtime or !defined $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $runtime and defined $ref 0 5 5
Condition33%1/3
defined $runtime and defined $ref
!ll&&!rl&&r
005
MC/DC0%0/2
defined $runtime and defined $ref
defined $runtime defined $ref
Truth table33%1/3
A and B
A= defined $runtimeB= defined $ref
ABresult
0X0
100
111
801  
802 5 ▶ for my $module ( sort keys %{ $runtime->{_modules} // {} } ) {
Condition50%1/2
$runtime->{"_modules"} // {}
l!l
50
MC/DC0%0/1
$runtime->{"_modules"} // {}
$runtime->{"_modules"}
Truth table50%1/2
A
A= $runtime->{"_modules"}
Aresult
11
00
803 1 ▶ next if $module !~ m{\Astd/};
Branch: 1 branch
BranchTrueFalseTotal
unless $module =~ m[\Astd/] 0 1 1
804 1 ▶ my $exports = $runtime->{_module_exports}{$module} // {};
Condition50%1/2
$runtime->{"_module_exports"}{$module} // {}
l!l
10
MC/DC0%0/1
$runtime->{"_module_exports"}{$module} // {}
$runtime->{"_module_exports"}{$module}
Truth table50%1/2
A
A= $runtime->{"_module_exports"}{$module}
Aresult
11
00
805 1 my $env = $runtime->{_modules}{$module};
806 1 for my $export_name ( sort keys %{ $exports } ) {
807 2 ▶ next if !exists $env->slots->{$export_name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $env->slots->{$export_name} 0 2 2
808 2 ▶ next if $env->slots->{$export_name} != $ref;
Branch: 1 branch
BranchTrueFalseTotal
if $env->slots->{$export_name} != $ref 1 1 2
809 return {
810 1 local_name => $local_name,
811 module => $module,
812 export_name => $export_name,
813 };
814 }
815 }
816  
817 4 return undef;
818 }
819  
820 4 ▶sub _is_internal_dependency_value {
Subroutine _is_internal_dependency_value: called CC=7 SCAR=20.0
821 4 my ( $value ) = @_;
822  
823 4 ▶ return 1 if blessed($value) and $value->isa('Zuzu::Value::Function');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::Function") 1 3 4
Condition100%3/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
!ll&&!rl&&r
211
MC/DC100%2/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
builtin::blessed($value) $value->isa("Zuzu::Value::Function")
Truth table100%3/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
824 3 ▶ return 1 if blessed($value) and $value->isa('Zuzu::Value::Class');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::Class") 0 3 3
Condition66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Class")
!ll&&!rl&&r
210
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Class")
builtin::blessed($value) $value->isa("Zuzu::Value::Class")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
825 3 ▶ return 1 if blessed($value) and $value->isa('Zuzu::Value::Trait');
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::Trait") 0 3 3
Condition66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
210
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")
builtin::blessed($value) $value->isa("Zuzu::Value::Trait")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
826 3 return 0;
827 }
828  
829 2 ▶sub _is_scalar_capture_value {
Subroutine _is_scalar_capture_value: called CC=3 SCAR=11.0
830 2 my ( $runtime, $value ) = @_;
831  
832 2 ▶ return 0 if !_is_scalar_type( $runtime, $value );
Branch: 1 branch
BranchTrueFalseTotal
unless _is_scalar_type($runtime, $value) 1 1 2
833 1 ▶ return eval {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { _encode_scalar_value($runtime, $value); 1 } } ? : 1 0 1
834 1 _encode_scalar_value( $runtime, $value );
835 1 1;
836 } ? 1 : 0;
837 }
838  
839 2 ▶sub _class_declaration_source {
Subroutine _class_declaration_source: called CC=6 SCAR=21.4
840 2 my ( $runtime, $class_value ) = @_;
841  
842 2 ▶ die "Class source extraction expects a Class value"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($class_value) and $class_value->isa("Zuzu::Value::Class") 0 2 2
Condition33%1/3
builtin::blessed($class_value) and $class_value->isa("Zuzu::Value::Class")
!ll&&!rl&&r
002
MC/DC0%0/2
builtin::blessed($class_value) and $class_value->isa("Zuzu::Value::Class")
builtin::blessed($class_value) $class_value->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($class_value)B= $class_value->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
843 if !blessed($class_value) or !$class_value->isa('Zuzu::Value::Class');
844 2 ▶ die "Native classes do not have ZuzuScript source"
Branch: 1 branch
BranchTrueFalseTotal
if $class_value->native_constructor or $class_value->builtin_kind 0 2 2
Condition33%1/3
$class_value->native_constructor or $class_value->builtin_kind
l!l&&r!l&&!r
002
MC/DC0%0/2
$class_value->native_constructor or $class_value->builtin_kind
$class_value->native_constructor $class_value->builtin_kind
Truth table33%1/3
A or B
A= $class_value->native_constructorB= $class_value->builtin_kind
ABresult
1X1
011
000
845 if $class_value->native_constructor or $class_value->builtin_kind;
846 2 ▶ die "Class value has no AST declaration for source extraction"
Branch: 1 branch
BranchTrueFalseTotal
unless $class_value->source_node 0 2 2
847 if !$class_value->source_node;
848  
849 2 return _source_class_decl( $class_value->source_node );
850 }
851  
852 0 ▶sub _trait_declaration_source {
Subroutine _trait_declaration_source: not called CC=4 SCAR=30.0
853 0 my ( $runtime, $trait_value ) = @_;
854  
855 0 ▶ die "Trait source extraction expects a Trait value"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($trait_value) and $trait_value->isa("Zuzu::Value::Trait") 0 0 0
Condition0%0/3
builtin::blessed($trait_value) and $trait_value->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($trait_value) and $trait_value->isa("Zuzu::Value::Trait")
builtin::blessed($trait_value) $trait_value->isa("Zuzu::Value::Trait")
Truth table0%0/3
A and B
A= builtin::blessed($trait_value)B= $trait_value->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
856 if !blessed($trait_value) or !$trait_value->isa('Zuzu::Value::Trait');
857 0 ▶ die "Trait value has no AST declaration for source extraction"
Branch: 1 branch
BranchTrueFalseTotal
unless $trait_value->source_node 0 0 0
858 if !$trait_value->source_node;
859  
860 0 return _source_trait_decl( $trait_value->source_node );
861 }
862  
863 2 ▶sub _source_class_decl {
Subroutine _source_class_decl: called CC=9 SCAR=24.7
864 2 my ( $node ) = @_;
865  
866 2 my $source = 'class ' . $node->name;
867 2 ▶ $source .= ' extends ' . _source_expr( $node->parent )
Branch: 1 branch
BranchTrueFalseTotal
if defined $node->parent 0 2 2
868 if defined $node->parent;
869 2 ▶ if ( @{ $node->traits // [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$node->traits // [];}) 0 2 2
Condition50%1/2
$node->traits // []
l!l
20
MC/DC0%0/1
$node->traits // []
$node->traits
Truth table50%1/2
A
A= $node->traits
Aresult
11
00
870 $source .= ' with ' . join(
871 ', ',
872 0 map { _source_expr($_) } @{ $node->traits },
873 );
874 }
875  
876 2 my @members;
877 2 ▶ push @members, map { _source_field_decl($_) } @{ $node->fields // [] };
Condition50%1/2
$node->fields // []
l!l
20
MC/DC0%0/1
$node->fields // []
$node->fields
Truth table50%1/2
A
A= $node->fields
Aresult
11
00
878 push @members, map {
879 0 _source_method_decl($_)
880 } grep {
881 !$_->{_generated_field_accessor}
882 2 ▶ } @{ $node->methods // [] };
Condition50%1/2
$node->methods // []
l!l
20
MC/DC0%0/1
$node->methods // []
$node->methods
Truth table50%1/2
A
A= $node->methods
Aresult
11
00
883 push @members, map {
884 0 _source_method_decl( $_, 1 )
885 2 ▶ } @{ $node->static_methods // [] };
Condition50%1/2
$node->static_methods // []
l!l
20
MC/DC0%0/1
$node->static_methods // []
$node->static_methods
Truth table50%1/2
A
A= $node->static_methods
Aresult
11
00
886 0 ▶ push @members, map { _source_class_decl($_) } @{ $node->classes // [] };
Condition50%1/2
$node->classes // []
l!l
20
MC/DC0%0/1
$node->classes // []
$node->classes
Truth table50%1/2
A
A= $node->classes
Aresult
11
00
887  
888 2 ▶ return $source . ';' if !@members;
Branch: 1 branch
BranchTrueFalseTotal
unless @members 1 1 2
889 1 return $source . ' { ' . join( ' ', @members ) . ' }';
890 }
891  
892 0 ▶sub _source_trait_decl {
Subroutine _source_trait_decl: not called CC=3 SCAR=24.8
893 0 my ( $node ) = @_;
894  
895 0 my $source = 'trait ' . $node->name;
896 0 ▶ my @members = map { _source_method_decl($_) } @{ $node->methods // [] };
Condition0%0/2
$node->methods // []
l!l
00
MC/DC0%0/1
$node->methods // []
$node->methods
Truth table0%0/2
A
A= $node->methods
Aresult
11
00
897  
898 0 ▶ return $source . ';' if !@members;
Branch: 1 branch
BranchTrueFalseTotal
unless @members 0 0 0
899 0 return $source . ' { ' . join( ' ', @members ) . ' }';
900 }
901  
902 1 ▶sub _source_field_decl {
Subroutine _source_field_decl: called CC=6 SCAR=18.7
903 1 my ( $field ) = @_;
904  
905 1 ▶ my $kw = $field->{is_const} ? 'const' : 'let';
Branch: 1 branch
BranchTrueFalseTotal
$field->{'is_const'} ? : 0 1 1
906 my $name = _source_typed_name(
907 $field->{declared_type},
908 $field->{name},
909 1 'Any',
910 );
911 1 my $source = "$kw $name";
912 1 ▶ if ( @{ $field->{accessors} // [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$field->{"accessors"} // [];}) 1 0 1
Condition50%1/2
$field->{"accessors"} // []
l!l
10
MC/DC0%0/1
$field->{"accessors"} // []
$field->{"accessors"}
Truth table50%1/2
A
A= $field->{"accessors"}
Aresult
11
00
913 1 $source .= ' with ' . join( ', ', @{ $field->{accessors} } );
914 }
915 $source .= ' := ' . _source_expr( $field->{init} )
916 1 ▶ if defined $field->{init};
Branch: 1 branch
BranchTrueFalseTotal
if defined $field->{"init"} 0 1 1
917 1 ▶ $source .= ' but weak' if $field->{is_weak_storage};
Branch: 1 branch
BranchTrueFalseTotal
if $field->{"is_weak_storage"} 1 0 1
918  
919 1 return $source . ';';
920 }
921  
922 0 ▶sub _source_method_decl {
Subroutine _source_method_decl: not called CC=6 SCAR=37.4
923 0 my ( $method, $force_static ) = @_;
924  
925 0 my $source = '';
926 0 ▶ $source .= 'async ' if $method->is_async;
Branch: 1 branch
BranchTrueFalseTotal
if $method->is_async 0 0 0
927 0 ▶ $source .= 'static ' if $force_static || $method->is_static;
Branch: 1 branch
BranchTrueFalseTotal
if $force_static or $method->is_static 0 0 0
Condition0%0/3
$force_static or $method->is_static
l!l&&r!l&&!r
000
MC/DC0%0/2
$force_static or $method->is_static
$force_static $method->is_static
Truth table0%0/3
A or B
A= $force_staticB= $method->is_static
ABresult
1X1
011
000
928 0 $source .= 'method ' . $method->name . ' ('
929 . _source_param_list($method)
930 . ')';
931 0 ▶ my $return_type = $method->return_type // 'Any';
Condition0%0/2
$method->return_type // "Any"
l!l
00
MC/DC0%0/1
$method->return_type // "Any"
$method->return_type
Truth table0%0/2
A
A= $method->return_type
Aresult
11
00
932 0 ▶ $source .= ' -> ' . $return_type if $return_type ne 'Any';
Branch: 1 branch
BranchTrueFalseTotal
if $return_type ne "Any" 0 0 0
933 0 $source .= ' ' . _source_block( $method->body );
934  
935 0 return $source;
936 }
937  
938 9 ▶sub _source_param_list {
Subroutine _source_param_list: called CC=10 SCAR=26.2
939 9 my ( $fn ) = @_;
940  
941 9 my @params;
942 9 ▶ for my $name ( @{ $fn->params // [] } ) {
Condition50%1/2
$fn->params // []
l!l
90
MC/DC0%0/1
$fn->params // []
$fn->params
Truth table50%1/2
A
A= $fn->params
Aresult
11
00
943 7 ▶ my $type = $fn->param_types->{$name} // 'Any';
Condition50%1/2
$fn->param_types->{$name} // "Any"
l!l
70
MC/DC0%0/1
$fn->param_types->{$name} // "Any"
$fn->param_types->{$name}
Truth table50%1/2
A
A= $fn->param_types->{$name}
Aresult
11
00
944 7 ▶ my $param = $type eq 'Any' ? $name : "$type $name";
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'Any' ? : 6 1 7
945 7 ▶ if ( $fn->param_optional->{$name} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($fn->param_optional->{$name}) { } 0 7 7
elsif (exists $fn->param_defaults->{$name}) { } 0 7 7
946 0 $param .= '?';
947 }
948 elsif ( exists $fn->param_defaults->{$name} ) {
949 0 $param .= ' := ' . _source_expr( $fn->param_defaults->{$name} );
950 }
951 7 push @params, $param;
952 }
953  
954 9 my @collectors;
955 9 ▶ if ( defined $fn->vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fn->vararg) 0 9 9
956 0 push @collectors, _source_typed_name(
957 $fn->vararg_type,
958 $fn->vararg,
959 'Array',
960 );
961 }
962 9 ▶ if ( defined $fn->named_vararg ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fn->named_vararg) 0 9 9
963 0 push @collectors, _source_typed_name(
964 $fn->named_vararg_type,
965 $fn->named_vararg,
966 'PairList',
967 );
968 }
969 9 ▶ push @params, '... ' . join( ', ', @collectors ) if @collectors;
Branch: 1 branch
BranchTrueFalseTotal
if @collectors 0 9 9
970  
971 9 return join( ', ', @params );
972 }
973  
974 1 ▶sub _source_typed_name {
Subroutine _source_typed_name: called CC=4 SCAR=17.1
975 1 my ( $type, $name, $implicit_type ) = @_;
976  
977 1 ▶ $type //= 'Any';
Condition50%1/2
$type //= "Any"
l!l
10
MC/DC0%0/1
$type //= "Any"
$type
Truth table50%1/2
A
A= $type
Aresult
11
00
978 1 ▶ return $name if $type eq 'Any' or $type eq $implicit_type;
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Any" or $type eq $implicit_type 1 0 1
Condition33%1/3
$type eq "Any" or $type eq $implicit_type
l!l&&r!l&&!r
100
MC/DC0%0/2
$type eq "Any" or $type eq $implicit_type
$type eq "Any" $type eq $implicit_type
Truth table33%1/3
A or B
A= $type eq "Any"B= $type eq $implicit_type
ABresult
1X1
011
000
979 0 return "$type $name";
980 }
981  
982 9 ▶sub _source_block {
Subroutine _source_block: called CC=3 SCAR=11.2
983 9 my ( $block ) = @_;
984  
985 my @statements = map {
986 9 _source_stmt($_)
987 9 ▶ } @{ $block->statements // [] };
Condition50%1/2
$block->statements // []
l!l
90
MC/DC0%0/1
$block->statements // []
$block->statements
Truth table50%1/2
A
A= $block->statements
Aresult
11
00
988 9 ▶ return '{}' if !@statements;
Branch: 1 branch
BranchTrueFalseTotal
unless @statements 0 9 9
989  
990 9 return '{ ' . join( ' ', @statements ) . ' }';
991 }
992  
993 9 ▶sub _source_stmt {
Subroutine _source_stmt: called CC=28 SCAR=65.6
994 9 my ( $stmt ) = @_;
995  
996 9 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Return') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Return")) 9 0 9
997 9 ▶ return defined $stmt->expr
Branch: 1 branch
BranchTrueFalseTotal
defined $stmt->expr ? : 9 0 9
998 ? 'return ' . _source_expr( $stmt->expr ) . ';'
999 : 'return;';
1000 }
1001 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Expr') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Expr")) 0 0 0
1002 0 return _source_expr( $stmt->expr ) . ';';
1003 }
1004 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Let') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Let")) 0 0 0
1005 0 ▶ my $kw = $stmt->is_const ? 'const' : 'let';
Branch: 1 branch
BranchTrueFalseTotal
$stmt->is_const ? : 0 0 0
1006 0 my $name = _source_typed_name(
1007 $stmt->declared_type,
1008 $stmt->name,
1009 'Any',
1010 );
1011 0 my $source = "$kw $name";
1012 0 ▶ $source .= ' := ' . _source_expr( $stmt->init )
Branch: 1 branch
BranchTrueFalseTotal
if defined $stmt->init 0 0 0
1013 if defined $stmt->init;
1014 0 ▶ $source .= ' but weak' if $stmt->is_weak_storage;
Branch: 1 branch
BranchTrueFalseTotal
if $stmt->is_weak_storage 0 0 0
1015 0 return $source . ';';
1016 }
1017 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Assign') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Assign")) 0 0 0
1018 0 ▶ if ( ( $stmt->op // '' ) eq '~=' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($stmt->op // "") eq "~=") 0 0 0
Condition0%0/2
$stmt->op // ""
l!l
00
MC/DC0%0/1
$stmt->op // ""
$stmt->op
Truth table0%0/2
A
A= $stmt->op
Aresult
11
00
1019 0 return join(
1020 ' ',
1021 _source_expr( $stmt->target ),
1022 '~=',
1023 _source_expr( $stmt->match_expr ),
1024 '->',
1025 _source_expr( $stmt->replace_expr ) . ';',
1026 );
1027 }
1028 0 ▶ return join(
Branch: 1 branch
BranchTrueFalseTotal
$stmt->is_weak_write ? : 0 0 0
1029 ' ',
1030 _source_expr( $stmt->target ),
1031 $stmt->op,
1032 _source_expr( $stmt->expr )
1033 . ( $stmt->is_weak_write ? ' but weak' : '' )
1034 . ';',
1035 );
1036 }
1037 0 ▶ if ( $stmt->isa('Zuzu::AST::Block') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Block")) 0 0 0
1038 0 return _source_block($stmt);
1039 }
1040 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::If') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::If")) 0 0 0
1041 0 my $source = 'if (' . _source_expr( $stmt->cond ) . ') '
1042 . _source_block( $stmt->then_block );
1043 0 ▶ $source .= ' else ' . _source_else_branch( $stmt->else_branch )
Branch: 1 branch
BranchTrueFalseTotal
if $stmt->else_branch 0 0 0
1044 if $stmt->else_branch;
1045 0 return $source;
1046 }
1047 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::While') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::While")) 0 0 0
1048 0 return 'while (' . _source_expr( $stmt->cond ) . ') '
1049 . _source_block( $stmt->body );
1050 }
1051 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Die') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Die")) 0 0 0
1052 0 return 'die ' . _source_expr( $stmt->expr ) . ';';
1053 }
1054 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Throw') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Throw")) 0 0 0
1055 0 return 'throw ' . _source_expr( $stmt->expr ) . ';';
1056 }
1057 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Import') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Import")) 0 0 0
1058 0 my $source = 'from ' . $stmt->module . ' ';
1059 0 ▶ $source .= 'try ' if $stmt->try_mode;
Branch: 1 branch
BranchTrueFalseTotal
if $stmt->try_mode 0 0 0
1060 0 $source .= 'import ';
1061 $source .= join(
1062 ', ',
1063 map {
1064 0 ▶ if ( $_->{star} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_->{'star'}) { } 0 0 0
elsif ($_->{'alias'} ne $_->{'name'}) { } 0 0 0
1065 0 '*';
1066 }
1067 elsif ( $_->{alias} ne $_->{name} ) {
1068 0 $_->{name} . ' as ' . $_->{alias};
1069 }
1070 else {
1071 0 $_->{name};
1072 }
1073 0 ▶ } @{ $stmt->items // [] },
Condition0%0/2
$stmt->items // []
l!l
00
MC/DC0%0/1
$stmt->items // []
$stmt->items
Truth table0%0/2
A
A= $stmt->items
Aresult
11
00
1074 );
1075 0 ▶ if ( defined $stmt->condition_expr ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $stmt->condition_expr) 0 0 0
1076 0 ▶ $source .= $stmt->condition_positive ? ' if ' : ' unless ';
Branch: 1 branch
BranchTrueFalseTotal
$stmt->condition_positive ? : 0 0 0
1077 0 $source .= _source_expr( $stmt->condition_expr );
1078 }
1079 0 return $source . ';';
1080 }
1081 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Next') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Next")) 0 0 0
1082 0 return 'next;';
1083 }
1084 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Last') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Last")) 0 0 0
1085 0 return 'last;';
1086 }
1087 0 ▶ if ( $stmt->isa('Zuzu::AST::Stmt::Continue') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stmt->isa("Zuzu::AST::Stmt::Continue")) 0 0 0
1088 0 return 'continue;';
1089 }
1090  
1091 0 die "Unsupported function body statement for source extraction: "
1092 . ref($stmt);
1093 }
1094  
1095 0 ▶sub _source_else_branch {
Subroutine _source_else_branch: not called CC=3 SCAR=24.8
1096 0 my ( $branch ) = @_;
1097  
1098 0 ▶ return _source_block($branch) if $branch->isa('Zuzu::AST::Block');
Branch: 1 branch
BranchTrueFalseTotal
if $branch->isa("Zuzu::AST::Block") 0 0 0
1099 0 ▶ return _source_stmt($branch) if $branch->isa('Zuzu::AST::Stmt::If');
Branch: 1 branch
BranchTrueFalseTotal
if $branch->isa("Zuzu::AST::Stmt::If") 0 0 0
1100 0 die "Unsupported else branch for source extraction: " . ref($branch);
1101 }
1102  
1103 29 ▶sub _source_expr {
Subroutine _source_expr: called CC=76 SCAR=72.7
1104 29 my ( $expr, $parent_prec, $side ) = @_;
1105  
1106 29 ▶ $parent_prec //= 0;
Condition100%2/2
$parent_prec //= 0
l!l
1316
MC/DC100%1/1
$parent_prec //= 0
$parent_prec
Truth table100%2/2
A
A= $parent_prec
Aresult
11
00
1107 29 ▶ $side //= '';
Condition100%2/2
$side //= ""
l!l
1019
MC/DC100%1/1
$side //= ""
$side
Truth table100%2/2
A
A= $side
Aresult
11
00
1108  
1109 29 ▶ die "Missing expression for source extraction" if !defined $expr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $expr 0 29 29
1110  
1111 29 my $source;
1112 29 my $prec = 100;
1113 29 ▶ if ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Literal') ) {
Branch: 21 branches
BranchTrueFalseTotal
if (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Literal')) { } 7 22 29
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Var')) { } 12 10 22
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::TypeRef')) { } 0 10 10
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Binary')) { } 5 5 10
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Unary')) { } 0 5 5
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Ternary')) { } 0 5 5
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Call')) { } 1 4 5
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::MemberCall')) { } 0 4 4
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::DynamicMemberCall')) { } 0 4 4
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Index')) { } 1 3 4
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Slice')) { } 0 3 3
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::DictGet')) { } 0 3 3
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Array')) { } 0 3 3
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Dict')) { } 2 1 3
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::PairList')) { } 0 1 1
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Set')) { } 0 1 1
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Bag')) { } 0 1 1
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Range')) { } 0 1 1
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::New')) { } 1 0 1
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Function')) { } 0 0 0
elsif (builtin::blessed($expr) and $expr->isa('Zuzu::AST::Expr::Await')) { } 0 0 0
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Literal")
!ll&&!rl&&r
0227
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Literal")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Literal")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Literal")
ABresult
0X0
100
111
1114 7 $source = _source_literal( $expr->value );
1115 }
1116 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Var') ) {
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
!ll&&!rl&&r
01012
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Var")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Var")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Var")
ABresult
0X0
100
111
1117 12 $source = $expr->name;
1118 }
1119 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::TypeRef') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::TypeRef")
!ll&&!rl&&r
0100
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::TypeRef")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::TypeRef")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::TypeRef")
ABresult
0X0
100
111
1120 0 $source = $expr->root;
1121 0 ▶ $source .= '.' . $expr->member if defined $expr->member;
Branch: 1 branch
BranchTrueFalseTotal
if defined $expr->member 0 0 0
1122 }
1123 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Binary') ) {
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Binary")
!ll&&!rl&&r
055
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Binary")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Binary")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Binary")
ABresult
0X0
100
111
1124 5 $prec = _source_binary_prec( $expr->op );
1125 5 ▶ my $right_parent_prec =
Branch: 1 branch
BranchTrueFalseTotal
$expr->op eq '**' || $expr->op eq "\x{25c1}" || $expr->op eq '<|' || $expr->op eq 'onlyif' || $expr->op eq "\x{22a8}" || $expr->op eq 'onlyif?' || $expr->op eq "\x{22a8}?" ? : 0 5 5
Condition33%6/18
$expr->op eq "**" or $expr->op eq "\x{25c1}" or $expr->op eq "<|" or $expr->op eq "onlyif" or $expr->op eq "\x{22a8}" or $expr->op eq "onlyif?" or $expr->op eq "\x{22a8}?"
l!l&&r!l&&!r
005
$expr->op eq "**" or $expr->op eq "\x{25c1}" or $expr->op eq "<|" or $expr->op eq "onlyif" or $expr->op eq "\x{22a8}" or $expr->op eq "onlyif?"
l!l&&r!l&&!r
005
$expr->op eq "**" or $expr->op eq "\x{25c1}" or $expr->op eq "<|" or $expr->op eq "onlyif" or $expr->op eq "\x{22a8}"
l!l&&r!l&&!r
005
$expr->op eq "**" or $expr->op eq "\x{25c1}" or $expr->op eq "<|" or $expr->op eq "onlyif"
l!l&&r!l&&!r
005
$expr->op eq "**" or $expr->op eq "\x{25c1}" or $expr->op eq "<|"
l!l&&r!l&&!r
005
$expr->op eq "**" or $expr->op eq "\x{25c1}"
l!l&&r!l&&!r
005
MC/DC0%0/7
$expr->op eq "**" or $expr->op eq "\x{25c1}" or $expr->op eq "<|" or $expr->op eq "onlyif" or $expr->op eq "\x{22a8}" or $expr->op eq "onlyif?" or $expr->op eq "\x{22a8}?"
$expr->op eq "**" $expr->op eq "\x{25c1}" $expr->op eq "<|" $expr->op eq "onlyif" $expr->op eq "\x{22a8}" $expr->op eq "onlyif?" $expr->op eq "\x{22a8}?"
Truth table12%1/8
A or B or C or D or E or F or G
A= $expr->op eq "**"B= $expr->op eq "\x{25c1}"C= $expr->op eq "<|"D= $expr->op eq "onlyif"E= $expr->op eq "\x{22a8}"F= $expr->op eq "onlyif?"G= $expr->op eq "\x{22a8}?"
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
000001X1
00000011
00000000
1126 (
1127 $expr->op eq '**'
1128 or $expr->op eq '◁'
1129 or $expr->op eq '<|'
1130 or $expr->op eq 'onlyif'
1131 or $expr->op eq '⊨'
1132 or $expr->op eq 'onlyif?'
1133 or $expr->op eq '⊨?'
1134 )
1135 ? $prec - 1
1136 : $prec;
1137 5 $source = join(
1138 ' ',
1139 _source_expr( $expr->left, $prec, 'left' ),
1140 $expr->op,
1141 _source_expr( $expr->right, $right_parent_prec, 'right' ),
1142 );
1143 }
1144 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Unary') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Unary")
!ll&&!rl&&r
050
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Unary")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Unary")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Unary")
ABresult
0X0
100
111
1145 0 $prec = 90;
1146 0 my $op = $expr->op;
1147 0 ▶ if ( $op =~ /\A[A-Za-z_]\w*\z/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($op =~ /\A[A-Za-z_]\w*\z/) { } 0 0 0
1148 0 $source = $op . ' ' . _source_expr( $expr->expr, $prec );
1149 }
1150 else {
1151 0 $source = $op . _source_expr( $expr->expr, $prec );
1152 }
1153 }
1154 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Ternary') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Ternary")
!ll&&!rl&&r
050
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Ternary")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Ternary")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Ternary")
ABresult
0X0
100
111
1155 0 $prec = 1;
1156 0 ▶ if ( defined $expr->if_true ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $expr->if_true) { } 0 0 0
1157 0 $source = _source_expr( $expr->cond, $prec )
1158 . ' ? '
1159 . _source_expr( $expr->if_true )
1160 . ' : '
1161 . _source_expr( $expr->if_false );
1162 }
1163 else {
1164 0 $source = _source_expr( $expr->cond, $prec )
1165 . ' ?: '
1166 . _source_expr( $expr->if_false );
1167 }
1168 }
1169 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Call') ) {
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Call")
!ll&&!rl&&r
041
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Call")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Call")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Call")
ABresult
0X0
100
111
1170 1 $source = _source_expr( $expr->callee, 95 )
1171 . '('
1172 . _source_args( $expr->args )
1173 . ')';
1174 }
1175 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::MemberCall') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::MemberCall")
!ll&&!rl&&r
040
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::MemberCall")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::MemberCall")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::MemberCall")
ABresult
0X0
100
111
1176 0 $source = _source_expr( $expr->object, 95 )
1177 . '.'
1178 . $expr->method
1179 . '('
1180 . _source_args( $expr->args )
1181 . ')';
1182 }
1183 ▶ elsif (
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::DynamicMemberCall")
!ll&&!rl&&r
040
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::DynamicMemberCall")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::DynamicMemberCall")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::DynamicMemberCall")
ABresult
0X0
100
111
1184 blessed($expr)
1185 and $expr->isa('Zuzu::AST::Expr::DynamicMemberCall')
1186 ) {
1187 0 $source = _source_expr( $expr->object, 95 )
1188 . '.('
1189 . _source_expr( $expr->method_expr )
1190 . ')('
1191 . _source_args( $expr->args )
1192 . ')';
1193 }
1194 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Index') ) {
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Index")
!ll&&!rl&&r
031
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Index")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Index")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Index")
ABresult
0X0
100
111
1195 1 $source = _source_expr( $expr->array, 95 )
1196 . '['
1197 . _source_expr( $expr->index )
1198 . ']';
1199 }
1200 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Slice') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Slice")
!ll&&!rl&&r
030
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Slice")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Slice")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Slice")
ABresult
0X0
100
111
1201 0 ▶ $source = _source_expr( $expr->collection, 95 )
Branch: 2 branches
BranchTrueFalseTotal
defined $expr->start ? : 0 0 0
defined $expr->length ? : 0 0 0
1202 . '['
1203 . ( defined $expr->start ? _source_expr( $expr->start ) : '' )
1204 . ':'
1205 . ( defined $expr->length ? _source_expr( $expr->length ) : '' )
1206 . ']';
1207 }
1208 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::DictGet') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::DictGet")
!ll&&!rl&&r
030
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::DictGet")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::DictGet")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::DictGet")
ABresult
0X0
100
111
1209 0 $source = _source_expr( $expr->dict, 95 )
1210 . '{'
1211 . _source_expr( $expr->key )
1212 . '}';
1213 }
1214 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Array') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Array")
!ll&&!rl&&r
030
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Array")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Array")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Array")
ABresult
0X0
100
111
1215 $source = '[ ' . join(
1216 ', ',
1217 0 ▶ map { _source_expr($_) } @{ $expr->items // [] },
Condition0%0/2
$expr->items // []
l!l
00
MC/DC0%0/1
$expr->items // []
$expr->items
Truth table0%0/2
A
A= $expr->items
Aresult
11
00
1218 ) . ' ]';
1219 }
1220 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Dict') ) {
Condition66%2/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Dict")
!ll&&!rl&&r
012
MC/DC50%1/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Dict")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Dict")
Truth table66%2/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Dict")
ABresult
0X0
100
111
1221 $source = '{ ' . join(
1222 ', ',
1223 map {
1224 2 _source_expr( $_->[0] ) . ': ' . _source_expr( $_->[1] )
1225 2 ▶ } @{ $expr->pairs // [] },
Condition50%1/2
$expr->pairs // []
l!l
20
MC/DC0%0/1
$expr->pairs // []
$expr->pairs
Truth table50%1/2
A
A= $expr->pairs
Aresult
11
00
1226 ) . ' }';
1227 }
1228 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::PairList') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::PairList")
!ll&&!rl&&r
010
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::PairList")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::PairList")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::PairList")
ABresult
0X0
100
111
1229 $source = '{{ ' . join(
1230 ', ',
1231 map {
1232 0 _source_expr( $_->[0] ) . ': ' . _source_expr( $_->[1] )
1233 0 ▶ } @{ $expr->pairs // [] },
Condition0%0/2
$expr->pairs // []
l!l
00
MC/DC0%0/1
$expr->pairs // []
$expr->pairs
Truth table0%0/2
A
A= $expr->pairs
Aresult
11
00
1234 ) . ' }}';
1235 }
1236 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Set') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Set")
!ll&&!rl&&r
010
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Set")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Set")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Set")
ABresult
0X0
100
111
1237 $source = '<< ' . join(
1238 ', ',
1239 0 ▶ map { _source_expr($_) } @{ $expr->items // [] },
Condition0%0/2
$expr->items // []
l!l
00
MC/DC0%0/1
$expr->items // []
$expr->items
Truth table0%0/2
A
A= $expr->items
Aresult
11
00
1240 ) . ' >>';
1241 }
1242 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Bag') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Bag")
!ll&&!rl&&r
010
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Bag")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Bag")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Bag")
ABresult
0X0
100
111
1243 $source = '<<< ' . join(
1244 ', ',
1245 0 ▶ map { _source_expr($_) } @{ $expr->items // [] },
Condition0%0/2
$expr->items // []
l!l
00
MC/DC0%0/1
$expr->items // []
$expr->items
Truth table0%0/2
A
A= $expr->items
Aresult
11
00
1246 ) . ' >>>';
1247 }
1248 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Range') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Range")
!ll&&!rl&&r
010
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Range")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Range")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Range")
ABresult
0X0
100
111
1249 0 $source = _source_expr( $expr->start, 20 )
1250 . '..'
1251 . _source_expr( $expr->end, 20 );
1252 }
1253 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::New') ) {
Condition33%1/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::New")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::New")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::New")
Truth table33%1/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::New")
ABresult
0X0
100
111
1254 1 $source = 'new '
1255 . _source_expr( $expr->class_expr, 95 );
1256 1 ▶ if ( @{ $expr->traits // [] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$expr->traits // [];}) 0 1 1
Condition50%1/2
$expr->traits // []
l!l
10
MC/DC0%0/1
$expr->traits // []
$expr->traits
Truth table50%1/2
A
A= $expr->traits
Aresult
11
00
1257 $source .= ' with ' . join(
1258 ', ',
1259 0 map { _source_expr($_) } @{ $expr->traits },
1260 );
1261 }
1262 1 $source .= '('
1263 . _source_args( $expr->args )
1264 . ')';
1265 }
1266 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Function') ) {
Condition0%0/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Function")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Function")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Function")
Truth table0%0/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Function")
ABresult
0X0
100
111
1267 my $fn = Zuzu::Value::Function->new(
1268 0 ▶ params => [ @{ $expr->params // [] } ],
Condition0%0/2
$expr->params // []
l!l
00
MC/DC0%0/1
$expr->params // []
$expr->params
Truth table0%0/2
A
A= $expr->params
Aresult
11
00
1269 vararg => $expr->vararg,
1270 named_vararg => $expr->named_vararg,
1271 0 ▶ param_types => { %{ $expr->param_types // {} } },
Condition0%0/6
$expr->param_types // {}
l!l
00
$expr->vararg_type // "Any"
l!l
00
$expr->named_vararg_type // "PairList"
l!l
00
MC/DC0%0/1
$expr->param_types // {}
$expr->param_types
MC/DC0%0/1
$expr->vararg_type // "Any"
$expr->vararg_type
MC/DC0%0/1
$expr->named_vararg_type // "PairList"
$expr->named_vararg_type
Truth table0%0/2
A
A= $expr->param_types
Aresult
11
00
Truth table0%0/2
A
A= $expr->vararg_type
Aresult
11
00
Truth table0%0/2
A
A= $expr->named_vararg_type
Aresult
11
00
1272 vararg_type => $expr->vararg_type // 'Any',
1273 named_vararg_type => $expr->named_vararg_type // 'PairList',
1274 0 ▶ param_optional => { %{ $expr->param_optional // {} } },
Condition0%0/2
$expr->param_optional // {}
l!l
00
MC/DC0%0/1
$expr->param_optional // {}
$expr->param_optional
Truth table0%0/2
A
A= $expr->param_optional
Aresult
11
00
1275 0 ▶ param_defaults => { %{ $expr->param_defaults // {} } },
Branch: 1 branch
BranchTrueFalseTotal
$expr->is_async ? : 0 0 0
Condition0%0/4
$expr->param_defaults // {}
l!l
00
$expr->return_type // "Any"
l!l
00
MC/DC0%0/1
$expr->param_defaults // {}
$expr->param_defaults
MC/DC0%0/1
$expr->return_type // "Any"
$expr->return_type
Truth table0%0/2
A
A= $expr->param_defaults
Aresult
11
00
Truth table0%0/2
A
A= $expr->return_type
Aresult
11
00
1276 return_type => $expr->return_type // 'Any',
1277 body => $expr->body,
1278 is_async => $expr->is_async ? 1 : 0,
1279 );
1280 0 $source = _function_expression_source( undef, $fn );
1281 }
1282 ▶ elsif ( blessed($expr) and $expr->isa('Zuzu::AST::Expr::Await') ) {
Condition0%0/3
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Await")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($expr) and $expr->isa("Zuzu::AST::Expr::Await")
builtin::blessed($expr) $expr->isa("Zuzu::AST::Expr::Await")
Truth table0%0/3
A and B
A= builtin::blessed($expr)B= $expr->isa("Zuzu::AST::Expr::Await")
ABresult
0X0
100
111
1283 0 $source = 'await ' . _source_block( $expr->block );
1284 }
1285 else {
1286 0 die "Unsupported expression for source extraction: " . ref($expr);
1287 }
1288  
1289 29 ▶ return '(' . $source . ')'
Branch: 1 branch
BranchTrueFalseTotal
if $prec < $parent_prec or $side eq "right" and $prec == $parent_prec 0 29 29
Condition50%3/6
$prec < $parent_prec or $side eq "right" and $prec == $parent_prec
l!l&&r!l&&!r
0029
$side eq "right" and $prec == $parent_prec
!ll&&!rl&&r
2450
MC/DC0%0/3
$prec < $parent_prec or $side eq "right" and $prec == $parent_prec
$prec < $parent_prec $side eq "right" $prec == $parent_prec
Truth table50%2/4
A or B and C
A= $prec < $parent_precB= $side eq "right"C= $prec == $parent_prec
ABCresult
1XX1
0111
00X0
0100
1290 if $prec < $parent_prec or ( $side eq 'right' and $prec == $parent_prec );
1291  
1292 29 return $source;
1293 }
1294  
1295 5 ▶sub _source_binary_prec {
Subroutine _source_binary_prec: called CC=69 SCAR=69.4
1296 5 my ( $op ) = @_;
1297  
1298 5 ▶ return 0 if $op eq '▷' || $op eq '|>' || $op eq '◁' || $op eq '<|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{25b7}" or $op eq "|>" or $op eq "\x{25c1}" or $op eq "<|" 0 5 5
Condition33%3/9
$op eq "\x{25b7}" or $op eq "|>" or $op eq "\x{25c1}" or $op eq "<|"
l!l&&r!l&&!r
005
$op eq "\x{25b7}" or $op eq "|>" or $op eq "\x{25c1}"
l!l&&r!l&&!r
005
$op eq "\x{25b7}" or $op eq "|>"
l!l&&r!l&&!r
005
MC/DC0%0/4
$op eq "\x{25b7}" or $op eq "|>" or $op eq "\x{25c1}" or $op eq "<|"
$op eq "\x{25b7}" $op eq "|>" $op eq "\x{25c1}" $op eq "<|"
Truth table20%1/5
A or B or C or D
A= $op eq "\x{25b7}"B= $op eq "|>"C= $op eq "\x{25c1}"D= $op eq "<|"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1299 5 ▶ return 1 if $op eq 'or' || $op eq '⋁' || $op eq 'or?' || $op eq '⋁?';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "or" or $op eq "\x{22c1}" or $op eq "or?" or $op eq "\x{22c1}?" 0 5 5
Condition33%3/9
$op eq "or" or $op eq "\x{22c1}" or $op eq "or?" or $op eq "\x{22c1}?"
l!l&&r!l&&!r
005
$op eq "or" or $op eq "\x{22c1}" or $op eq "or?"
l!l&&r!l&&!r
005
$op eq "or" or $op eq "\x{22c1}"
l!l&&r!l&&!r
005
MC/DC0%0/4
$op eq "or" or $op eq "\x{22c1}" or $op eq "or?" or $op eq "\x{22c1}?"
$op eq "or" $op eq "\x{22c1}" $op eq "or?" $op eq "\x{22c1}?"
Truth table20%1/5
A or B or C or D
A= $op eq "or"B= $op eq "\x{22c1}"C= $op eq "or?"D= $op eq "\x{22c1}?"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1300 5 ▶ return 2 if $op eq 'onlyif' || $op eq '⊨' || $op eq 'onlyif?' || $op eq '⊨?';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?" or $op eq "\x{22a8}?" 0 5 5
Condition33%3/9
$op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?" or $op eq "\x{22a8}?"
l!l&&r!l&&!r
005
$op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?"
l!l&&r!l&&!r
005
$op eq "onlyif" or $op eq "\x{22a8}"
l!l&&r!l&&!r
005
MC/DC0%0/4
$op eq "onlyif" or $op eq "\x{22a8}" or $op eq "onlyif?" or $op eq "\x{22a8}?"
$op eq "onlyif" $op eq "\x{22a8}" $op eq "onlyif?" $op eq "\x{22a8}?"
Truth table20%1/5
A or B or C or D
A= $op eq "onlyif"B= $op eq "\x{22a8}"C= $op eq "onlyif?"D= $op eq "\x{22a8}?"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1301 5 ▶ return 3 if $op eq 'xor' || $op eq '⊻' || $op eq 'xor?' || $op eq '⊻?'
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}" or $op eq "xnor?" or $op eq "\x{2194}?" 0 5 5
Condition33%11/33
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}" or $op eq "xnor?" or $op eq "\x{2194}?"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}" or $op eq "xnor?"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?"
l!l&&r!l&&!r
005
$op eq "xor" or $op eq "\x{22bb}"
l!l&&r!l&&!r
005
MC/DC0%0/12
$op eq "xor" or $op eq "\x{22bb}" or $op eq "xor?" or $op eq "\x{22bb}?" or $op eq "nor" or $op eq "\x{22bd}" or $op eq "nor?" or $op eq "\x{22bd}?" or $op eq "xnor" or $op eq "\x{2194}" or $op eq "xnor?" or $op eq "\x{2194}?"
$op eq "xor" $op eq "\x{22bb}" $op eq "xor?" $op eq "\x{22bb}?" $op eq "nor" $op eq "\x{22bd}" $op eq "nor?" $op eq "\x{22bd}?" $op eq "xnor" $op eq "\x{2194}" $op eq "xnor?" $op eq "\x{2194}?"
Truth table7%1/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $op eq "xor"B= $op eq "\x{22bb}"C= $op eq "xor?"D= $op eq "\x{22bb}?"E= $op eq "nor"F= $op eq "\x{22bd}"G= $op eq "nor?"H= $op eq "\x{22bd}?"I= $op eq "xnor"J= $op eq "\x{2194}"K= $op eq "xnor?"L= $op eq "\x{2194}?"
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
1302 || $op eq 'nor' || $op eq '⊽' || $op eq 'nor?' || $op eq '⊽?'
1303 || $op eq 'xnor' || $op eq '↔' || $op eq 'xnor?' || $op eq '↔?';
1304 5 ▶ return 4 if $op eq 'and' || $op eq '⋀' || $op eq 'and?' || $op eq '⋀?'
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}" or $op eq "butnot?" or $op eq "\x{22ad}?" 0 5 5
Condition33%11/33
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}" or $op eq "butnot?" or $op eq "\x{22ad}?"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}" or $op eq "butnot?"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?"
l!l&&r!l&&!r
005
$op eq "and" or $op eq "\x{22c0}"
l!l&&r!l&&!r
005
MC/DC0%0/12
$op eq "and" or $op eq "\x{22c0}" or $op eq "and?" or $op eq "\x{22c0}?" or $op eq "nand" or $op eq "\x{22bc}" or $op eq "nand?" or $op eq "\x{22bc}?" or $op eq "butnot" or $op eq "\x{22ad}" or $op eq "butnot?" or $op eq "\x{22ad}?"
$op eq "and" $op eq "\x{22c0}" $op eq "and?" $op eq "\x{22c0}?" $op eq "nand" $op eq "\x{22bc}" $op eq "nand?" $op eq "\x{22bc}?" $op eq "butnot" $op eq "\x{22ad}" $op eq "butnot?" $op eq "\x{22ad}?"
Truth table7%1/13
A or B or C or D or E or F or G or H or I or J or K or L
A= $op eq "and"B= $op eq "\x{22c0}"C= $op eq "and?"D= $op eq "\x{22c0}?"E= $op eq "nand"F= $op eq "\x{22bc}"G= $op eq "nand?"H= $op eq "\x{22bc}?"I= $op eq "butnot"J= $op eq "\x{22ad}"K= $op eq "butnot?"L= $op eq "\x{22ad}?"
ABCDEFGHIJKLresult
1XXXXXXXXXXX1
01XXXXXXXXXX1
001XXXXXXXXX1
0001XXXXXXXX1
00001XXXXXXX1
000001XXXXXX1
0000001XXXXX1
00000001XXXX1
000000001XXX1
0000000001XX1
00000000001X1
0000000000011
0000000000000
1305 || $op eq 'nand' || $op eq '⊼' || $op eq 'nand?' || $op eq '⊼?'
1306 || $op eq 'butnot' || $op eq '⊭' || $op eq 'butnot?' || $op eq '⊭?';
1307 5 ▶ return 5 if $op eq 'default';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "default" 1 4 5
1308 4 ▶ return 5 if $op eq '==' || $op eq '≡' || $op eq '!=' || $op eq '≢';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "==" or $op eq "\x{2261}" or $op eq "!=" or $op eq "\x{2262}" 0 4 4
Condition33%3/9
$op eq "==" or $op eq "\x{2261}" or $op eq "!=" or $op eq "\x{2262}"
l!l&&r!l&&!r
004
$op eq "==" or $op eq "\x{2261}" or $op eq "!="
l!l&&r!l&&!r
004
$op eq "==" or $op eq "\x{2261}"
l!l&&r!l&&!r
004
MC/DC0%0/4
$op eq "==" or $op eq "\x{2261}" or $op eq "!=" or $op eq "\x{2262}"
$op eq "==" $op eq "\x{2261}" $op eq "!=" $op eq "\x{2262}"
Truth table20%1/5
A or B or C or D
A= $op eq "=="B= $op eq "\x{2261}"C= $op eq "!="D= $op eq "\x{2262}"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1309 4 ▶ return 6 if $op =~ /\A(?:=|eq|ne|gt|ge|lt|le|cmp)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /\A(?:=|eq|ne|gt|ge|lt|le|cmp)\z/ 0 4 4
1310 4 ▶ return 6 if $op =~ /\A(?:eqi|nei|gti|gei|lti|lei|cmpi)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /\A(?:eqi|nei|gti|gei|lti|lei|cmpi)\z/ 0 4 4
1311 4 ▶ return 6 if $op =~ /\A(?:in|subsetof|supersetof|equivalentof)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /\A(?:in|subsetof|supersetof|equivalentof)\z/ 0 4 4
1312 4 ▶ return 6 if $op =~ /\A(?:instanceof|does|can|~|@|@\?|@@)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /\A(?:instanceof|does|can|~|@|\@\?|\@@)\z/ 0 4 4
1313 4 ▶ return 6 if $op =~ /\A(?:[<>]=?|<=>|[≤≥≠≶≷∈∉⊂⊃]|⊂⊃)\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $op =~ /\A(?:[<>]=?|<=>|[\x{2264}\x{2265}\x{2260}\x{2276}\x{2277}\x{2208}\x{2209}\x{2282}\x{2283}]|\x{2282}\x{2283})\z/ 0 4 4
1314 4 ▶ return 7 if $op eq '|';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "|" 0 4 4
1315 4 ▶ return 8 if $op eq '^';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "^" 0 4 4
1316 4 ▶ return 9 if $op eq '&';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "&" 0 4 4
1317 4 ▶ return 10 if $op eq '<<' || $op eq '«' || $op eq '>>' || $op eq '»';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}" 0 4 4
Condition33%3/9
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}"
l!l&&r!l&&!r
004
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>"
l!l&&r!l&&!r
004
$op eq "<<" or $op eq "\x{ab}"
l!l&&r!l&&!r
004
MC/DC0%0/4
$op eq "<<" or $op eq "\x{ab}" or $op eq ">>" or $op eq "\x{bb}"
$op eq "<<" $op eq "\x{ab}" $op eq ">>" $op eq "\x{bb}"
Truth table20%1/5
A or B or C or D
A= $op eq "<<"B= $op eq "\x{ab}"C= $op eq ">>"D= $op eq "\x{bb}"
ABCDresult
1XXX1
01XX1
001X1
00011
00000
1318 4 ▶ return 11 if $op eq 'union' || $op eq 'intersection' || $op eq '\\';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "union" or $op eq "intersection" or $op eq "\\" 0 4 4
Condition33%2/6
$op eq "union" or $op eq "intersection" or $op eq "\\"
l!l&&r!l&&!r
004
$op eq "union" or $op eq "intersection"
l!l&&r!l&&!r
004
MC/DC0%0/3
$op eq "union" or $op eq "intersection" or $op eq "\\"
$op eq "union" $op eq "intersection" $op eq "\\"
Truth table25%1/4
A or B or C
A= $op eq "union"B= $op eq "intersection"C= $op eq "\\"
ABCresult
1XX1
01X1
0011
0000
1319 4 ▶ return 11 if $op eq '⋃' || $op eq '⋂' || $op eq '∖';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{22c3}" or $op eq "\x{22c2}" or $op eq "\x{2216}" 0 4 4
Condition33%2/6
$op eq "\x{22c3}" or $op eq "\x{22c2}" or $op eq "\x{2216}"
l!l&&r!l&&!r
004
$op eq "\x{22c3}" or $op eq "\x{22c2}"
l!l&&r!l&&!r
004
MC/DC0%0/3
$op eq "\x{22c3}" or $op eq "\x{22c2}" or $op eq "\x{2216}"
$op eq "\x{22c3}" $op eq "\x{22c2}" $op eq "\x{2216}"
Truth table25%1/4
A or B or C
A= $op eq "\x{22c3}"B= $op eq "\x{22c2}"C= $op eq "\x{2216}"
ABCresult
1XX1
01X1
0011
0000
1320 4 ▶ return 12 if $op eq '_';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "_" 1 3 4
1321 3 ▶ return 13 if $op eq '+' || $op eq '-';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "+" or $op eq "-" 3 0 3
Condition33%1/3
$op eq "+" or $op eq "-"
l!l&&r!l&&!r
300
MC/DC0%0/2
$op eq "+" or $op eq "-"
$op eq "+" $op eq "-"
Truth table33%1/3
A or B
A= $op eq "+"B= $op eq "-"
ABresult
1X1
011
000
1322 0 ▶ return 14 if $op eq '*' || $op eq '/' || $op eq '×';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "*" or $op eq "/" or $op eq "\x{d7}" 0 0 0
Condition0%0/6
$op eq "*" or $op eq "/" or $op eq "\x{d7}"
l!l&&r!l&&!r
000
$op eq "*" or $op eq "/"
l!l&&r!l&&!r
000
MC/DC0%0/3
$op eq "*" or $op eq "/" or $op eq "\x{d7}"
$op eq "*" $op eq "/" $op eq "\x{d7}"
Truth table0%0/4
A or B or C
A= $op eq "*"B= $op eq "/"C= $op eq "\x{d7}"
ABCresult
1XX1
01X1
0011
0000
1323 0 ▶ return 14 if $op eq '÷' || $op eq 'mod';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "\x{f7}" or $op eq "mod" 0 0 0
Condition0%0/3
$op eq "\x{f7}" or $op eq "mod"
l!l&&r!l&&!r
000
MC/DC0%0/2
$op eq "\x{f7}" or $op eq "mod"
$op eq "\x{f7}" $op eq "mod"
Truth table0%0/3
A or B
A= $op eq "\x{f7}"B= $op eq "mod"
ABresult
1X1
011
000
1324 0 ▶ return 15 if $op eq '**';
Branch: 1 branch
BranchTrueFalseTotal
if $op eq "**" 0 0 0
1325  
1326 0 die "Unsupported binary operator for source extraction: $op";
1327 }
1328  
1329 2 ▶sub _source_args {
Subroutine _source_args: called CC=4 SCAR=15.2
1330 2 my ( $args ) = @_;
1331  
1332 return join(
1333 ', ',
1334 map {
1335 2 my ( $name, $value, $dynamic ) = @{ $_ };
1336 2 ▶ if ($dynamic) {
Branch: 2 branches
BranchTrueFalseTotal
if ($dynamic) { } 0 2 2
elsif (defined $name) { } 0 2 2
1337 0 _source_expr($_->[0]) . ': ' . _source_expr($value);
1338 }
1339 elsif ( defined $name ) {
1340 0 $name . ': ' . _source_expr($value);
1341 }
1342 else {
1343 2 _source_expr($value);
1344 }
1345 2 ▶ } @{ $args // [] },
Condition50%1/2
$args // []
l!l
20
MC/DC0%0/1
$args // []
$args
Truth table50%1/2
A
A= $args
Aresult
11
00
1346 );
1347 }
1348  
1349 7 ▶sub _source_literal {
Subroutine _source_literal: called CC=12 SCAR=31.9
1350 7 my ( $value ) = @_;
1351  
1352 7 ▶ return 'null' if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 7 7
1353 7 ▶ return $value->value ? 'true' : 'false'
Branch: 2 branches
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::Boolean") 0 7 7
$value->value ? : 0 0 0
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Boolean")
!ll&&!rl&&r
700
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Boolean")
builtin::blessed($value) $value->isa("Zuzu::Value::Boolean")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Boolean")
ABresult
0X0
100
111
1354 if blessed($value) and $value->isa('Zuzu::Value::Boolean');
1355 7 ▶ return _source_binary_string( $value->bytes )
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString") 0 7 7
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
!ll&&!rl&&r
700
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::BinaryString")
builtin::blessed($value) $value->isa("Zuzu::Value::BinaryString")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::BinaryString")
ABresult
0X0
100
111
1356 if blessed($value) and $value->isa('Zuzu::Value::BinaryString');
1357 7 ▶ return _source_regexp( $value->pattern, $value->flags )
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp") 0 7 7
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")
!ll&&!rl&&r
700
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Regexp")
builtin::blessed($value) $value->isa("Zuzu::Value::Regexp")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Regexp")
ABresult
0X0
100
111
1358 if blessed($value) and $value->isa('Zuzu::Value::Regexp');
1359 7 ▶ return _source_string($value) if !ref($value) and $value !~ /\A-?\d/;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value or $value =~ /\A-?\d/ 3 4 7
Condition66%2/3
ref $value or $value =~ /\A-?\d/
l!l&&r!l&&!r
043
MC/DC50%1/2
ref $value or $value =~ /\A-?\d/
ref $value $value =~ /\A-?\d/
Truth table66%2/3
A or B
A= ref $valueB= $value =~ /\A-?\d/
ABresult
1X1
011
000
1360 4 ▶ return "$value" if !ref($value);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value 4 0 4
1361  
1362 0 die "Unsupported literal for source extraction: " . ref($value);
1363 }
1364  
1365 3 ▶sub _source_string {
Subroutine _source_string: called CC=2 SCAR=7.0
1366 3 my ( $value ) = @_;
1367  
1368 3 ▶ $value //= '';
Condition50%1/2
$value //= ""
l!l
30
MC/DC0%0/1
$value //= ""
$value
Truth table50%1/2
A
A= $value
Aresult
11
00
1369 3 $value =~ s/\\/\\\\/g;
1370 3 $value =~ s/"/\\"/g;
1371 3 $value =~ s/\n/\\n/g;
1372 3 $value =~ s/\r/\\r/g;
1373 3 $value =~ s/\t/\\t/g;
1374  
1375 3 return '"' . $value . '"';
1376 }
1377  
1378 0 ▶sub _source_binary_string {
Subroutine _source_binary_string: not called CC=2 SCAR=17.9
1379 0 my ( $bytes ) = @_;
1380  
1381 0 ▶ $bytes //= '';
Condition0%0/2
$bytes //= ""
l!l
00
MC/DC0%0/1
$bytes //= ""
$bytes
Truth table0%0/2
A
A= $bytes
Aresult
11
00
1382 0 $bytes =~ s/\\/\\\\/g;
1383 0 $bytes =~ s/"/\\"/g;
1384 0 $bytes =~ s/\n/\\n/g;
1385 0 $bytes =~ s/\r/\\r/g;
1386 0 $bytes =~ s/\t/\\t/g;
1387 0 $bytes =~ s/([^\x20-\x7E])/sprintf '\\x{%02X}', ord($1)/ge;
1388  
1389 0 return '~"' . $bytes . '"';
1390 }
1391  
1392 0 ▶sub _source_regexp {
Subroutine _source_regexp: not called CC=3 SCAR=24.8
1393 0 my ( $pattern, $flags ) = @_;
1394  
1395 0 ▶ $pattern //= '';
Condition0%0/2
$pattern //= ""
l!l
00
MC/DC0%0/1
$pattern //= ""
$pattern
Truth table0%0/2
A
A= $pattern
Aresult
11
00
1396 0 ▶ $flags //= '';
Condition0%0/2
$flags //= ""
l!l
00
MC/DC0%0/1
$flags //= ""
$flags
Truth table0%0/2
A
A= $flags
Aresult
11
00
1397 0 $pattern =~ s{/}{\\/}g;
1398  
1399 0 return '/' . $pattern . '/' . $flags;
1400 }
1401  
1402 12 ▶sub _number_to_cbor {
Subroutine _number_to_cbor: called CC=4 SCAR=15.9
1403 12 my ( $value ) = @_;
1404  
1405 12 my $number = 0 + $value;
1406 12 ▶ die "Number values must be finite" if !is_finite_number($number);
Branch: 1 branch
BranchTrueFalseTotal
unless is_finite_number($number) 0 12 12
1407  
1408 12 ▶ if ( _is_integral_number($number) and abs($number) <= MAX_SAFE_INTEGER ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_integral_number($number) and abs $number <= '9007199254740991') 12 0 12
Condition33%1/3
_is_integral_number($number) and abs $number <= '9007199254740991'
!ll&&!rl&&r
0012
MC/DC0%0/2
_is_integral_number($number) and abs $number <= '9007199254740991'
_is_integral_number($number) abs $number <= '9007199254740991'
Truth table33%1/3
A and B
A= _is_integral_number($number)B= abs $number <= '9007199254740991'
ABresult
0X0
100
111
1409 12 return int($number);
1410 }
1411  
1412 0 return $number;
1413 }
1414  
1415 12 ▶sub _is_integral_number {
Subroutine _is_integral_number: called CC=4 SCAR=14.9
1416 12 my ( $number ) = @_;
1417 12 ▶ return 0 if !_is_finite_number($number);
Branch: 1 branch
BranchTrueFalseTotal
unless _is_finite_number($number) 0 12 12
1418 12 ▶ return 0 if _is_negative_zero($number);
Branch: 1 branch
BranchTrueFalseTotal
if _is_negative_zero($number) 0 12 12
1419 12 ▶ return int($number) == $number ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
int $number == $number ? : 12 0 12
1420 }
1421  
1422 118 ▶sub _is_integer_value {
Subroutine _is_integer_value: called CC=5 SCAR=16.7
1423 118 my ( $value ) = @_;
1424  
1425 118 ▶ return 0 if ref($value);
Branch: 1 branch
BranchTrueFalseTotal
if ref $value 0 118 118
1426 118 ▶ return 0 if !looks_like_number($value);
Branch: 1 branch
BranchTrueFalseTotal
unless &looks_like_number($value) 0 118 118
1427 118 ▶ return 0 if !_is_finite_number( 0 + $value );
Branch: 1 branch
BranchTrueFalseTotal
unless _is_finite_number(0 + $value) 0 118 118
1428 118 ▶ return int($value) == $value ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
int $value == $value ? : 116 2 118
1429 }
1430  
1431 130 ▶sub _is_finite_number {
Subroutine _is_finite_number: called CC=2 SCAR=7.2
1432 130 my ( $number ) = @_;
1433 130 ▶ return is_finite_number($number) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
is_finite_number($number) ? : 130 0 130
1434 }
1435  
1436 12 ▶sub _is_negative_zero {
Subroutine _is_negative_zero: called CC=3 SCAR=15.4
1437 12 my ( $number ) = @_;
1438 12 ▶ return 0 if $number != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $number != 0 12 0 12
1439 0 ▶ return sprintf( '%.17g', $number ) eq '-0' ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
sprintf('%.17g', $number) eq '-0' ? : 0 0 0
1440 }
1441  
1442 15 ▶sub _encode_scalar_value {
Subroutine _encode_scalar_value: called CC=7 SCAR=23.2
1443 15 my ( $runtime, $value ) = @_;
1444  
1445 15 my $type = $runtime->_type_name($value);
1446 15 ▶ return undef if $type eq 'Null';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Null" 2 13 15
1447 13 ▶ return $value->value ? cbor_true() : cbor_false()
Branch: 2 branches
BranchTrueFalseTotal
if $type eq "Boolean" 0 13 13
$value->value ? : 0 0 0
1448 if $type eq 'Boolean';
1449 13 ▶ return _number_to_cbor($value) if $type eq 'Number';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Number" 11 2 13
1450 2 ▶ return text_string($value) if $type eq 'String';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "String" 2 0 2
1451 0 ▶ return byte_string( $value->bytes ) if $type eq 'BinaryString';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "BinaryString" 0 0 0
1452  
1453 0 die "Value of type $type is not marshalable in scalar phase";
1454 }
1455  
1456 28 ▶sub _decode_scalar_value {
Subroutine _decode_scalar_value: called CC=6 SCAR=20.3
1457 28 my ( $runtime, $value ) = @_;
1458  
1459 28 ▶ return undef if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 15 13 28
1460 13 ▶ return _zuzu_bool($value) if is_cbor_bool($value);
Branch: 1 branch
BranchTrueFalseTotal
if is_cbor_bool($value) 0 13 13
1461 13 ▶ return 0 + $value if !ref($value);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value 9 4 13
1462 4 ▶ return text_value($value) if is_text_string($value);
Branch: 1 branch
BranchTrueFalseTotal
if is_text_string($value) 4 0 4
1463 0 ▶ return Zuzu::Value::BinaryString->new( bytes => bytes_value($value) )
Branch: 1 branch
BranchTrueFalseTotal
if is_byte_string($value) 0 0 0
1464 if is_byte_string($value);
1465  
1466 0 die "Envelope root is not a scalar value";
1467 }
1468  
1469 9 ▶sub _new_dump_state {
Subroutine _new_dump_state: called CC=1 SCAR=0.0
1470 9 my %strong_ids;
1471  
1472 return {
1473 9 objects => [],
1474 strong_ids => \%strong_ids,
1475 on_dump => {},
1476 code => [],
1477 code_ids => {},
1478 code_names => {},
1479 };
1480 }
1481  
1482 62 ▶sub _encode_value {
Subroutine _encode_value: called CC=23 SCAR=33.0
1483 62 my ( $runtime, $value, $state, $edge_strength ) = @_;
1484  
1485 62 ▶ $edge_strength //= EDGE_STRONG;
Condition50%1/2
$edge_strength //= "strong"
l!l
620
MC/DC0%0/1
$edge_strength //= "strong"
$edge_strength
Truth table50%1/2
A
A= $edge_strength
Aresult
11
00
1486 62 ▶ die "Unknown dump edge strength '$edge_strength'"
Branch: 1 branch
BranchTrueFalseTotal
if $edge_strength ne "strong" and $edge_strength ne "weak" 0 62 62
Condition66%2/3
$edge_strength ne "strong" and $edge_strength ne "weak"
!ll&&!rl&&r
52100
MC/DC0%0/2
$edge_strength ne "strong" and $edge_strength ne "weak"
$edge_strength ne "strong" $edge_strength ne "weak"
Truth table66%2/3
A and B
A= $edge_strength ne "strong"B= $edge_strength ne "weak"
ABresult
0X0
100
111
1487 if $edge_strength ne EDGE_STRONG and $edge_strength ne EDGE_WEAK;
1488  
1489 62 ▶ return _encode_weak_value( $runtime, $value, $state )
Branch: 1 branch
BranchTrueFalseTotal
if $edge_strength eq "weak" 10 52 62
1490 if $edge_strength eq EDGE_WEAK;
1491  
1492 52 ▶ return _encode_scalar_value( $runtime, $value )
Branch: 1 branch
BranchTrueFalseTotal
if _is_scalar_type($runtime, $value) 11 41 52
1493 if _is_scalar_type( $runtime, $value );
1494  
1495 41 ▶ if ( _is_pair_value( $runtime, $value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_pair_value($runtime, $value)) 0 41 41
1496 0 return _encode_pair_value( $runtime, $value, $state );
1497 }
1498  
1499 41 ▶ if ( _is_time_value( $runtime, $value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_time_value($runtime, $value)) 2 39 41
1500 2 return _encode_time_value( $runtime, $value, $state );
1501 }
1502  
1503 39 ▶ if ( _is_path_value( $runtime, $value ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_path_value($runtime, $value)) 2 37 39
1504 2 return _encode_path_value( $runtime, $value, $state );
1505 }
1506  
1507 37 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Class")) 3 34 37
Condition66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Class")
!ll&&!rl&&r
0343
MC/DC50%1/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Class")
builtin::blessed($value) $value->isa("Zuzu::Value::Class")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
1508 3 return _encode_class_value( $runtime, $value, $state );
1509 }
1510  
1511 34 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Trait') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")) 0 34 34
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
0340
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")
builtin::blessed($value) $value->isa("Zuzu::Value::Trait")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
1512 0 return _encode_trait_value( $runtime, $value, $state );
1513 }
1514  
1515 34 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Function")) 1 33 34
Condition66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
!ll&&!rl&&r
0331
MC/DC50%1/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
builtin::blessed($value) $value->isa("Zuzu::Value::Function")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
1516 return _encode_bound_method_value( $runtime, $value, $state )
1517 1 ▶ if $value->{_is_method};
Branch: 1 branch
BranchTrueFalseTotal
if $value->{"_is_method"} 0 1 1
1518 1 return _encode_function_value( $runtime, $value, $state );
1519 }
1520  
1521 33 my $array = $runtime->_unwrap_builtin_collection( $value, 'Array' );
1522 33 ▶ if ($array) {
Branch: 1 branch
BranchTrueFalseTotal
if ($array) 13 20 33
1523 13 return _encode_array_value( $runtime, $array, $state );
1524 }
1525  
1526 20 my $dict = $runtime->_unwrap_builtin_collection( $value, 'Dict' );
1527 20 ▶ if ($dict) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dict) 6 14 20
1528 6 return _encode_dict_value( $runtime, $dict, $state );
1529 }
1530  
1531 14 my $pairlist = $runtime->_unwrap_builtin_collection( $value, 'PairList' );
1532 14 ▶ if ($pairlist) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pairlist) 4 10 14
1533 4 return _encode_pairlist_value( $runtime, $pairlist, $state );
1534 }
1535  
1536 10 my $set = $runtime->_unwrap_builtin_collection( $value, 'Set' );
1537 10 ▶ if ($set) {
Branch: 1 branch
BranchTrueFalseTotal
if ($set) 2 8 10
1538 2 return _encode_set_value( $runtime, $set, $state );
1539 }
1540  
1541 8 my $bag = $runtime->_unwrap_builtin_collection( $value, 'Bag' );
1542 8 ▶ if ($bag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($bag) 2 6 8
1543 2 return _encode_bag_value( $runtime, $bag, $state );
1544 }
1545  
1546 6 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Object")) 6 0 6
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
006
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
builtin::blessed($value) $value->isa("Zuzu::Value::Object")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
1547 6 return _encode_object_value( $runtime, $value, $state );
1548 }
1549  
1550 0 my $type = $runtime->_type_name($value);
1551 0 die "Value of type $type is not marshalable in this phase";
1552 }
1553  
1554 32 ▶sub _encode_strong_value {
Subroutine _encode_strong_value: called CC=1 SCAR=0.0
1555 32 my ( $runtime, $value, $state ) = @_;
1556  
1557 32 return _encode_value( $runtime, $value, $state, EDGE_STRONG );
1558 }
1559  
1560 10 ▶sub _encode_weak_value {
Subroutine _encode_weak_value: called CC=4 SCAR=13.9
1561 10 my ( $runtime, $value, $state ) = @_;
1562  
1563 10 ▶ return [ 1, _encode_scalar_value( $runtime, $value ) ]
Branch: 1 branch
BranchTrueFalseTotal
if _is_scalar_type($runtime, $value) 3 7 10
1564 if _is_scalar_type( $runtime, $value );
1565  
1566 7 my $addr = refaddr($value);
1567 7 ▶ return [ 1, undef ] if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 7 7
1568 7 ▶ return [ 1, undef ] if !exists $state->{strong_ids}{$addr};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $state->{"strong_ids"}{$addr} 5 2 7
1569  
1570 2 return [ 1, [ 0, $state->{strong_ids}{$addr} ] ];
1571 }
1572  
1573 30 ▶sub _encode_stored_value {
Subroutine _encode_stored_value: called CC=2 SCAR=6.9
1574 30 my ( $runtime, $value, $state, $weak ) = @_;
1575  
1576 30 ▶ return _encode_value(
Branch: 1 branch
BranchTrueFalseTotal
$weak ? : 10 20 30
1577 $runtime,
1578 $value,
1579 $state,
1580 $weak ? EDGE_WEAK : EDGE_STRONG,
1581 );
1582 }
1583  
1584 64 ▶sub _is_scalar_type {
Subroutine _is_scalar_type: called CC=6 SCAR=18.0
1585 64 my ( $runtime, $value ) = @_;
1586  
1587 64 my $type = $runtime->_type_name($value);
1588 64 ▶ return 1 if $type eq 'Null';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Null" 2 62 64
1589 62 ▶ return 1 if $type eq 'Boolean';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Boolean" 0 62 62
1590 62 ▶ return 1 if $type eq 'Number';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "Number" 11 51 62
1591 51 ▶ return 1 if $type eq 'String';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "String" 2 49 51
1592 49 ▶ return 1 if $type eq 'BinaryString';
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "BinaryString" 0 49 49
1593 49 return 0;
1594 }
1595  
1596 5 ▶sub _module_symbol {
Subroutine _module_symbol: called CC=2 SCAR=7.0
1597 5 my ( $runtime, $module, $symbol ) = @_;
1598  
1599 5 my $env = $runtime->_load_module(
1600 $module,
1601 _call_file($runtime),
1602 _call_line($runtime),
1603 );
1604 5 my $ref = $env->find_ref($symbol);
1605 5 ▶ die "Runtime-supported module $module does not export $symbol"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ref 0 5 5
1606 if !defined $ref;
1607  
1608 5 return ${ $ref };
1609 }
1610  
1611 4 ▶sub _object_descends_from {
Subroutine _object_descends_from: called CC=5 SCAR=19.6
1612 4 my ( $class, $target ) = @_;
1613  
1614 4 ▶ return 0 if !defined $class or !defined $target;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $class and defined $target 0 4 4
Condition33%1/3
defined $class and defined $target
!ll&&!rl&&r
004
MC/DC0%0/2
defined $class and defined $target
defined $class defined $target
Truth table33%1/3
A and B
A= defined $classB= defined $target
ABresult
0X0
100
111
1615 4 my $cur = $class;
1616 4 ▶ while ($cur) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cur) 4 0 4
1617 4 ▶ return 1 if $cur == $target;
Branch: 1 branch
BranchTrueFalseTotal
if $cur == $target 4 0 4
1618 0 $cur = $cur->parent;
1619 }
1620  
1621 0 return 0;
1622 }
1623  
1624 4 ▶sub _object_is_module_class {
Subroutine _object_is_module_class: called CC=3 SCAR=12.0
1625 4 my ( $runtime, $value, $module, $symbol ) = @_;
1626  
1627 4 ▶ return 0
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Object") 0 4 4
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
004
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
builtin::blessed($value) $value->isa("Zuzu::Value::Object")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
1628 if !blessed($value) or !$value->isa('Zuzu::Value::Object');
1629 4 my $target = _module_symbol( $runtime, $module, $symbol );
1630  
1631 4 return _object_descends_from( $value->class, $target );
1632 }
1633  
1634 41 ▶sub _is_pair_value {
Subroutine _is_pair_value: called CC=4 SCAR=14.2
1635 41 my ( $runtime, $value ) = @_;
1636  
1637 41 ▶ return 0
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Object") 31 10 41
Condition66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
03110
MC/DC50%1/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
builtin::blessed($value) $value->isa("Zuzu::Value::Object")
Truth table66%2/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
1638 if !blessed($value) or !$value->isa('Zuzu::Value::Object');
1639 10 ▶ return $runtime->_class_is_or_descends( $value->class, 'Pair' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$runtime->_class_is_or_descends($value->class, 'Pair') ? : 0 10 10
1640 }
1641  
1642 0 ▶sub _pair_slot_array {
Subroutine _pair_slot_array: not called CC=3 SCAR=24.8
1643 0 my ( $pair ) = @_;
1644  
1645 0 my $slot = $pair->slots->{pair};
1646 0 ▶ die "Pair value has invalid pair slot"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($slot) and $slot->isa("Zuzu::Value::Array") 0 0 0
Condition0%0/3
builtin::blessed($slot) and $slot->isa("Zuzu::Value::Array")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($slot) and $slot->isa("Zuzu::Value::Array")
builtin::blessed($slot) $slot->isa("Zuzu::Value::Array")
Truth table0%0/3
A and B
A= builtin::blessed($slot)B= $slot->isa("Zuzu::Value::Array")
ABresult
0X0
100
111
1647 if !blessed($slot) or !$slot->isa('Zuzu::Value::Array');
1648  
1649 0 return $slot;
1650 }
1651  
1652 0 ▶sub _encode_pair_value {
Subroutine _encode_pair_value: not called CC=6 SCAR=37.4
1653 0 my ( $runtime, $pair, $state ) = @_;
1654  
1655 0 my $addr = refaddr($pair);
1656 0 ▶ die "Pair value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 0 0
1657  
1658 0 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 0 0 0
1659 0 my $id = $state->{strong_ids}{$addr};
1660 0 return [ 0, $id ];
1661 }
1662  
1663 0 my $id = scalar @{ $state->{objects} };
1664 0 $state->{strong_ids}{$addr} = $id;
1665 0 push @{ $state->{objects} }, undef;
1666  
1667 0 ▶ my $items = _pair_slot_array($pair)->items // [];
Condition0%0/2
_pair_slot_array($pair)->items // []
l!l
00
MC/DC0%0/1
_pair_slot_array($pair)->items // []
_pair_slot_array($pair)->items
Truth table0%0/2
A
A= _pair_slot_array($pair)->items
Aresult
11
00
1668 0 my $pair_array = _pair_slot_array($pair);
1669 0 my $key = $items->[0];
1670 0 my $value = $pair_array->_value_at(1);
1671 0 ▶ my $weak = $pair_array->weak->[1] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$pair_array->weak->[1] ? : 0 0 0
1672 0 ▶ _encode_strong_value( $runtime, $value, $state ) if !$weak;
Branch: 1 branch
BranchTrueFalseTotal
unless $weak 0 0 0
1673 0 my $payload = [
1674 text_string($key),
1675 _encode_stored_value( $runtime, $value, $state, $weak ),
1676 ];
1677 0 $state->{objects}[$id] = [ KIND_PAIR, $payload ];
1678  
1679 0 return [ 0, $id ];
1680 }
1681  
1682 3 ▶sub _encode_class_value {
Subroutine _encode_class_value: called CC=3 SCAR=11.0
1683 3 my ( $runtime, $class_value, $state ) = @_;
1684  
1685 3 my $addr = refaddr($class_value);
1686 3 ▶ die "Class value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 3 3
1687  
1688 3 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 1 2 3
1689 1 my $id = $state->{strong_ids}{$addr};
1690 1 return [ 0, $id ];
1691 }
1692  
1693 2 my $id = scalar @{ $state->{objects} };
1694 2 $state->{strong_ids}{$addr} = $id;
1695 2 push @{ $state->{objects} }, undef;
1696  
1697 2 my $code_id = _encode_class_code( $runtime, $class_value, $state, undef );
1698 2 $state->{objects}[$id] = [ KIND_CLASS, [$code_id] ];
1699  
1700 2 return [ 0, $id ];
1701 }
1702  
1703 0 ▶sub _encode_trait_value {
Subroutine _encode_trait_value: not called CC=3 SCAR=24.8
1704 0 my ( $runtime, $trait_value, $state ) = @_;
1705  
1706 0 my $addr = refaddr($trait_value);
1707 0 ▶ die "Trait value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 0 0
1708  
1709 0 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 0 0 0
1710 0 my $id = $state->{strong_ids}{$addr};
1711 0 return [ 0, $id ];
1712 }
1713  
1714 0 my $id = scalar @{ $state->{objects} };
1715 0 $state->{strong_ids}{$addr} = $id;
1716 0 push @{ $state->{objects} }, undef;
1717  
1718 0 my $code_id = _encode_trait_code( $runtime, $trait_value, $state, undef );
1719 0 $state->{objects}[$id] = [ KIND_TRAIT, [$code_id] ];
1720  
1721 0 return [ 0, $id ];
1722 }
1723  
1724 1 ▶sub _encode_function_value {
Subroutine _encode_function_value: called CC=4 SCAR=14.4
1725 1 my ( $runtime, $fn, $state ) = @_;
1726  
1727 die "Bound method values are not marshalable in this phase"
1728 1 ▶ if $fn->{_is_method};
Branch: 1 branch
BranchTrueFalseTotal
if $fn->{"_is_method"} 0 1 1
1729  
1730 1 my $addr = refaddr($fn);
1731 1 ▶ die "Function value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 1 1
1732  
1733 1 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 0 1 1
1734 0 my $id = $state->{strong_ids}{$addr};
1735 0 return [ 0, $id ];
1736 }
1737  
1738 1 my $id = scalar @{ $state->{objects} };
1739 1 $state->{strong_ids}{$addr} = $id;
1740 1 push @{ $state->{objects} }, undef;
1741  
1742 1 my $code_id = _encode_function_code( $runtime, $fn, $state, undef );
1743 1 $state->{objects}[$id] = [ KIND_FUNCTION, [$code_id] ];
1744  
1745 1 return [ 0, $id ];
1746 }
1747  
1748 0 ▶sub _encode_bound_method_value {
Subroutine _encode_bound_method_value: not called CC=7 SCAR=40.3
1749 0 my ( $runtime, $method, $state ) = @_;
1750  
1751 die "Unbound method values are not marshalable in this phase"
1752 0 ▶ if !defined $method->{_bound_self};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $method->{"_bound_self"} 0 0 0
1753  
1754 0 my $addr = refaddr($method);
1755 0 ▶ die "Bound method value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 0 0
1756  
1757 0 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 0 0 0
1758 0 my $id = $state->{strong_ids}{$addr};
1759 0 return [ 0, $id ];
1760 }
1761  
1762 0 ▶ my $method_name = $method->{_method_name} // $method->name;
Condition0%0/3
$method->{"_method_name"} // $method->name
l!l&&r!l&&!r
000
MC/DC0%0/2
$method->{"_method_name"} // $method->name
$method->{"_method_name"} $method->name
Truth table0%0/3
A // B
A= $method->{"_method_name"}B= $method->name
ABresult
1X1
011
000
1763 0 ▶ die "Bound method value has no method name"
Branch: 1 branch
BranchTrueFalseTotal
if not defined $method_name or $method_name eq "" 0 0 0
Condition0%0/3
not defined $method_name or $method_name eq ""
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $method_name or $method_name eq ""
not defined $method_name $method_name eq ""
Truth table0%0/3
not(A) or B
A= not defined $method_nameB= $method_name eq ""
ABresult
1X1
011
000
1764 if !defined $method_name or $method_name eq '';
1765  
1766 0 my $id = scalar @{ $state->{objects} };
1767 0 $state->{strong_ids}{$addr} = $id;
1768 0 push @{ $state->{objects} }, undef;
1769  
1770 $state->{objects}[$id] = [
1771 KIND_BOUND_METHOD,
1772 [
1773 _encode_strong_value(
1774 $runtime,
1775 $method->{_bound_self},
1776 0 $state,
1777 ),
1778 text_string($method_name),
1779 ],
1780 ];
1781  
1782 0 return [ 0, $id ];
1783 }
1784  
1785 1 ▶sub _encode_function_code {
Subroutine _encode_function_code: called CC=9 SCAR=23.3
1786 1 my ( $runtime, $fn, $state, $preferred_name ) = @_;
1787  
1788 1 ▶ die "Function dependency is not a Function value"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function") 0 1 1
Condition33%1/3
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($fn) and $fn->isa("Zuzu::Value::Function")
builtin::blessed($fn) $fn->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($fn)B= $fn->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
1789 if !blessed($fn) or !$fn->isa('Zuzu::Value::Function');
1790 die "Bound method values are not marshalable in this phase"
1791 1 ▶ if $fn->{_is_method};
Branch: 1 branch
BranchTrueFalseTotal
if $fn->{"_is_method"} 0 1 1
1792 die "Native functions do not have ZuzuScript source"
1793 1 ▶ if $fn->{_native};
Branch: 1 branch
BranchTrueFalseTotal
if $fn->{"_native"} 0 1 1
1794  
1795 1 my $addr = refaddr($fn);
1796 1 ▶ die "Function code value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 1 1
1797  
1798 return $state->{code_ids}{$addr}
1799 1 ▶ if exists $state->{code_ids}{$addr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $state->{"code_ids"}{$addr} 0 1 1
1800  
1801 1 my $id = scalar @{ $state->{code} };
1802 1 $state->{code_ids}{$addr} = $id;
1803 1 push @{ $state->{code} }, undef;
1804  
1805 1 my $binding_name = _function_code_binding_name(
1806 $fn,
1807 $state,
1808 $id,
1809 $preferred_name,
1810 );
1811 1 $state->{code_names}{$binding_name} = 1;
1812  
1813 1 my $analysis = _analyse_function_value( $runtime, $fn );
1814 my @captures = map {
1815 [
1816 text_string( $_->{name} ),
1817 0 _encode_scalar_value( $runtime, $_->{value} ),
1818 ]
1819 1 } @{ $analysis->{captures} };
1820 1 my @dependencies;
1821 1 for my $dependency ( @{ $analysis->{internal_dependencies} } ) {
1822 0 push @dependencies, _encode_code_dependency(
1823 $runtime,
1824 $dependency,
1825 $state,
1826 );
1827 }
1828 1 for my $dependency ( @{ $analysis->{external_dependencies} } ) {
1829 push @dependencies, [
1830 1,
1831 text_string( $dependency->{local_name} ),
1832 text_string( $dependency->{module} ),
1833 0 text_string( $dependency->{export_name} ),
1834 ];
1835 }
1836  
1837 $state->{code}[$id] = [
1838 CODE_FUNCTION,
1839 text_string($binding_name),
1840 1 text_string( $analysis->{source} ),
1841 \@captures,
1842 \@dependencies,
1843 ];
1844  
1845 1 return $id;
1846 }
1847  
1848 2 ▶sub _encode_class_code {
Subroutine _encode_class_code: called CC=9 SCAR=23.7
1849 2 my ( $runtime, $class_value, $state, $preferred_name ) = @_;
1850  
1851 2 ▶ die "Class dependency is not a Class value"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($class_value) and $class_value->isa("Zuzu::Value::Class") 0 2 2
Condition33%1/3
builtin::blessed($class_value) and $class_value->isa("Zuzu::Value::Class")
!ll&&!rl&&r
002
MC/DC0%0/2
builtin::blessed($class_value) and $class_value->isa("Zuzu::Value::Class")
builtin::blessed($class_value) $class_value->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($class_value)B= $class_value->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
1852 if !blessed($class_value) or !$class_value->isa('Zuzu::Value::Class');
1853 2 ▶ die "Native classes do not have ZuzuScript source"
Branch: 1 branch
BranchTrueFalseTotal
if $class_value->native_constructor or $class_value->builtin_kind 0 2 2
Condition33%1/3
$class_value->native_constructor or $class_value->builtin_kind
l!l&&r!l&&!r
002
MC/DC0%0/2
$class_value->native_constructor or $class_value->builtin_kind
$class_value->native_constructor $class_value->builtin_kind
Truth table33%1/3
A or B
A= $class_value->native_constructorB= $class_value->builtin_kind
ABresult
1X1
011
000
1854 if $class_value->native_constructor or $class_value->builtin_kind;
1855  
1856 2 my $addr = refaddr($class_value);
1857 2 ▶ die "Class code value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 2 2
1858  
1859 return $state->{code_ids}{$addr}
1860 2 ▶ if exists $state->{code_ids}{$addr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $state->{"code_ids"}{$addr} 0 2 2
1861  
1862 2 my $analysis = _analyse_class_value( $runtime, $class_value );
1863  
1864 2 my $id = scalar @{ $state->{code} };
1865 2 $state->{code_ids}{$addr} = $id;
1866 2 push @{ $state->{code} }, undef;
1867  
1868 2 my $binding_name = _class_code_binding_name(
1869 $class_value,
1870 $state,
1871 $id,
1872 $preferred_name,
1873 );
1874 2 $state->{code_names}{$binding_name} = 1;
1875  
1876 my @captures = map {
1877 [
1878 text_string( $_->{name} ),
1879 0 _encode_scalar_value( $runtime, $_->{value} ),
1880 ]
1881 2 } @{ $analysis->{captures} };
1882 2 my @dependencies;
1883 2 for my $dependency ( @{ $analysis->{internal_dependencies} } ) {
1884 0 push @dependencies, _encode_code_dependency(
1885 $runtime,
1886 $dependency,
1887 $state,
1888 );
1889 }
1890 2 for my $dependency ( @{ $analysis->{external_dependencies} } ) {
1891 push @dependencies, [
1892 1,
1893 text_string( $dependency->{local_name} ),
1894 text_string( $dependency->{module} ),
1895 0 text_string( $dependency->{export_name} ),
1896 ];
1897 }
1898  
1899 $state->{code}[$id] = [
1900 CODE_CLASS,
1901 text_string($binding_name),
1902 2 text_string( $analysis->{source} ),
1903 \@captures,
1904 \@dependencies,
1905 ];
1906  
1907 2 return $id;
1908 }
1909  
1910 0 ▶sub _encode_trait_code {
Subroutine _encode_trait_code: not called CC=7 SCAR=40.3
1911 0 my ( $runtime, $trait_value, $state, $preferred_name ) = @_;
1912  
1913 0 ▶ die "Trait dependency is not a Trait value"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($trait_value) and $trait_value->isa("Zuzu::Value::Trait") 0 0 0
Condition0%0/3
builtin::blessed($trait_value) and $trait_value->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($trait_value) and $trait_value->isa("Zuzu::Value::Trait")
builtin::blessed($trait_value) $trait_value->isa("Zuzu::Value::Trait")
Truth table0%0/3
A and B
A= builtin::blessed($trait_value)B= $trait_value->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
1914 if !blessed($trait_value) or !$trait_value->isa('Zuzu::Value::Trait');
1915  
1916 0 my $addr = refaddr($trait_value);
1917 0 ▶ die "Trait code value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 0 0
1918  
1919 return $state->{code_ids}{$addr}
1920 0 ▶ if exists $state->{code_ids}{$addr};
Branch: 1 branch
BranchTrueFalseTotal
if exists $state->{"code_ids"}{$addr} 0 0 0
1921  
1922 0 my $analysis = _analyse_trait_value( $runtime, $trait_value );
1923  
1924 0 my $id = scalar @{ $state->{code} };
1925 0 $state->{code_ids}{$addr} = $id;
1926 0 push @{ $state->{code} }, undef;
1927  
1928 0 my $binding_name = _trait_code_binding_name(
1929 $trait_value,
1930 $state,
1931 $id,
1932 $preferred_name,
1933 );
1934 0 $state->{code_names}{$binding_name} = 1;
1935  
1936 my @captures = map {
1937 [
1938 text_string( $_->{name} ),
1939 0 _encode_scalar_value( $runtime, $_->{value} ),
1940 ]
1941 0 } @{ $analysis->{captures} };
1942 0 my @dependencies;
1943 0 for my $dependency ( @{ $analysis->{internal_dependencies} } ) {
1944 0 push @dependencies, _encode_code_dependency(
1945 $runtime,
1946 $dependency,
1947 $state,
1948 );
1949 }
1950 0 for my $dependency ( @{ $analysis->{external_dependencies} } ) {
1951 push @dependencies, [
1952 1,
1953 text_string( $dependency->{local_name} ),
1954 text_string( $dependency->{module} ),
1955 0 text_string( $dependency->{export_name} ),
1956 ];
1957 }
1958  
1959 $state->{code}[$id] = [
1960 CODE_TRAIT,
1961 text_string($binding_name),
1962 0 text_string( $analysis->{source} ),
1963 \@captures,
1964 \@dependencies,
1965 ];
1966  
1967 0 return $id;
1968 }
1969  
1970 0 ▶sub _encode_code_dependency {
Subroutine _encode_code_dependency: not called CC=7 SCAR=40.3
1971 0 my ( $runtime, $dependency, $state ) = @_;
1972  
1973 0 my $value = $dependency->{value};
1974 0 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Function') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Function")) 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
builtin::blessed($value) $value->isa("Zuzu::Value::Function")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
1975 return [
1976 0,
1977 _encode_function_code(
1978 $runtime,
1979 $value,
1980 $state,
1981 $dependency->{name},
1982 0 ),
1983 ];
1984 }
1985 0 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Class') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Class")) 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Class")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Class")
builtin::blessed($value) $value->isa("Zuzu::Value::Class")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
1986 return [
1987 0,
1988 _encode_class_code(
1989 $runtime,
1990 $value,
1991 $state,
1992 $dependency->{name},
1993 0 ),
1994 ];
1995 }
1996 0 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Trait') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")) 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")
builtin::blessed($value) $value->isa("Zuzu::Value::Trait")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
1997 return [
1998 0,
1999 _encode_trait_code(
2000 $runtime,
2001 $value,
2002 $state,
2003 $dependency->{name},
2004 0 ),
2005 ];
2006 }
2007 0 die "Internal code dependency '$dependency->{name}' has unsupported type";
2008 }
2009  
2010 1 ▶sub _function_code_binding_name {
Subroutine _function_code_binding_name: called CC=6 SCAR=21.6
2011 1 my ( $fn, $state, $id, $preferred_name ) = @_;
2012  
2013 1 for my $name ( $preferred_name, $fn->name ) {
2014 2 ▶ next if !defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 1 1 2
2015 1 ▶ next if !_is_identifier($name);
Branch: 1 branch
BranchTrueFalseTotal
unless _is_identifier($name) 1 0 1
2016 0 ▶ next if $state->{code_names}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $state->{"code_names"}{$name} 0 0 0
2017 0 return $name;
2018 }
2019  
2020 1 my $name = "__zuzu_marshal_fn_$id";
2021 1 ▶ while ( $state->{code_names}{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"code_names"}{$name}) 0 1 1
2022 0 $id++;
2023 0 $name = "__zuzu_marshal_fn_$id";
2024 }
2025  
2026 1 return $name;
2027 }
2028  
2029 2 ▶sub _class_code_binding_name {
Subroutine _class_code_binding_name: called CC=6 SCAR=22.9
2030 2 my ( $class_value, $state, $id, $preferred_name ) = @_;
2031  
2032 2 for my $name ( $preferred_name, $class_value->source_node->name ) {
2033 4 ▶ next if !defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 2 2 4
2034 2 ▶ next if !_is_identifier($name);
Branch: 1 branch
BranchTrueFalseTotal
unless _is_identifier($name) 0 2 2
2035 2 ▶ next if $state->{code_names}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $state->{"code_names"}{$name} 0 2 2
2036 2 return $name;
2037 }
2038  
2039 0 my $name = "__zuzu_marshal_class_$id";
2040 0 ▶ while ( $state->{code_names}{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"code_names"}{$name}) 0 0 0
2041 0 $id++;
2042 0 $name = "__zuzu_marshal_class_$id";
2043 }
2044  
2045 0 return $name;
2046 }
2047  
2048 0 ▶sub _trait_code_binding_name {
Subroutine _trait_code_binding_name: not called CC=6 SCAR=37.4
2049 0 my ( $trait_value, $state, $id, $preferred_name ) = @_;
2050  
2051 0 for my $name ( $preferred_name, $trait_value->source_node->name ) {
2052 0 ▶ next if !defined $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name 0 0 0
2053 0 ▶ next if !_is_identifier($name);
Branch: 1 branch
BranchTrueFalseTotal
unless _is_identifier($name) 0 0 0
2054 0 ▶ next if $state->{code_names}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $state->{"code_names"}{$name} 0 0 0
2055 0 return $name;
2056 }
2057  
2058 0 my $name = "__zuzu_marshal_trait_$id";
2059 0 ▶ while ( $state->{code_names}{$name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"code_names"}{$name}) 0 0 0
2060 0 $id++;
2061 0 $name = "__zuzu_marshal_trait_$id";
2062 }
2063  
2064 0 return $name;
2065 }
2066  
2067 15 ▶sub _is_identifier {
Subroutine _is_identifier: called CC=2 SCAR=7.1
2068 15 my ( $name ) = @_;
2069  
2070 15 ▶ return defined $name && $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/;
Condition66%2/3
defined $name && $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/
!ll&&!rl&&r
0114
MC/DC50%1/2
defined $name && $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/
defined $name $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/
Truth table66%2/3
A && B
A= defined $nameB= $name =~ /\A[A-Za-z_][A-Za-z0-9_]*\z/
ABresult
0X0
100
111
2071 }
2072  
2073 6 ▶sub _encode_object_value {
Subroutine _encode_object_value: called CC=9 SCAR=22.7
2074 6 my ( $runtime, $object, $state ) = @_;
2075  
2076 6 my $addr = refaddr($object);
2077 6 ▶ die "Object value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 6 6
2078  
2079 6 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 3 3 6
2080 3 my $id = $state->{strong_ids}{$addr};
2081 3 return [ 0, $id ];
2082 }
2083  
2084 3 _run_on_dump_hook( $runtime, $object, $state, $addr );
2085  
2086 3 my $native_constructor = $runtime->_native_constructor_for( $object->class );
2087 3 ▶ die "Runtime-backed object of type "
Branch: 2 branches
BranchTrueFalseTotal
if $native_constructor 0 3 3
$object->class ? : 0 0 0
2088 . ( $object->class ? $object->class->name : '<unknown>' )
2089 . " is not marshalable in this phase"
2090 if $native_constructor;
2091  
2092 3 my $id = scalar @{ $state->{objects} };
2093 3 $state->{strong_ids}{$addr} = $id;
2094 3 push @{ $state->{objects} }, undef;
2095  
2096 3 my $class_ref = _encode_strong_value( $runtime, $object->class, $state );
2097 3 ▶ my @slot_names = sort keys %{ $object->slots // {} };
Condition50%1/2
$object->slots // {}
l!l
30
MC/DC0%0/1
$object->slots // {}
$object->slots
Truth table50%1/2
A
A= $object->slots
Aresult
11
00
2098 3 for my $name ( @slot_names ) {
2099 2 ▶ next if $object->weak->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $object->weak->{$name} 2 0 2
2100 _encode_strong_value(
2101 $runtime,
2102 0 slot_value( \$object->slots->{$name} ),
2103 $state,
2104 );
2105 }
2106 my @slots = map {
2107 3 ▶ my $weak = $object->weak->{$_} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$object->weak->{$_} ? : 2 0 2
2108 [
2109 text_string($_),
2110 _encode_stored_value(
2111 $runtime,
2112 2 slot_value( \$object->slots->{$_} ),
2113 $state,
2114 $weak,
2115 ),
2116 ]
2117 } @slot_names;
2118 3 my $payload = [
2119 $class_ref,
2120 \@slots,
2121 ];
2122 3 $state->{objects}[$id] = [ KIND_OBJECT, $payload ];
2123  
2124 3 return [ 0, $id ];
2125 }
2126  
2127 0 ▶sub _hook_error_text {
Subroutine _hook_error_text: not called CC=9 SCAR=45.0
2128 0 my ( $runtime, $error ) = @_;
2129  
2130 0 ▶ if ( ref($error) eq 'HASH' and $error->{_zuzu_throw} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $error eq "HASH" and $error->{"_zuzu_throw"}) 0 0 0
Condition0%0/3
ref $error eq "HASH" and $error->{"_zuzu_throw"}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $error eq "HASH" and $error->{"_zuzu_throw"}
ref $error eq "HASH" $error->{"_zuzu_throw"}
Truth table0%0/3
A and B
A= ref $error eq "HASH"B= $error->{"_zuzu_throw"}
ABresult
0X0
100
111
2131 0 my $value = $error->{value};
2132 0 my $text;
2133 0 local $@;
2134 eval {
2135 0 $text = $runtime->_to_String($value);
2136 0 1;
2137 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $text = $runtime->_to_String($value); 1 } } or do { $text = "$value" } 0 0 0
2138 0 $text = "$value";
2139 };
2140  
2141 0 ▶ if ( blessed($value) and $value->isa('Zuzu::Value::Object') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($value) and $value->isa("Zuzu::Value::Object")) 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
builtin::blessed($value) $value->isa("Zuzu::Value::Object")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
2142 0 ▶ my $slots = $value->slots // {};
Condition0%0/2
$value->slots // {}
l!l
00
MC/DC0%0/1
$value->slots // {}
$value->slots
Truth table0%0/2
A
A= $value->slots
Aresult
11
00
2143 0 my $file = $slots->{file};
2144 0 my $line = $slots->{line};
2145 0 ▶ $text .= " at $file, line $line"
Branch: 1 branch
BranchTrueFalseTotal
if defined $file and defined $line 0 0 0
Condition0%0/3
defined $file and defined $line
!ll&&!rl&&r
000
MC/DC0%0/2
defined $file and defined $line
defined $file defined $line
Truth table0%0/3
A and B
A= defined $fileB= defined $line
ABresult
0X0
100
111
2146 if defined $file and defined $line;
2147 }
2148  
2149 0 return $text;
2150 }
2151  
2152 0 return "$error";
2153 }
2154  
2155 3 ▶sub _run_on_dump_hook {
Subroutine _run_on_dump_hook: called CC=5 SCAR=25.7
2156 3 my ( $runtime, $object, $state, $addr ) = @_;
2157  
2158 3 ▶ return if $state->{on_dump}{$addr}++;
Branch: 1 branch
BranchTrueFalseTotal
if $state->{"on_dump"}{$addr}++ 0 3 3
2159  
2160 3 my $method = $runtime->_lookup_method( $object->class, '__on_dump__', 0 );
2161 3 ▶ return if !$method;
Branch: 1 branch
BranchTrueFalseTotal
unless $method 3 0 3
2162  
2163 eval {
2164 0 $runtime->_call_method(
2165 $method,
2166 $object,
2167 [],
2168 {},
2169 [],
2170 _call_file($runtime),
2171 _call_line($runtime),
2172 );
2173 0 1;
2174 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $runtime->_call_method($method, $object, [], {}, [], _call_file($runtime), _call_line($runtime)); 1 } } or do { my $error = $@; my $class = $object->class ? $object->class->name : "<unknown>"; die "__on_dump__ for $class failed: " . _hook_error_text($runtime, $error) } 0 0 0
2175 0 my $error = $@;
2176 0 ▶ my $class = $object->class ? $object->class->name : '<unknown>';
Branch: 1 branch
BranchTrueFalseTotal
$object->class ? : 0 0 0
2177 0 die "__on_dump__ for $class failed: "
2178 . _hook_error_text( $runtime, $error );
2179 };
2180  
2181 0 return;
2182 }
2183  
2184 41 ▶sub _is_time_value {
Subroutine _is_time_value: called CC=4 SCAR=13.9
2185 41 my ( $runtime, $value ) = @_;
2186  
2187 return 0
2188 if !blessed($value)
2189 or !$value->isa('Zuzu::Value::Object')
2190 41 ▶ or !exists $value->slots->{_epoch};
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Object") and exists $value->slots->{"_epoch"} 39 2 41
Condition83%5/6
builtin::blessed($value) and $value->isa("Zuzu::Value::Object") and exists $value->slots->{"_epoch"}
!ll&&!rl&&r
3182
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
03110
MC/DC66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object") and exists $value->slots->{"_epoch"}
builtin::blessed($value) $value->isa("Zuzu::Value::Object") exists $value->slots->{"_epoch"}
Truth table75%3/4
A and B and C
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")C= exists $value->slots->{"_epoch"}
ABCresult
0XX0
10X0
1100
1111
2191  
2192 2 return _object_is_module_class( $runtime, $value, 'std/time', 'Time' );
2193 }
2194  
2195 39 ▶sub _is_path_value {
Subroutine _is_path_value: called CC=4 SCAR=13.9
2196 39 my ( $runtime, $value ) = @_;
2197  
2198 return 0
2199 if !blessed($value)
2200 or !$value->isa('Zuzu::Value::Object')
2201 39 ▶ or !exists $value->slots->{_path_tiny};
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Object") and exists $value->slots->{"_path_tiny"} 37 2 39
Condition83%5/6
builtin::blessed($value) and $value->isa("Zuzu::Value::Object") and exists $value->slots->{"_path_tiny"}
!ll&&!rl&&r
3162
builtin::blessed($value) and $value->isa("Zuzu::Value::Object")
!ll&&!rl&&r
0318
MC/DC66%2/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Object") and exists $value->slots->{"_path_tiny"}
builtin::blessed($value) $value->isa("Zuzu::Value::Object") exists $value->slots->{"_path_tiny"}
Truth table75%3/4
A and B and C
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Object")C= exists $value->slots->{"_path_tiny"}
ABCresult
0XX0
10X0
1100
1111
2202  
2203 2 return _object_is_module_class( $runtime, $value, 'std/io', 'Path' );
2204 }
2205  
2206 2 ▶sub _encode_time_value {
Subroutine _encode_time_value: called CC=4 SCAR=13.9
2207 2 my ( $runtime, $time, $state ) = @_;
2208  
2209 2 my $addr = refaddr($time);
2210 2 ▶ die "Time value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 2 2
2211  
2212 2 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 1 1 2
2213 1 my $id = $state->{strong_ids}{$addr};
2214 1 return [ 0, $id ];
2215 }
2216  
2217 1 my $id = scalar @{ $state->{objects} };
2218 1 $state->{strong_ids}{$addr} = $id;
2219 1 push @{ $state->{objects} }, undef;
2220  
2221 1 my $epoch = $time->slots->{_epoch};
2222 1 my @payload = ( _number_to_cbor($epoch) );
2223 push @payload, text_string( $time->slots->{_timezone} )
2224 1 ▶ if exists $time->slots->{_timezone};
Branch: 1 branch
BranchTrueFalseTotal
if exists $time->slots->{"_timezone"} 1 0 1
2225 1 $state->{objects}[$id] = [ KIND_TIME, \@payload ];
2226  
2227 1 return [ 0, $id ];
2228 }
2229  
2230 2 ▶sub _encode_path_value {
Subroutine _encode_path_value: called CC=6 SCAR=18.6
2231 2 my ( $runtime, $path_value, $state ) = @_;
2232  
2233 2 my $addr = refaddr($path_value);
2234 2 ▶ die "Path value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 2 2
2235  
2236 2 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 1 1 2
2237 1 my $id = $state->{strong_ids}{$addr};
2238 1 return [ 0, $id ];
2239 }
2240  
2241 1 my $id = scalar @{ $state->{objects} };
2242 1 $state->{strong_ids}{$addr} = $id;
2243 1 push @{ $state->{objects} }, undef;
2244  
2245 1 my $path_obj = $path_value->slots->{_path_tiny};
2246 1 ▶ die "Path value has invalid internal path"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path_obj and ref $path_obj and $path_obj->can("stringify") 0 1 1
Condition33%2/6
defined $path_obj and ref $path_obj and $path_obj->can("stringify")
!ll&&!rl&&r
001
defined $path_obj and ref $path_obj
!ll&&!rl&&r
001
MC/DC0%0/3
defined $path_obj and ref $path_obj and $path_obj->can("stringify")
defined $path_obj ref $path_obj $path_obj->can("stringify")
Truth table25%1/4
A and B and C
A= defined $path_objB= ref $path_objC= $path_obj->can("stringify")
ABCresult
0XX0
10X0
1100
1111
2247 if !defined $path_obj or !ref($path_obj) or !$path_obj->can('stringify');
2248 1 $state->{objects}[$id] = [
2249 KIND_PATH,
2250 [ text_string( $path_obj->stringify ) ],
2251 ];
2252  
2253 1 return [ 0, $id ];
2254 }
2255  
2256 13 ▶sub _encode_array_value {
Subroutine _encode_array_value: called CC=8 SCAR=20.8
2257 13 my ( $runtime, $array, $state ) = @_;
2258  
2259 13 my $addr = refaddr($array);
2260 13 ▶ die "Array value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 13 13
2261  
2262 13 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 4 9 13
2263 4 my $id = $state->{strong_ids}{$addr};
2264 4 return [ 0, $id ];
2265 }
2266  
2267 9 my $id = scalar @{ $state->{objects} };
2268 9 $state->{strong_ids}{$addr} = $id;
2269 9 push @{ $state->{objects} }, undef;
2270  
2271 9 ▶ for ( my $i = 0; $i < @{ $array->items // [] }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$array->items // [];}) 18 9 27
Condition50%1/2
$array->items // []
l!l
270
MC/DC0%0/1
$array->items // []
$array->items
Truth table50%1/2
A
A= $array->items
Aresult
11
00
2272 18 ▶ next if $array->weak->[$i];
Branch: 1 branch
BranchTrueFalseTotal
if $array->weak->[$i] 3 15 18
2273 15 _encode_strong_value( $runtime, $array->_value_at($i), $state );
2274 }
2275 my @payload = map {
2276 18 ▶ my $weak = $array->weak->[$_] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$array->weak->[$_] ? : 3 15 18
2277 18 _encode_stored_value(
2278 $runtime,
2279 $array->_value_at($_),
2280 $state,
2281 $weak,
2282 );
2283 9 ▶ } 0 .. $#{ $array->items // [] };
Condition50%1/2
$array->items // []
l!l
90
MC/DC0%0/1
$array->items // []
$array->items
Truth table50%1/2
A
A= $array->items
Aresult
11
00
2284  
2285 9 $state->{objects}[$id] = [ KIND_ARRAY, \@payload ];
2286  
2287 9 return [ 0, $id ];
2288 }
2289  
2290 6 ▶sub _encode_dict_value {
Subroutine _encode_dict_value: called CC=7 SCAR=19.5
2291 6 my ( $runtime, $dict, $state ) = @_;
2292  
2293 6 my $addr = refaddr($dict);
2294 6 ▶ die "Dict value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 6 6
2295  
2296 6 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 3 3 6
2297 3 my $id = $state->{strong_ids}{$addr};
2298 3 return [ 0, $id ];
2299 }
2300  
2301 3 my $id = scalar @{ $state->{objects} };
2302 3 $state->{strong_ids}{$addr} = $id;
2303 3 push @{ $state->{objects} }, undef;
2304  
2305 3 ▶ my @keys = sort keys %{ $dict->map // {} };
Condition50%1/2
$dict->map // {}
l!l
30
MC/DC0%0/1
$dict->map // {}
$dict->map
Truth table50%1/2
A
A= $dict->map
Aresult
11
00
2306 3 for my $key ( @keys ) {
2307 4 ▶ next if $dict->weak->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $dict->weak->{$key} 2 2 4
2308 2 _encode_strong_value( $runtime, $dict->_value_for_key($key), $state );
2309 }
2310 my @payload = map {
2311 3 ▶ my $weak = $dict->weak->{$_} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$dict->weak->{$_} ? : 2 2 4
2312 [
2313 4 text_string($_),
2314 _encode_stored_value(
2315 $runtime,
2316 $dict->_value_for_key($_),
2317 $state,
2318 $weak,
2319 ),
2320 ]
2321 } @keys;
2322  
2323 3 $state->{objects}[$id] = [ KIND_DICT, \@payload ];
2324  
2325 3 return [ 0, $id ];
2326 }
2327  
2328 4 ▶sub _encode_pairlist_value {
Subroutine _encode_pairlist_value: called CC=8 SCAR=20.8
2329 4 my ( $runtime, $pairlist, $state ) = @_;
2330  
2331 4 my $addr = refaddr($pairlist);
2332 4 ▶ die "PairList value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 4 4
2333  
2334 4 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 2 2 4
2335 2 my $id = $state->{strong_ids}{$addr};
2336 2 return [ 0, $id ];
2337 }
2338  
2339 2 my $id = scalar @{ $state->{objects} };
2340 2 $state->{strong_ids}{$addr} = $id;
2341 2 push @{ $state->{objects} }, undef;
2342  
2343 2 ▶ for ( my $i = 0; $i < @{ $pairlist->list // [] }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$pairlist->list // [];}) 4 2 6
Condition50%1/2
$pairlist->list // []
l!l
60
MC/DC0%0/1
$pairlist->list // []
$pairlist->list
Truth table50%1/2
A
A= $pairlist->list
Aresult
11
00
2344 4 ▶ next if $pairlist->weak->[$i];
Branch: 1 branch
BranchTrueFalseTotal
if $pairlist->weak->[$i] 1 3 4
2345 3 _encode_strong_value( $runtime, $pairlist->_value_at($i), $state );
2346 }
2347 my @payload = map {
2348 4 ▶ my $weak = $pairlist->weak->[$_] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$pairlist->weak->[$_] ? : 1 3 4
2349 [
2350 4 text_string( $pairlist->list->[$_][0] ),
2351 _encode_stored_value(
2352 $runtime,
2353 $pairlist->_value_at($_),
2354 $state,
2355 $weak,
2356 ),
2357 ]
2358 2 ▶ } 0 .. $#{ $pairlist->list // [] };
Condition50%1/2
$pairlist->list // []
l!l
20
MC/DC0%0/1
$pairlist->list // []
$pairlist->list
Truth table50%1/2
A
A= $pairlist->list
Aresult
11
00
2359  
2360 2 $state->{objects}[$id] = [ KIND_PAIRLIST, \@payload ];
2361  
2362 2 return [ 0, $id ];
2363 }
2364  
2365 2 ▶sub _encode_set_value {
Subroutine _encode_set_value: called CC=8 SCAR=21.2
2366 2 my ( $runtime, $set, $state ) = @_;
2367  
2368 2 my $addr = refaddr($set);
2369 2 ▶ die "Set value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 2 2
2370  
2371 2 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 1 1 2
2372 1 my $id = $state->{strong_ids}{$addr};
2373 1 return [ 0, $id ];
2374 }
2375  
2376 1 my $id = scalar @{ $state->{objects} };
2377 1 $state->{strong_ids}{$addr} = $id;
2378 1 push @{ $state->{objects} }, undef;
2379  
2380 1 ▶ for ( my $i = 0; $i < @{ $set->items // [] }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$set->items // [];}) 1 1 2
Condition50%1/2
$set->items // []
l!l
20
MC/DC0%0/1
$set->items // []
$set->items
Truth table50%1/2
A
A= $set->items
Aresult
11
00
2381 1 ▶ next if $set->weak->[$i];
Branch: 1 branch
BranchTrueFalseTotal
if $set->weak->[$i] 1 0 1
2382 0 _encode_strong_value( $runtime, $set->_value_at($i), $state );
2383 }
2384 my @payload = map {
2385 1 ▶ my $weak = $set->weak->[$_] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$set->weak->[$_] ? : 1 0 1
2386 1 _encode_stored_value(
2387 $runtime,
2388 $set->_value_at($_),
2389 $state,
2390 $weak,
2391 );
2392 1 ▶ } 0 .. $#{ $set->items // [] };
Condition50%1/2
$set->items // []
l!l
10
MC/DC0%0/1
$set->items // []
$set->items
Truth table50%1/2
A
A= $set->items
Aresult
11
00
2393  
2394 1 $state->{objects}[$id] = [ KIND_SET, \@payload ];
2395  
2396 1 return [ 0, $id ];
2397 }
2398  
2399 2 ▶sub _encode_bag_value {
Subroutine _encode_bag_value: called CC=8 SCAR=21.2
2400 2 my ( $runtime, $bag, $state ) = @_;
2401  
2402 2 my $addr = refaddr($bag);
2403 2 ▶ die "Bag value has no stable identity" if !defined $addr;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $addr 0 2 2
2404  
2405 2 ▶ if ( exists $state->{strong_ids}{$addr} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $state->{"strong_ids"}{$addr}) 1 1 2
2406 1 my $id = $state->{strong_ids}{$addr};
2407 1 return [ 0, $id ];
2408 }
2409  
2410 1 my $id = scalar @{ $state->{objects} };
2411 1 $state->{strong_ids}{$addr} = $id;
2412 1 push @{ $state->{objects} }, undef;
2413  
2414 1 ▶ for ( my $i = 0; $i < @{ $bag->items // [] }; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$bag->items // [];}) 1 1 2
Condition50%1/2
$bag->items // []
l!l
20
MC/DC0%0/1
$bag->items // []
$bag->items
Truth table50%1/2
A
A= $bag->items
Aresult
11
00
2415 1 ▶ next if $bag->weak->[$i];
Branch: 1 branch
BranchTrueFalseTotal
if $bag->weak->[$i] 1 0 1
2416 0 _encode_strong_value( $runtime, $bag->_value_at($i), $state );
2417 }
2418 my @payload = map {
2419 1 ▶ my $weak = $bag->weak->[$_] ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$bag->weak->[$_] ? : 1 0 1
2420 1 _encode_stored_value(
2421 $runtime,
2422 $bag->_value_at($_),
2423 $state,
2424 $weak,
2425 );
2426 1 ▶ } 0 .. $#{ $bag->items // [] };
Condition50%1/2
$bag->items // []
l!l
10
MC/DC0%0/1
$bag->items // []
$bag->items
Truth table50%1/2
A
A= $bag->items
Aresult
11
00
2427  
2428 1 $state->{objects}[$id] = [ KIND_BAG, \@payload ];
2429  
2430 1 return [ 0, $id ];
2431 }
2432  
2433 9 ▶sub _encode_envelope {
Subroutine _encode_envelope: called CC=1 SCAR=0.0
2434 9 my ( $runtime, $value ) = @_;
2435  
2436 9 my $state = _new_dump_state();
2437 9 my $root = _encode_strong_value( $runtime, $value, $state );
2438 return tag(
2439 55799,
2440 [
2441 text_string('ZUZU-MARSHAL'),
2442 1,
2443 {},
2444 $root,
2445 $state->{objects},
2446 $state->{code},
2447 9 ],
2448 );
2449 }
2450  
2451 27 ▶sub _decode_envelope {
Subroutine _decode_envelope: called CC=12 SCAR=28.1
2452 27 my ( $runtime, $decoded ) = @_;
2453  
2454 27 ▶ die "Top-level item is not tag 55799"
Branch: 1 branch
BranchTrueFalseTotal
if not is_tagged($decoded) or tag_number($decoded) != 55799 0 27 27
Condition33%1/3
not is_tagged($decoded) or tag_number($decoded) != 55799
l!l&&r!l&&!r
0027
MC/DC0%0/2
not is_tagged($decoded) or tag_number($decoded) != 55799
not is_tagged($decoded) tag_number($decoded) != 55799
Truth table33%1/3
not(A) or B
A= not is_tagged($decoded)B= tag_number($decoded) != 55799
ABresult
1X1
011
000
2455 if !is_tagged($decoded) or tag_number($decoded) != 55799;
2456  
2457 27 my $envelope = tag_value($decoded);
2458 27 ▶ die "Envelope must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $envelope ne "ARRAY" 0 27 27
2459 if ref($envelope) ne 'ARRAY';
2460 die "Envelope must contain exactly 6 fields"
2461 27 ▶ if scalar @{ $envelope } != 6;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$envelope;} != 6 0 27 27
2462  
2463 my ( $magic, $version, $options, $root, $objects, $code ) =
2464 27 @{ $envelope };
2465  
2466 27 ▶ die "Envelope magic is invalid"
Branch: 1 branch
BranchTrueFalseTotal
if not is_text_string($magic) or text_value($magic) ne "ZUZU-MARSHAL" 0 27 27
Condition33%1/3
not is_text_string($magic) or text_value($magic) ne "ZUZU-MARSHAL"
l!l&&r!l&&!r
0027
MC/DC0%0/2
not is_text_string($magic) or text_value($magic) ne "ZUZU-MARSHAL"
not is_text_string($magic) text_value($magic) ne "ZUZU-MARSHAL"
Truth table33%1/3
not(A) or B
A= not is_text_string($magic)B= text_value($magic) ne "ZUZU-MARSHAL"
ABresult
1X1
011
000
2467 if !is_text_string($magic) or text_value($magic) ne 'ZUZU-MARSHAL';
2468 27 ▶ die "Unsupported Zuzu Marshal version"
Branch: 1 branch
BranchTrueFalseTotal
if ref $version or $version != 1 0 27 27
Condition33%1/3
ref $version or $version != 1
l!l&&r!l&&!r
0027
MC/DC0%0/2
ref $version or $version != 1
ref $version $version != 1
Truth table33%1/3
A or B
A= ref $versionB= $version != 1
ABresult
1X1
011
000
2469 if ref($version) or $version != 1;
2470 27 ▶ die "Envelope options must be a map"
Branch: 1 branch
BranchTrueFalseTotal
if ref $options ne "HASH" 0 27 27
2471 if ref($options) ne 'HASH';
2472 27 ▶ die "Envelope object table must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $objects ne "ARRAY" 0 27 27
2473 if ref($objects) ne 'ARRAY';
2474 27 ▶ die "Envelope code table must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $code ne "ARRAY" 0 27 27
2475 if ref($code) ne 'ARRAY';
2476  
2477 27 my $code_values = _load_code_table( $runtime, $code );
2478 20 my $placeholders = _allocate_object_placeholders(
2479 $runtime,
2480 $objects,
2481 $code_values,
2482 );
2483 16 _fill_object_placeholders( $runtime, $objects, $placeholders );
2484 12 my $value = _decode_value(
2485 $runtime,
2486 $root,
2487 $placeholders,
2488 allow_weak => 0,
2489 context => 'Envelope root',
2490 );
2491 9 _run_on_load_hooks( $runtime, $objects, $placeholders );
2492  
2493 9 return $value;
2494 }
2495  
2496 20 ▶sub _allocate_object_placeholders {
Subroutine _allocate_object_placeholders: called CC=18 SCAR=29.7
2497 20 my ( $runtime, $objects, $code_values ) = @_;
2498  
2499 20 my @placeholders;
2500 20 for my $id ( 0 .. $#{ $objects } ) {
2501 33 my $entry = $objects->[$id];
2502 die "Object table entry $id must be a two-item array"
2503 33 ▶ if ref($entry) ne 'ARRAY' or scalar @{ $entry } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $entry ne "ARRAY" or scalar @{$entry;} != 2 0 33 33
Condition33%1/3
ref $entry ne "ARRAY" or scalar @{$entry;} != 2
l!l&&r!l&&!r
0033
MC/DC0%0/2
ref $entry ne "ARRAY" or scalar @{$entry;} != 2
ref $entry ne "ARRAY" scalar @{$entry;} != 2
Truth table33%1/3
A or B
A= ref $entry ne "ARRAY"B= scalar @{$entry;} != 2
ABresult
1X1
011
000
2504  
2505 33 my ( $kind ) = @{ $entry };
2506 33 ▶ die "Object table entry $id kind must be an integer"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_integer_value($kind) 1 32 33
2507 if !_is_integer_value($kind);
2508 32 ▶ if ( $kind == KIND_PAIR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 1) 1 31 32
2509 1 my $pair_array = Zuzu::Value::Array->new( items => [] );
2510 $placeholders[$id] = $runtime->_instantiate_builtin_object(
2511 $runtime->{_builtin_classes}{Pair},
2512 {
2513 1 pair => $pair_array,
2514 },
2515 );
2516 1 next;
2517 }
2518 31 ▶ if ( $kind == KIND_ARRAY ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 2) 12 19 31
2519 12 $placeholders[$id] = Zuzu::Value::Array->new( items => [] );
2520 12 next;
2521 }
2522 19 ▶ if ( $kind == KIND_DICT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 3) 4 15 19
2523 4 $placeholders[$id] = Zuzu::Value::Dict->new( map => {} );
2524 4 next;
2525 }
2526 15 ▶ if ( $kind == KIND_PAIRLIST ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 4) 2 13 15
2527 2 $placeholders[$id] = Zuzu::Value::PairList->new( list => [] );
2528 2 next;
2529 }
2530 13 ▶ if ( $kind == KIND_SET ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 5) 1 12 13
2531 1 $placeholders[$id] = Zuzu::Value::Set->new( items => [] );
2532 1 next;
2533 }
2534 12 ▶ if ( $kind == KIND_BAG ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 6) 1 11 12
2535 1 $placeholders[$id] = Zuzu::Value::Bag->new( items => [] );
2536 1 next;
2537 }
2538 11 ▶ if ( $kind == KIND_OBJECT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 7) 4 7 11
2539 4 $placeholders[$id] = Zuzu::Value::Object->new(
2540 class => undef,
2541 slots => {},
2542 const => {},
2543 types => {},
2544 weak => {},
2545 );
2546 4 next;
2547 }
2548 7 ▶ if ( $kind == KIND_FUNCTION ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 8) 2 5 7
2549 2 $placeholders[$id] = _decode_function_payload(
2550 $runtime,
2551 $id,
2552 $entry->[1],
2553 $code_values,
2554 );
2555 1 next;
2556 }
2557 5 ▶ if ( $kind == KIND_CLASS ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 9) 3 2 5
2558 3 $placeholders[$id] =
2559 _decode_class_payload(
2560 $runtime,
2561 $id,
2562 $entry->[1],
2563 $code_values,
2564 );
2565 3 next;
2566 }
2567 2 ▶ if ( $kind == KIND_TRAIT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 10) 0 2 2
2568 0 $placeholders[$id] = _decode_trait_payload(
2569 $runtime,
2570 $id,
2571 $entry->[1],
2572 $code_values,
2573 );
2574 0 next;
2575 }
2576 2 ▶ if ( $kind == KIND_BOUND_METHOD ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 11) 0 2 2
2577 0 $placeholders[$id] = Zuzu::Value::Function->new(
2578 name => '<pending bound method>',
2579 params => [],
2580 body => undef,
2581 closure_env => undef,
2582 );
2583 0 $placeholders[$id]{_is_method} = 1;
2584 0 next;
2585 }
2586 2 ▶ if ( $kind == KIND_TIME ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 12) 1 1 2
2587 1 $placeholders[$id] = _new_time_placeholder($runtime);
2588 0 next;
2589 }
2590 1 ▶ if ( $kind == KIND_PATH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 13) 0 1 1
2591 0 $placeholders[$id] = _new_path_placeholder($runtime);
2592 0 next;
2593 }
2594 1 die "Unsupported object kind $kind in current loader";
2595 }
2596  
2597 16 return \@placeholders;
2598 }
2599  
2600 16 ▶sub _fill_object_placeholders {
Subroutine _fill_object_placeholders: called CC=22 SCAR=36.0
2601 16 my ( $runtime, $objects, $placeholders ) = @_;
2602  
2603 16 for my $id ( 0 .. $#{ $objects } ) {
2604 27 my ( $kind, $payload ) = @{ $objects->[$id] };
2605 27 ▶ if ( $kind == KIND_PAIR ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 1) 1 26 27
2606 die "Pair object payload $id must be a two-item array"
2607 1 ▶ if ref($payload) ne 'ARRAY' or scalar @{ $payload } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" or scalar @{$payload;} != 2 1 0 1
Condition33%1/3
ref $payload ne "ARRAY" or scalar @{$payload;} != 2
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $payload ne "ARRAY" or scalar @{$payload;} != 2
ref $payload ne "ARRAY" scalar @{$payload;} != 2
Truth table33%1/3
A or B
A= ref $payload ne "ARRAY"B= scalar @{$payload;} != 2
ABresult
1X1
011
000
2608 0 my ( $key, $value ) = @{ $payload };
2609 0 ▶ die "Pair object payload $id key must be a text string"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($key) 0 0 0
2610 if !is_text_string($key);
2611 0 my ( $decoded_value, $weak ) = _decode_stored_value(
2612 $runtime,
2613 $value,
2614 $placeholders,
2615 "Pair object payload $id value",
2616 );
2617 0 my $pair_array = _pair_slot_array( $placeholders->[$id] );
2618 0 $pair_array->_store_at( 0, text_value($key), 0 );
2619 0 $pair_array->_store_at( 1, $decoded_value, $weak );
2620 0 next;
2621 }
2622 26 ▶ if ( $kind == KIND_ARRAY ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 2) 11 15 26
2623 11 ▶ die "Array object payload $id must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" 1 10 11
2624 if ref($payload) ne 'ARRAY';
2625 10 my $array = $placeholders->[$id];
2626 10 $array->items( [] );
2627 10 $array->weak( [] );
2628 10 for my $encoded ( @{ $payload } ) {
2629 17 my ( $value, $weak ) = _decode_stored_value(
2630 $runtime,
2631 $encoded,
2632 $placeholders,
2633 "Array object payload $id item",
2634 );
2635 17 $array->_store_at( $array->length, $value, $weak );
2636 }
2637 10 next;
2638 }
2639 15 ▶ if ( $kind == KIND_DICT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 3) 4 11 15
2640 4 my ( $map, $weak ) = _decode_dict_payload(
2641 $runtime,
2642 $id,
2643 $payload,
2644 $placeholders,
2645 );
2646 3 $placeholders->[$id]->map($map);
2647 3 $placeholders->[$id]->weak($weak);
2648 3 next;
2649 }
2650 11 ▶ if ( $kind == KIND_PAIRLIST ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 4) 2 9 11
2651 2 my ( $list, $weak ) = _decode_pairlist_payload(
2652 $runtime,
2653 $id,
2654 $payload,
2655 $placeholders,
2656 );
2657 2 $placeholders->[$id]->list($list);
2658 2 $placeholders->[$id]->weak($weak);
2659 2 next;
2660 }
2661 9 ▶ if ( $kind == KIND_SET ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 5) 1 8 9
2662 1 my $set = $placeholders->[$id];
2663 1 my @items = _decode_item_payload_records(
2664 $runtime,
2665 "Set object payload $id",
2666 $payload,
2667 $placeholders,
2668 );
2669 1 for my $record ( @items ) {
2670 1 my ( $value, $weak ) = @{ $record };
2671 1 my $index = $set->length;
2672 1 $set->_store_at( $index, $value, $weak );
2673 }
2674 1 $set->_uniq;
2675 1 next;
2676 }
2677 8 ▶ if ( $kind == KIND_BAG ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 6) 1 7 8
2678 1 my @items = _decode_item_payload_records(
2679 $runtime,
2680 "Bag object payload $id",
2681 $payload,
2682 $placeholders,
2683 );
2684 1 my $bag = $placeholders->[$id];
2685 1 $bag->items( [] );
2686 1 $bag->weak( [] );
2687 1 for my $record ( @items ) {
2688 1 my ( $value, $weak ) = @{ $record };
2689 1 $bag->_store_at( $bag->length, $value, $weak );
2690 }
2691 1 next;
2692 }
2693 7 ▶ if ( $kind == KIND_OBJECT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 7) 4 3 7
2694 4 _fill_object_payload(
2695 $runtime,
2696 $id,
2697 $payload,
2698 $placeholders,
2699 );
2700 3 next;
2701 }
2702 3 ▶ if ( $kind == KIND_FUNCTION ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 8) 1 2 3
2703 1 next;
2704 }
2705 2 ▶ if ( $kind == KIND_CLASS ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 9) 2 0 2
2706 2 next;
2707 }
2708 0 ▶ if ( $kind == KIND_TRAIT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 10) 0 0 0
2709 0 next;
2710 }
2711 0 ▶ if ( $kind == KIND_BOUND_METHOD ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 11) 0 0 0
2712 0 next;
2713 }
2714 0 ▶ if ( $kind == KIND_TIME ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 12) 0 0 0
2715 0 my ( $epoch, $timezone ) = _decode_time_payload( $id, $payload );
2716 0 $placeholders->[$id]->slots->{_epoch} = $epoch;
2717 0 $placeholders->[$id]->slots->{_timezone} = $timezone;
2718 0 next;
2719 }
2720 0 ▶ if ( $kind == KIND_PATH ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 13) 0 0 0
2721 $placeholders->[$id]->slots->{_path_tiny} =
2722 0 path( _decode_path_payload( $id, $payload ) );
2723 0 next;
2724 }
2725 0 die "Unsupported object kind $kind in current loader";
2726 }
2727  
2728 12 _fill_bound_method_placeholders( $runtime, $objects, $placeholders );
2729 }
2730  
2731 27 ▶sub _load_code_table {
Subroutine _load_code_table: called CC=13 SCAR=25.9
2732 27 my ( $runtime, $code ) = @_;
2733  
2734 27 my $shared = Zuzu::Env->new( parent => undef );
2735 27 ▶ for my $name ( sort keys %{ $runtime->{_builtin_global_names} // {} } ) {
Condition50%1/2
$runtime->{"_builtin_global_names"} // {}
l!l
270
MC/DC0%0/1
$runtime->{"_builtin_global_names"} // {}
$runtime->{"_builtin_global_names"}
Truth table50%1/2
A
A= $runtime->{"_builtin_global_names"}
Aresult
11
00
2736 945 my $ref = $runtime->{_global}->find_ref($name);
2737 945 ▶ next if !defined $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ref 0 945 945
2738 $shared->alias_to_ref(
2739 $name,
2740 $ref,
2741 $runtime->{_global}{const}{$name} ? 1 : 0,
2742 945 ▶ $runtime->{_global}{types}{$name} // 'Any',
Branch: 1 branch
BranchTrueFalseTotal
$runtime->{'_global'}{'const'}{$name} ? : 918 27 945
Condition50%1/2
$runtime->{"_global"}{"types"}{$name} // "Any"
l!l
9450
MC/DC0%0/1
$runtime->{"_global"}{"types"}{$name} // "Any"
$runtime->{"_global"}{"types"}{$name}
Truth table50%1/2
A
A= $runtime->{"_global"}{"types"}{$name}
Aresult
11
00
2743 );
2744 }
2745  
2746 27 my @records;
2747 my @refs;
2748 27 my %code_names;
2749 27 for my $id ( 0 .. $#{ $code } ) {
2750 11 my $record = _validate_code_record( $id, $code->[$id] );
2751 die "Unsupported code kind $record->{kind} in current loader"
2752 if $record->{kind} != CODE_FUNCTION
2753 and $record->{kind} != CODE_CLASS
2754 10 ▶ and $record->{kind} != CODE_TRAIT;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"kind"} != 1 and $record->{"kind"} != 2 and $record->{"kind"} != 3 1 9 10
Condition83%5/6
$record->{"kind"} != 1 and $record->{"kind"} != 2 and $record->{"kind"} != 3
!ll&&!rl&&r
901
$record->{"kind"} != 1 and $record->{"kind"} != 2
!ll&&!rl&&r
361
MC/DC66%2/3
$record->{"kind"} != 1 and $record->{"kind"} != 2 and $record->{"kind"} != 3
$record->{"kind"} != 1 $record->{"kind"} != 2 $record->{"kind"} != 3
Truth table75%3/4
A and B and C
A= $record->{"kind"} != 1B= $record->{"kind"} != 2C= $record->{"kind"} != 3
ABCresult
0XX0
10X0
1100
1111
2755 die "Duplicate code binding '$record->{binding_name}'"
2756 9 ▶ if $code_names{ $record->{binding_name} }++;
Branch: 1 branch
BranchTrueFalseTotal
if $code_names{$record->{"binding_name"}}++ 0 9 9
2757 9 my $ref = $shared->declare( $record->{binding_name}, undef, 1 );
2758 9 $refs[$id] = $ref;
2759 9 $records[$id] = $record;
2760 }
2761  
2762 25 for my $id ( 0 .. $#records ) {
2763 9 _install_external_dependencies(
2764 $runtime,
2765 $shared,
2766 $id,
2767 $records[$id],
2768 scalar(@records),
2769 );
2770 }
2771  
2772 22 my @values;
2773 my @status;
2774 22 for my $id ( 0 .. $#records ) {
2775 6 _load_code_record_by_id(
2776 $runtime,
2777 $shared,
2778 \@records,
2779 \@refs,
2780 \@values,
2781 \@status,
2782 $id,
2783 );
2784 }
2785  
2786 20 return \@values;
2787 }
2788  
2789 11 ▶sub _validate_code_record {
Subroutine _validate_code_record: called CC=9 SCAR=23.5
2790 11 my ( $id, $record ) = @_;
2791  
2792 die "Code table entry $id must be a five-item array"
2793 11 ▶ if ref($record) ne 'ARRAY' or scalar @{ $record } != 5;
Branch: 1 branch
BranchTrueFalseTotal
if ref $record ne "ARRAY" or scalar @{$record;} != 5 0 11 11
Condition33%1/3
ref $record ne "ARRAY" or scalar @{$record;} != 5
l!l&&r!l&&!r
0011
MC/DC0%0/2
ref $record ne "ARRAY" or scalar @{$record;} != 5
ref $record ne "ARRAY" scalar @{$record;} != 5
Truth table33%1/3
A or B
A= ref $record ne "ARRAY"B= scalar @{$record;} != 5
ABresult
1X1
011
000
2794 my ( $kind, $binding_name, $source, $captures, $dependencies ) =
2795 11 @{ $record };
2796 11 ▶ die "Code table entry $id kind must be an integer"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_integer_value($kind) 1 10 11
2797 if !_is_integer_value($kind);
2798 10 ▶ die "Code table entry $id binding name must be a text string"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($binding_name) 0 10 10
2799 if !is_text_string($binding_name);
2800 10 $binding_name = text_value($binding_name);
2801 10 ▶ die "Code table entry $id binding name is not a valid identifier"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_identifier($binding_name) 0 10 10
2802 if !_is_identifier($binding_name);
2803 10 ▶ die "Code table entry $id source must be a text string"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($source) 0 10 10
2804 if !is_text_string($source);
2805 10 ▶ die "Code table entry $id captures must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $captures ne "ARRAY" 0 10 10
2806 if ref($captures) ne 'ARRAY';
2807 10 ▶ die "Code table entry $id dependencies must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $dependencies ne "ARRAY" 0 10 10
2808 if ref($dependencies) ne 'ARRAY';
2809  
2810 return {
2811 10 kind => $kind,
2812 binding_name => $binding_name,
2813 source => text_value($source),
2814 captures => $captures,
2815 dependencies => $dependencies,
2816 };
2817 }
2818  
2819 9 ▶sub _install_external_dependencies {
Subroutine _install_external_dependencies: called CC=11 SCAR=26.8
2820 9 my ( $runtime, $shared, $id, $record, $record_count ) = @_;
2821  
2822 9 for my $dependency ( @{ $record->{dependencies} } ) {
2823 die "Code dependency in record $id must be an array"
2824 3 ▶ if ref($dependency) ne 'ARRAY' or !@{ $dependency };
Branch: 1 branch
BranchTrueFalseTotal
if ref $dependency ne "ARRAY" or not @{$dependency;} 1 2 3
Condition66%2/3
ref $dependency ne "ARRAY" or not @{$dependency;}
l!l&&r!l&&!r
102
MC/DC50%1/2
ref $dependency ne "ARRAY" or not @{$dependency;}
ref $dependency ne "ARRAY" not @{$dependency;}
Truth table66%2/3
A or not(B)
A= ref $dependency ne "ARRAY"B= not @{$dependency;}
ABresult
1X1
011
000
2825 2 my $kind = $dependency->[0];
2826 2 ▶ die "Code dependency in record $id kind must be an integer"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_integer_value($kind) 0 2 2
2827 if !_is_integer_value($kind);
2828 2 ▶ if ( $kind == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 0) 1 1 2
2829 die "Internal dependency in record $id must be [0, code_id]"
2830 1 ▶ if scalar @{ $dependency } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$dependency;} != 2 0 1 1
2831 1 my $code_id = $dependency->[1];
2832 1 ▶ die "Internal dependency in record $id has invalid code id"
Branch: 1 branch
BranchTrueFalseTotal
if not _is_integer_value($code_id) or $code_id < 0 or $code_id >= $record_count 1 0 1
Condition33%2/6
not _is_integer_value($code_id) or $code_id < 0 or $code_id >= $record_count
l!l&&r!l&&!r
010
not _is_integer_value($code_id) or $code_id < 0
l!l&&r!l&&!r
001
MC/DC0%0/3
not _is_integer_value($code_id) or $code_id < 0 or $code_id >= $record_count
not _is_integer_value($code_id) $code_id < 0 $code_id >= $record_count
Truth table25%1/4
not(A) or B or C
A= not _is_integer_value($code_id)B= $code_id < 0C= $code_id >= $record_count
ABCresult
1XX1
01X1
0011
0000
2833 if !_is_integer_value($code_id)
2834 or $code_id < 0
2835 or $code_id >= $record_count;
2836 0 next;
2837 }
2838 1 ▶ if ( $kind == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($kind == 1) 1 0 1
2839 1 _install_external_dependency(
2840 $runtime,
2841 $shared,
2842 $id,
2843 $dependency,
2844 );
2845 0 next;
2846 }
2847 0 die "Unsupported code dependency kind $kind in record $id";
2848 }
2849  
2850 6 return;
2851 }
2852  
2853 1 ▶sub _install_external_dependency {
Subroutine _install_external_dependency: called CC=11 SCAR=45.9
2854 1 my ( $runtime, $shared, $id, $dependency ) = @_;
2855  
2856 die "External dependency in record $id must have four fields"
2857 1 ▶ if scalar @{ $dependency } != 4;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$dependency;} != 4 1 0 1
2858 0 my ( undef, $local_name, $module, $export_name ) = @{ $dependency };
2859 0 for my $field (
2860 [ local_name => \$local_name ],
2861 [ module => \$module ],
2862 [ export_name => \$export_name ],
2863 ) {
2864 die "External dependency $field->[0] in record $id must be text"
2865 0 ▶ if !is_text_string( ${ $field->[1] } );
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string(${$$field[1];}) 0 0 0
2866 0 ${ $field->[1] } = text_value( ${ $field->[1] } );
2867 }
2868 0 ▶ die "External dependency local name '$local_name' is not valid"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_identifier($local_name) 0 0 0
2869 if !_is_identifier($local_name);
2870 0 ▶ die "External dependency module '$module' is not a stdlib module"
Branch: 1 branch
BranchTrueFalseTotal
unless $module =~ m[\Astd/] 0 0 0
2871 if $module !~ m{\Astd/};
2872  
2873 0 my $module_env = $runtime->_load_module(
2874 $module,
2875 _call_file($runtime),
2876 _call_line($runtime),
2877 );
2878 0 my $ref = $module_env->find_ref($export_name);
2879 0 ▶ die "External dependency '$module.$export_name' is not exported"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ref 0 0 0
2880 if !defined $ref;
2881 0 ▶ if ( exists $shared->slots->{$local_name} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $shared->slots->{$local_name}) 0 0 0
2882 die "External dependency '$local_name' conflicts with code binding"
2883 0 ▶ if $shared->slots->{$local_name} != $ref;
Branch: 1 branch
BranchTrueFalseTotal
if $shared->slots->{$local_name} != $ref 0 0 0
2884 0 return;
2885 }
2886 $shared->alias_to_ref(
2887 $local_name,
2888 $ref,
2889 $module_env->{const}{$export_name} ? 1 : 0,
2890 0 ▶ $module_env->{types}{$export_name} // 'Any',
Branch: 1 branch
BranchTrueFalseTotal
$module_env->{'const'}{$export_name} ? : 0 0 0
Condition0%0/2
$module_env->{"types"}{$export_name} // "Any"
l!l
00
MC/DC0%0/1
$module_env->{"types"}{$export_name} // "Any"
$module_env->{"types"}{$export_name}
Truth table0%0/2
A
A= $module_env->{"types"}{$export_name}
Aresult
11
00
2891 );
2892  
2893 0 return;
2894 }
2895  
2896 6 ▶sub _load_code_record_by_id {
Subroutine _load_code_record_by_id: called CC=16 SCAR=39.1
2897 6 my ( $runtime, $shared, $records, $refs, $values, $status, $id ) = @_;
2898  
2899 die "Internal dependency has invalid code id"
2900 6 ▶ if !_is_integer_value($id) or $id < 0 or $id > $#{ $records };
Branch: 1 branch
BranchTrueFalseTotal
if not _is_integer_value($id) or $id < 0 or $id > $#{$records;} 0 6 6
Condition33%2/6
not _is_integer_value($id) or $id < 0 or $id > $#{$records;}
l!l&&r!l&&!r
006
not _is_integer_value($id) or $id < 0
l!l&&r!l&&!r
006
MC/DC0%0/3
not _is_integer_value($id) or $id < 0 or $id > $#{$records;}
not _is_integer_value($id) $id < 0 $id > $#{$records;}
Truth table25%1/4
not(A) or B or C
A= not _is_integer_value($id)B= $id < 0C= $id > $#{$records;}
ABCresult
1XX1
01X1
0011
0000
2901 6 ▶ return $values->[$id] if ( $status->[$id] // '' ) eq 'done';
Branch: 1 branch
BranchTrueFalseTotal
if ($status->[$id] // "") eq "done" 0 6 6
Condition50%1/2
$status->[$id] // ""
l!l
06
MC/DC0%0/1
$status->[$id] // ""
$status->[$id]
Truth table50%1/2
A
A= $status->[$id]
Aresult
11
00
2902 6 ▶ die "Cyclic class or trait code dependency involving record $id"
Branch: 1 branch
BranchTrueFalseTotal
if ($status->[$id] // "") eq "loading" 0 6 6
Condition50%1/2
$status->[$id] // ""
l!l
06
MC/DC0%0/1
$status->[$id] // ""
$status->[$id]
Truth table50%1/2
A
A= $status->[$id]
Aresult
11
00
2903 if ( $status->[$id] // '' ) eq 'loading';
2904  
2905 6 my $record = $records->[$id];
2906 6 $status->[$id] = 'loading';
2907 6 ▶ if ( $record->{kind} == CODE_CLASS or $record->{kind} == CODE_TRAIT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($record->{"kind"} == 2 or $record->{"kind"} == 3) 3 3 6
Condition66%2/3
$record->{"kind"} == 2 or $record->{"kind"} == 3
l!l&&r!l&&!r
303
MC/DC50%1/2
$record->{"kind"} == 2 or $record->{"kind"} == 3
$record->{"kind"} == 2 $record->{"kind"} == 3
Truth table66%2/3
A or B
A= $record->{"kind"} == 2B= $record->{"kind"} == 3
ABresult
1X1
011
000
2908 3 for my $dependency ( @{ $record->{dependencies} } ) {
2909 0 ▶ next if $dependency->[0] != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $dependency->[0] != 0 0 0 0
2910 0 my $dependency_id = $dependency->[1];
2911 die "Internal dependency in record $id has invalid code id"
2912 if !_is_integer_value($dependency_id)
2913 or $dependency_id < 0
2914 0 ▶ or $dependency_id > $#{ $records };
Branch: 1 branch
BranchTrueFalseTotal
if not _is_integer_value($dependency_id) or $dependency_id < 0 or $dependency_id > $#{$records;} 0 0 0
Condition0%0/6
not _is_integer_value($dependency_id) or $dependency_id < 0 or $dependency_id > $#{$records;}
l!l&&r!l&&!r
000
not _is_integer_value($dependency_id) or $dependency_id < 0
l!l&&r!l&&!r
000
MC/DC0%0/3
not _is_integer_value($dependency_id) or $dependency_id < 0 or $dependency_id > $#{$records;}
not _is_integer_value($dependency_id) $dependency_id < 0 $dependency_id > $#{$records;}
Truth table0%0/4
not(A) or B or C
A= not _is_integer_value($dependency_id)B= $dependency_id < 0C= $dependency_id > $#{$records;}
ABCresult
1XX1
01X1
0011
0000
2915 0 ▶ next if $records->[$dependency_id]{kind} == CODE_FUNCTION;
Branch: 1 branch
BranchTrueFalseTotal
if $records->[$dependency_id]{"kind"} == 1 0 0 0
2916 0 _load_code_record_by_id(
2917 $runtime,
2918 $shared,
2919 $records,
2920 $refs,
2921 $values,
2922 $status,
2923 $dependency_id,
2924 );
2925 }
2926 }
2927  
2928 6 my $value = _load_code_record( $runtime, $shared, $id, $record );
2929 4 ${ $refs->[$id] } = $value;
2930 4 $values->[$id] = $value;
2931 4 $status->[$id] = 'done';
2932  
2933 4 return $value;
2934 }
2935  
2936 6 ▶sub _load_code_record {
Subroutine _load_code_record: called CC=4 SCAR=17.1
2937 6 my ( $runtime, $shared, $id, $record ) = @_;
2938  
2939 return _load_function_code_record( $runtime, $shared, $id, $record )
2940 6 ▶ if $record->{kind} == CODE_FUNCTION;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"kind"} == 1 3 3 6
2941 return _load_class_code_record( $runtime, $shared, $id, $record )
2942 3 ▶ if $record->{kind} == CODE_CLASS;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"kind"} == 2 3 0 3
2943 return _load_trait_code_record( $runtime, $shared, $id, $record )
2944 0 ▶ if $record->{kind} == CODE_TRAIT;
Branch: 1 branch
BranchTrueFalseTotal
if $record->{"kind"} == 3 0 0 0
2945  
2946 0 die "Unsupported code kind $record->{kind} in current loader";
2947 }
2948  
2949 3 ▶sub _load_function_code_record {
Subroutine _load_function_code_record: called CC=11 SCAR=25.4
2950 3 my ( $runtime, $shared, $id, $record ) = @_;
2951  
2952 3 my $private = Zuzu::Env->new( parent => $shared );
2953 3 my %capture_names;
2954 3 for my $capture ( @{ $record->{captures} } ) {
2955 die "Capture in code record $id must be a two-item array"
2956 3 ▶ if ref($capture) ne 'ARRAY' or scalar @{ $capture } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $capture ne "ARRAY" or scalar @{$capture;} != 2 1 2 3
Condition66%2/3
ref $capture ne "ARRAY" or scalar @{$capture;} != 2
l!l&&r!l&&!r
012
MC/DC50%1/2
ref $capture ne "ARRAY" or scalar @{$capture;} != 2
ref $capture ne "ARRAY" scalar @{$capture;} != 2
Truth table66%2/3
A or B
A= ref $capture ne "ARRAY"B= scalar @{$capture;} != 2
ABresult
1X1
011
000
2957 2 my ( $name, $value ) = @{ $capture };
2958 2 ▶ die "Capture name in code record $id must be a text string"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($name) 0 2 2
2959 if !is_text_string($name);
2960 2 $name = text_value($name);
2961 2 ▶ die "Capture name '$name' in code record $id is not valid"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_identifier($name) 0 2 2
2962 if !_is_identifier($name);
2963 die "Duplicate capture '$name' in code record $id"
2964 2 ▶ if $capture_names{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $capture_names{$name}++ 1 1 2
2965 1 _reject_weak_storage_record(
2966 $value,
2967 "Capture '$name' in code record $id",
2968 );
2969 1 $private->declare(
2970 $name,
2971 _decode_scalar_value( $runtime, $value ),
2972 1,
2973 );
2974 }
2975  
2976 1 my $result_name = "__zuzu_marshal_value_$id";
2977 1 ▶ while ( defined $private->find_ref($result_name) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $private->find_ref($result_name)) 0 1 1
2978 0 $result_name = '_' . $result_name;
2979 }
2980 my $source = "let $result_name := "
2981 . $record->{source}
2982 1 . "; $result_name;";
2983 1 my $value;
2984 eval {
2985 1 $runtime->_push_env($private);
2986 1 $value = $runtime->eval_with_current_scope(
2987 $source,
2988 '<std/marshal-code>',
2989 );
2990 1 1;
2991 1 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $runtime->_push_env($private); $value = $runtime->eval_with_current_scope($source, "<std/marshal-code>"); 1 } } or do { my $error = $@; $runtime->_pop_env; die $error } 1 0 1
2992 0 my $error = $@;
2993 0 $runtime->_pop_env;
2994 0 die $error;
2995 };
2996 1 $runtime->_pop_env;
2997  
2998 1 ▶ die "Code record $id did not evaluate to a Function"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Function") 0 1 1
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
builtin::blessed($value) $value->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
2999 if !blessed($value) or !$value->isa('Zuzu::Value::Function');
3000  
3001 1 return $value;
3002 }
3003  
3004 3 ▶sub _load_class_code_record {
Subroutine _load_class_code_record: called CC=4 SCAR=15.2
3005 3 my ( $runtime, $shared, $id, $record ) = @_;
3006  
3007 my $parent = _shared_code_env_without(
3008 $shared,
3009 $record->{binding_name},
3010 3 );
3011 3 my $private = _private_code_env_with_captures(
3012 $runtime,
3013 $parent,
3014 $id,
3015 $record,
3016 );
3017 3 my $value;
3018 eval {
3019 3 $runtime->_push_env($private);
3020 $value = $runtime->eval_with_current_scope(
3021 $record->{source},
3022 3 '<std/marshal-code>',
3023 );
3024 3 1;
3025 3 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $runtime->_push_env($private); $value = $runtime->eval_with_current_scope($record->{"source"}, "<std/marshal-code>"); 1 } } or do { my $error = $@; $runtime->_pop_env; die $error } 3 0 3
3026 0 my $error = $@;
3027 0 $runtime->_pop_env;
3028 0 die $error;
3029 };
3030 3 $runtime->_pop_env;
3031  
3032 3 ▶ die "Code record $id did not evaluate to a Class"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Class") 0 3 3
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Class")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Class")
builtin::blessed($value) $value->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
3033 if !blessed($value) or !$value->isa('Zuzu::Value::Class');
3034  
3035 3 return $value;
3036 }
3037  
3038 0 ▶sub _load_trait_code_record {
Subroutine _load_trait_code_record: not called CC=4 SCAR=30.0
3039 0 my ( $runtime, $shared, $id, $record ) = @_;
3040  
3041 my $parent = _shared_code_env_without(
3042 $shared,
3043 $record->{binding_name},
3044 0 );
3045 0 my $private = _private_code_env_with_captures(
3046 $runtime,
3047 $parent,
3048 $id,
3049 $record,
3050 );
3051 0 my $value;
3052 eval {
3053 0 $runtime->_push_env($private);
3054 $value = $runtime->eval_with_current_scope(
3055 $record->{source},
3056 0 '<std/marshal-code>',
3057 );
3058 0 1;
3059 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $runtime->_push_env($private); $value = $runtime->eval_with_current_scope($record->{"source"}, "<std/marshal-code>"); 1 } } or do { my $error = $@; $runtime->_pop_env; die $error } 0 0 0
3060 0 my $error = $@;
3061 0 $runtime->_pop_env;
3062 0 die $error;
3063 };
3064 0 $runtime->_pop_env;
3065  
3066 0 ▶ die "Code record $id did not evaluate to a Trait"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Trait") 0 0 0
Condition0%0/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Trait")
builtin::blessed($value) $value->isa("Zuzu::Value::Trait")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
3067 if !blessed($value) or !$value->isa('Zuzu::Value::Trait');
3068  
3069 0 return $value;
3070 }
3071  
3072 3 ▶sub _shared_code_env_without {
Subroutine _shared_code_env_without: called CC=5 SCAR=16.1
3073 3 my ( $shared, $hidden_name ) = @_;
3074  
3075 3 my $filtered = Zuzu::Env->new( parent => undef );
3076 3 for my $name ( sort keys %{ $shared->slots } ) {
3077 108 ▶ next if $name eq $hidden_name;
Branch: 1 branch
BranchTrueFalseTotal
if $name eq $hidden_name 3 105 108
3078 $filtered->alias_to_ref(
3079 $name,
3080 $shared->slots->{$name},
3081 $shared->const->{$name} ? 1 : 0,
3082 105 ▶ $shared->types->{$name} // 'Any',
Branch: 1 branch
BranchTrueFalseTotal
$shared->const->{$name} ? : 102 3 105
Condition50%1/2
$shared->types->{$name} // "Any"
l!l
1050
MC/DC0%0/1
$shared->types->{$name} // "Any"
$shared->types->{$name}
Truth table50%1/2
A
A= $shared->types->{$name}
Aresult
11
00
3083 );
3084 }
3085  
3086 3 return $filtered;
3087 }
3088  
3089 3 ▶sub _private_code_env_with_captures {
Subroutine _private_code_env_with_captures: called CC=7 SCAR=34.0
3090 3 my ( $runtime, $shared, $id, $record ) = @_;
3091  
3092 3 my $private = Zuzu::Env->new( parent => $shared );
3093 3 my %capture_names;
3094 3 for my $capture ( @{ $record->{captures} } ) {
3095 die "Capture in code record $id must be a two-item array"
3096 0 ▶ if ref($capture) ne 'ARRAY' or scalar @{ $capture } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $capture ne "ARRAY" or scalar @{$capture;} != 2 0 0 0
Condition0%0/3
ref $capture ne "ARRAY" or scalar @{$capture;} != 2
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $capture ne "ARRAY" or scalar @{$capture;} != 2
ref $capture ne "ARRAY" scalar @{$capture;} != 2
Truth table0%0/3
A or B
A= ref $capture ne "ARRAY"B= scalar @{$capture;} != 2
ABresult
1X1
011
000
3097 0 my ( $name, $value ) = @{ $capture };
3098 0 ▶ die "Capture name in code record $id must be a text string"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($name) 0 0 0
3099 if !is_text_string($name);
3100 0 $name = text_value($name);
3101 0 ▶ die "Capture name '$name' in code record $id is not valid"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_identifier($name) 0 0 0
3102 if !_is_identifier($name);
3103 die "Duplicate capture '$name' in code record $id"
3104 0 ▶ if $capture_names{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $capture_names{$name}++ 0 0 0
3105 0 _reject_weak_storage_record(
3106 $value,
3107 "Capture '$name' in code record $id",
3108 );
3109 0 $private->declare(
3110 $name,
3111 _decode_scalar_value( $runtime, $value ),
3112 1,
3113 );
3114 }
3115  
3116 3 return $private;
3117 }
3118  
3119 2 ▶sub _decode_function_payload {
Subroutine _decode_function_payload: called CC=8 SCAR=23.9
3120 2 my ( $runtime, $id, $payload, $code_values ) = @_;
3121  
3122 die "Function object payload $id must be a one-item array"
3123 2 ▶ if ref($payload) ne 'ARRAY' or scalar @{ $payload } != 1;
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" or scalar @{$payload;} != 1 0 2 2
Condition33%1/3
ref $payload ne "ARRAY" or scalar @{$payload;} != 1
l!l&&r!l&&!r
002
MC/DC0%0/2
ref $payload ne "ARRAY" or scalar @{$payload;} != 1
ref $payload ne "ARRAY" scalar @{$payload;} != 1
Truth table33%1/3
A or B
A= ref $payload ne "ARRAY"B= scalar @{$payload;} != 1
ABresult
1X1
011
000
3124 2 my $code_id = $payload->[0];
3125 2 _reject_weak_storage_record(
3126 $code_id,
3127 "Function object payload $id code id",
3128 );
3129 1 ▶ die "Function object payload $id code id must be an integer"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_integer_value($code_id) 0 1 1
3130 if !_is_integer_value($code_id);
3131 die "Function object payload $id code id is outside the code table"
3132 1 ▶ if $code_id < 0 or $code_id > $#{ $code_values };
Branch: 1 branch
BranchTrueFalseTotal
if $code_id < 0 or $code_id > $#{$code_values;} 0 1 1
Condition33%1/3
$code_id < 0 or $code_id > $#{$code_values;}
l!l&&r!l&&!r
001
MC/DC0%0/2
$code_id < 0 or $code_id > $#{$code_values;}
$code_id < 0 $code_id > $#{$code_values;}
Truth table33%1/3
A or B
A= $code_id < 0B= $code_id > $#{$code_values;}
ABresult
1X1
011
000
3133  
3134 1 my $value = $code_values->[$code_id];
3135 1 ▶ die "Function object payload $id code record is not a Function"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($value) and $value->isa("Zuzu::Value::Function") 0 1 1
Condition33%1/3
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
!ll&&!rl&&r
001
MC/DC0%0/2
builtin::blessed($value) and $value->isa("Zuzu::Value::Function")
builtin::blessed($value) $value->isa("Zuzu::Value::Function")
Truth table33%1/3
A and B
A= builtin::blessed($value)B= $value->isa("Zuzu::Value::Function")
ABresult
0X0
100
111
3136 if !blessed($value) or !$value->isa('Zuzu::Value::Function');
3137  
3138 1 return $value;
3139 }
3140  
3141 3 ▶sub _decode_class_payload {
Subroutine _decode_class_payload: called CC=8 SCAR=23.9
3142 3 my ( $runtime, $id, $payload, $code_values ) = @_;
3143  
3144 die "Class object payload $id must be a one-item array"
3145 3 ▶ if ref($payload) ne 'ARRAY' or scalar @{ $payload } != 1;
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" or scalar @{$payload;} != 1 0 3 3
Condition33%1/3
ref $payload ne "ARRAY" or scalar @{$payload;} != 1
l!l&&r!l&&!r
003
MC/DC0%0/2
ref $payload ne "ARRAY" or scalar @{$payload;} != 1
ref $payload ne "ARRAY" scalar @{$payload;} != 1
Truth table33%1/3
A or B
A= ref $payload ne "ARRAY"B= scalar @{$payload;} != 1
ABresult
1X1
011
000
3146 3 my $code_id = $payload->[0];
3147 3 _reject_weak_storage_record(
3148 $code_id,
3149 "Class object payload $id code id",
3150 );
3151 3 ▶ die "Class object payload $id code id must be an integer"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_integer_value($code_id) 0 3 3
3152 if !_is_integer_value($code_id);
3153 die "Class object payload $id code id is outside the code table"
3154 3 ▶ if $code_id < 0 or $code_id > $#{ $code_values };
Branch: 1 branch
BranchTrueFalseTotal
if $code_id < 0 or $code_id > $#{$code_values;} 0 3 3
Condition33%1/3
$code_id < 0 or $code_id > $#{$code_values;}
l!l&&r!l&&!r
003
MC/DC0%0/2
$code_id < 0 or $code_id > $#{$code_values;}
$code_id < 0 $code_id > $#{$code_values;}
Truth table33%1/3
A or B
A= $code_id < 0B= $code_id > $#{$code_values;}
ABresult
1X1
011
000
3155  
3156 3 my $class = $code_values->[$code_id];
3157 3 ▶ die "Class object payload $id code record is not a Class"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($class) and $class->isa("Zuzu::Value::Class") 0 3 3
Condition33%1/3
builtin::blessed($class) and $class->isa("Zuzu::Value::Class")
!ll&&!rl&&r
003
MC/DC0%0/2
builtin::blessed($class) and $class->isa("Zuzu::Value::Class")
builtin::blessed($class) $class->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($class)B= $class->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
3158 if !blessed($class) or !$class->isa('Zuzu::Value::Class');
3159  
3160 3 return $class;
3161 }
3162  
3163 0 ▶sub _decode_trait_payload {
Subroutine _decode_trait_payload: not called CC=8 SCAR=42.8
3164 0 my ( $runtime, $id, $payload, $code_values ) = @_;
3165  
3166 die "Trait object payload $id must be a one-item array"
3167 0 ▶ if ref($payload) ne 'ARRAY' or scalar @{ $payload } != 1;
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" or scalar @{$payload;} != 1 0 0 0
Condition0%0/3
ref $payload ne "ARRAY" or scalar @{$payload;} != 1
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $payload ne "ARRAY" or scalar @{$payload;} != 1
ref $payload ne "ARRAY" scalar @{$payload;} != 1
Truth table0%0/3
A or B
A= ref $payload ne "ARRAY"B= scalar @{$payload;} != 1
ABresult
1X1
011
000
3168 0 my $code_id = $payload->[0];
3169 0 _reject_weak_storage_record(
3170 $code_id,
3171 "Trait object payload $id code id",
3172 );
3173 0 ▶ die "Trait object payload $id code id must be an integer"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_integer_value($code_id) 0 0 0
3174 if !_is_integer_value($code_id);
3175 die "Trait object payload $id code id is outside the code table"
3176 0 ▶ if $code_id < 0 or $code_id > $#{ $code_values };
Branch: 1 branch
BranchTrueFalseTotal
if $code_id < 0 or $code_id > $#{$code_values;} 0 0 0
Condition0%0/3
$code_id < 0 or $code_id > $#{$code_values;}
l!l&&r!l&&!r
000
MC/DC0%0/2
$code_id < 0 or $code_id > $#{$code_values;}
$code_id < 0 $code_id > $#{$code_values;}
Truth table0%0/3
A or B
A= $code_id < 0B= $code_id > $#{$code_values;}
ABresult
1X1
011
000
3177  
3178 0 my $trait = $code_values->[$code_id];
3179 0 ▶ die "Trait object payload $id code record is not a Trait"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($trait) and $trait->isa("Zuzu::Value::Trait") 0 0 0
Condition0%0/3
builtin::blessed($trait) and $trait->isa("Zuzu::Value::Trait")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($trait) and $trait->isa("Zuzu::Value::Trait")
builtin::blessed($trait) $trait->isa("Zuzu::Value::Trait")
Truth table0%0/3
A and B
A= builtin::blessed($trait)B= $trait->isa("Zuzu::Value::Trait")
ABresult
0X0
100
111
3180 if !blessed($trait) or !$trait->isa('Zuzu::Value::Trait');
3181  
3182 0 return $trait;
3183 }
3184  
3185 12 ▶sub _fill_bound_method_placeholders {
Subroutine _fill_bound_method_placeholders: called CC=3 SCAR=11.6
3186 12 my ( $runtime, $objects, $placeholders ) = @_;
3187  
3188 12 for my $id ( 0 .. $#{ $objects } ) {
3189 23 my ( $kind, $payload ) = @{ $objects->[$id] };
3190 23 ▶ next if $kind != KIND_BOUND_METHOD;
Branch: 1 branch
BranchTrueFalseTotal
if $kind != 11 23 0 23
3191  
3192 0 my $bound = _decode_bound_method_payload(
3193 $runtime,
3194 $id,
3195 $payload,
3196 $placeholders,
3197 );
3198 0 _replace_function_value( $placeholders->[$id], $bound );
3199 }
3200  
3201 12 return;
3202 }
3203  
3204 0 ▶sub _decode_bound_method_payload {
Subroutine _decode_bound_method_payload: not called CC=7 SCAR=40.3
3205 0 my ( $runtime, $id, $payload, $placeholders ) = @_;
3206  
3207 die "Bound method object payload $id must be a two-item array"
3208 0 ▶ if ref($payload) ne 'ARRAY' or scalar @{ $payload } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" or scalar @{$payload;} != 2 0 0 0
Condition0%0/3
ref $payload ne "ARRAY" or scalar @{$payload;} != 2
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $payload ne "ARRAY" or scalar @{$payload;} != 2
ref $payload ne "ARRAY" scalar @{$payload;} != 2
Truth table0%0/3
A or B
A= ref $payload ne "ARRAY"B= scalar @{$payload;} != 2
ABresult
1X1
011
000
3209 0 my ( $receiver_ref, $method_name ) = @{ $payload };
3210 0 my $receiver = _decode_value(
3211 $runtime,
3212 $receiver_ref,
3213 $placeholders,
3214 allow_weak => 0,
3215 context => "Bound method object payload $id receiver",
3216 );
3217 0 ▶ die "Bound method object payload $id receiver must resolve to an Object"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($receiver) and $receiver->isa("Zuzu::Value::Object") 0 0 0
Condition0%0/3
builtin::blessed($receiver) and $receiver->isa("Zuzu::Value::Object")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($receiver) and $receiver->isa("Zuzu::Value::Object")
builtin::blessed($receiver) $receiver->isa("Zuzu::Value::Object")
Truth table0%0/3
A and B
A= builtin::blessed($receiver)B= $receiver->isa("Zuzu::Value::Object")
ABresult
0X0
100
111
3218 if !blessed($receiver) or !$receiver->isa('Zuzu::Value::Object');
3219 0 ▶ die "Bound method object payload $id method name must be a text string"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($method_name) 0 0 0
3220 if !is_text_string($method_name);
3221 0 $method_name = text_value($method_name);
3222  
3223 0 my $method = $runtime->_lookup_method( $receiver->class, $method_name, 0 );
3224 0 ▶ die "Bound method object payload $id method '$method_name' was not found"
Branch: 1 branch
BranchTrueFalseTotal
unless $method 0 0 0
3225 if !$method;
3226  
3227 0 return $runtime->_bind_method( $receiver, $method_name, $method );
3228 }
3229  
3230 0 ▶sub _replace_function_value {
Subroutine _replace_function_value: not called CC=1 SCAR=6.9
3231 0 my ( $target, $source ) = @_;
3232  
3233 0 %{ $target } = %{ $source };
3234  
3235 0 return;
3236 }
3237  
3238 4 ▶sub _fill_object_payload {
Subroutine _fill_object_payload: called CC=17 SCAR=30.3
3239 4 my ( $runtime, $id, $payload, $placeholders ) = @_;
3240  
3241 die "Object payload $id must be a two-item array"
3242 4 ▶ if ref($payload) ne 'ARRAY' or scalar @{ $payload } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" or scalar @{$payload;} != 2 0 4 4
Condition33%1/3
ref $payload ne "ARRAY" or scalar @{$payload;} != 2
l!l&&r!l&&!r
004
MC/DC0%0/2
ref $payload ne "ARRAY" or scalar @{$payload;} != 2
ref $payload ne "ARRAY" scalar @{$payload;} != 2
Truth table33%1/3
A or B
A= ref $payload ne "ARRAY"B= scalar @{$payload;} != 2
ABresult
1X1
011
000
3243  
3244 4 my ( $class_ref, $slot_payload ) = @{ $payload };
3245 4 my $class = _decode_value(
3246 $runtime,
3247 $class_ref,
3248 $placeholders,
3249 allow_weak => 0,
3250 context => "Object payload $id class",
3251 );
3252 4 ▶ die "Object payload $id class must resolve to a Class"
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($class) and $class->isa("Zuzu::Value::Class") 0 4 4
Condition33%1/3
builtin::blessed($class) and $class->isa("Zuzu::Value::Class")
!ll&&!rl&&r
004
MC/DC0%0/2
builtin::blessed($class) and $class->isa("Zuzu::Value::Class")
builtin::blessed($class) $class->isa("Zuzu::Value::Class")
Truth table33%1/3
A and B
A= builtin::blessed($class)B= $class->isa("Zuzu::Value::Class")
ABresult
0X0
100
111
3253 if !blessed($class) or !$class->isa('Zuzu::Value::Class');
3254 4 ▶ die "Object payload $id slots must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $slot_payload ne "ARRAY" 0 4 4
3255 if ref($slot_payload) ne 'ARRAY';
3256  
3257 4 my ( $slots, $const, $types, $weak ) = $runtime->_instantiate_slots($class);
3258 4 my %slot_names;
3259 4 for my $record ( @{ $slot_payload } ) {
3260 die "Object payload $id slot records must be two-item arrays"
3261 4 ▶ if ref($record) ne 'ARRAY' or scalar @{ $record } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $record ne "ARRAY" or scalar @{$record;} != 2 0 4 4
Condition33%1/3
ref $record ne "ARRAY" or scalar @{$record;} != 2
l!l&&r!l&&!r
004
MC/DC0%0/2
ref $record ne "ARRAY" or scalar @{$record;} != 2
ref $record ne "ARRAY" scalar @{$record;} != 2
Truth table33%1/3
A or B
A= ref $record ne "ARRAY"B= scalar @{$record;} != 2
ABresult
1X1
011
000
3262 4 my ( $name, $encoded_value ) = @{ $record };
3263 4 ▶ die "Object payload $id slot names must be text strings"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($name) 0 4 4
3264 if !is_text_string($name);
3265 4 $name = text_value($name);
3266 die "Object payload $id contains duplicate slot '$name'"
3267 4 ▶ if $slot_names{$name}++;
Branch: 1 branch
BranchTrueFalseTotal
if $slot_names{$name}++ 1 3 4
3268 3 my ( $value, $record_weak ) = _decode_stored_value(
3269 $runtime,
3270 $encoded_value,
3271 $placeholders,
3272 "Object payload $id slot '$name'",
3273 );
3274 3 ▶ my $declared_type = exists $types->{$name} ? $types->{$name} : 'Any';
Branch: 1 branch
BranchTrueFalseTotal
exists $types->{$name} ? : 3 0 3
3275 3 ▶ $runtime->_assert_declared_type(
Branch: 1 branch
BranchTrueFalseTotal
if $declared_type ne "Any" 0 3 3
3276 $declared_type,
3277 $value,
3278 _call_file($runtime),
3279 _call_line($runtime),
3280 $name,
3281 ) if $declared_type ne 'Any';
3282 3 ▶ my $is_weak = ( $weak->{$name} || $record_weak ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$weak->{$name} || $record_weak ? : 2 1 3
Condition66%2/3
$weak->{$name} or $record_weak
l!l&&r!l&&!r
201
MC/DC50%1/2
$weak->{$name} or $record_weak
$weak->{$name} $record_weak
Truth table66%2/3
A or B
A= $weak->{$name}B= $record_weak
ABresult
1X1
011
000
3283 3 store_value( \$slots->{$name}, $value, $is_weak );
3284 3 $weak->{$name} = $is_weak;
3285 3 ▶ $const->{$name} = 0 if !exists $const->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $const->{$name} 0 3 3
3286 3 ▶ $types->{$name} = 'Any' if !exists $types->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $types->{$name} 0 3 3
3287 }
3288  
3289 3 my $object = $placeholders->[$id];
3290 3 $object->class($class);
3291 3 $object->slots($slots);
3292 3 $object->const($const);
3293 3 $object->types($types);
3294 3 $object->weak($weak);
3295  
3296 3 return;
3297 }
3298  
3299 9 ▶sub _run_on_load_hooks {
Subroutine _run_on_load_hooks: called CC=6 SCAR=22.5
3300 9 my ( $runtime, $objects, $placeholders ) = @_;
3301  
3302 9 for my $id ( 0 .. $#{ $objects } ) {
3303 22 my ( $kind ) = @{ $objects->[$id] };
3304 22 ▶ next if $kind != KIND_OBJECT;
Branch: 1 branch
BranchTrueFalseTotal
if $kind != 7 19 3 22
3305  
3306 3 my $object = $placeholders->[$id];
3307 3 my $method = $runtime->_lookup_method(
3308 $object->class,
3309 '__on_load__',
3310 0,
3311 );
3312 3 ▶ next if !$method;
Branch: 1 branch
BranchTrueFalseTotal
unless $method 3 0 3
3313  
3314 eval {
3315 0 $runtime->_call_method(
3316 $method,
3317 $object,
3318 [],
3319 {},
3320 [],
3321 _call_file($runtime),
3322 _call_line($runtime),
3323 );
3324 0 1;
3325 0 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $runtime->_call_method($method, $object, [], {}, [], _call_file($runtime), _call_line($runtime)); 1 } } or do { my $error = $@; my $class = $object->class ? $object->class->name : "<unknown>"; die "__on_load__ for object id $id ($class) failed: " . _hook_error_text($runtime, $error) } 0 0 0
3326 0 my $error = $@;
3327 0 ▶ my $class = $object->class ? $object->class->name : '<unknown>';
Branch: 1 branch
BranchTrueFalseTotal
$object->class ? : 0 0 0
3328 0 die "__on_load__ for object id $id ($class) failed: "
3329 . _hook_error_text( $runtime, $error );
3330 };
3331 }
3332  
3333 9 return;
3334 }
3335  
3336 1 ▶sub _new_time_placeholder {
Subroutine _new_time_placeholder: called CC=1 SCAR=0.0
3337 1 my ( $runtime ) = @_;
3338  
3339 1 my $time_class = _module_symbol( $runtime, 'std/time', 'Time' );
3340 1 return $time_class->native_constructor->(
3341 $runtime,
3342 $time_class,
3343 [ 0 ],
3344 {},
3345 _call_file($runtime),
3346 _call_line($runtime),
3347 );
3348 }
3349  
3350 0 ▶sub _new_path_placeholder {
Subroutine _new_path_placeholder: not called CC=1 SCAR=6.9
3351 0 my ( $runtime ) = @_;
3352  
3353 0 my $path_class = _module_symbol( $runtime, 'std/io', 'Path' );
3354 0 return $path_class->native_constructor->(
3355 $runtime,
3356 $path_class,
3357 [ '.' ],
3358 {},
3359 _call_file($runtime),
3360 _call_line($runtime),
3361 );
3362 }
3363  
3364 0 ▶sub _decode_time_payload {
Subroutine _decode_time_payload: not called CC=7 SCAR=40.3
3365 0 my ( $id, $payload ) = @_;
3366  
3367 die "Time object payload $id must contain epoch and optional timezone"
3368 if ref($payload) ne 'ARRAY'
3369 0 or scalar @{ $payload } < 1
3370 0 ▶ or scalar @{ $payload } > 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" or scalar @{$payload;} < 1 or scalar @{$payload;} > 2 0 0 0
Condition0%0/6
ref $payload ne "ARRAY" or scalar @{$payload;} < 1 or scalar @{$payload;} > 2
l!l&&r!l&&!r
000
ref $payload ne "ARRAY" or scalar @{$payload;} < 1
l!l&&r!l&&!r
000
MC/DC0%0/3
ref $payload ne "ARRAY" or scalar @{$payload;} < 1 or scalar @{$payload;} > 2
ref $payload ne "ARRAY" scalar @{$payload;} < 1 scalar @{$payload;} > 2
Truth table0%0/4
A or B or C
A= ref $payload ne "ARRAY"B= scalar @{$payload;} < 1C= scalar @{$payload;} > 2
ABCresult
1XX1
01X1
0011
0000
3371 0 my $epoch = $payload->[0];
3372 0 ▶ die "Time object payload $id epoch must be a number"
Branch: 1 branch
BranchTrueFalseTotal
if ref $epoch 0 0 0
3373 if ref($epoch);
3374 0 my $timezone = 'UTC';
3375 0 ▶ if ( scalar @{ $payload } > 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$payload;} > 1) 0 0 0
3376 0 ▶ die "Time object payload $id timezone must be a text string"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($payload->[1]) 0 0 0
3377 if !is_text_string( $payload->[1] );
3378 0 $timezone = text_value( $payload->[1] );
3379 }
3380  
3381 0 return ( 0 + $epoch, $timezone );
3382 }
3383  
3384 0 ▶sub _decode_path_payload {
Subroutine _decode_path_payload: not called CC=4 SCAR=30.0
3385 0 my ( $id, $payload ) = @_;
3386  
3387 die "Path object payload $id must be a one-item array"
3388 0 ▶ if ref($payload) ne 'ARRAY' or scalar @{ $payload } != 1;
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" or scalar @{$payload;} != 1 0 0 0
Condition0%0/3
ref $payload ne "ARRAY" or scalar @{$payload;} != 1
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $payload ne "ARRAY" or scalar @{$payload;} != 1
ref $payload ne "ARRAY" scalar @{$payload;} != 1
Truth table0%0/3
A or B
A= ref $payload ne "ARRAY"B= scalar @{$payload;} != 1
ABresult
1X1
011
000
3389 0 my $path_value = $payload->[0];
3390 0 ▶ die "Path object payload $id path must be a text string"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($path_value) 0 0 0
3391 if !is_text_string($path_value);
3392  
3393 0 return text_value($path_value);
3394 }
3395  
3396 2 ▶sub _decode_item_payload_records {
Subroutine _decode_item_payload_records: called CC=2 SCAR=7.0
3397 2 my ( $runtime, $context, $payload, $placeholders ) = @_;
3398  
3399 2 ▶ die "$context must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" 0 2 2
3400 if ref($payload) ne 'ARRAY';
3401  
3402 return map {
3403 2 my ( $value, $weak ) = _decode_stored_value(
3404 $runtime,
3405 $_,
3406 $placeholders,
3407 "$context item",
3408 );
3409 2 [ $value, $weak ];
3410 2 } @{ $payload };
3411 }
3412  
3413 4 ▶sub _decode_dict_payload {
Subroutine _decode_dict_payload: called CC=5 SCAR=16.1
3414 4 my ( $runtime, $id, $payload, $placeholders ) = @_;
3415  
3416 4 ▶ die "Dict object payload $id must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" 0 4 4
3417 if ref($payload) ne 'ARRAY';
3418  
3419 4 my %map;
3420 my %weak;
3421 4 for my $pair ( @{ $payload } ) {
3422 6 my ( $key, $value, $is_weak ) = _decode_key_value_record(
3423 $runtime,
3424 "Dict object payload $id",
3425 $pair,
3426 $placeholders,
3427 );
3428 die "Dict object payload $id contains duplicate key '$key'"
3429 6 ▶ if exists $map{$key};
Branch: 1 branch
BranchTrueFalseTotal
if exists $map{$key} 1 5 6
3430 5 $map{$key} = undef;
3431 5 store_value( \$map{$key}, $value, $is_weak );
3432 5 ▶ $weak{$key} = $is_weak ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$is_weak ? : 2 3 5
3433 }
3434  
3435 3 return ( \%map, \%weak );
3436 }
3437  
3438 2 ▶sub _decode_pairlist_payload {
Subroutine _decode_pairlist_payload: called CC=4 SCAR=13.9
3439 2 my ( $runtime, $id, $payload, $placeholders ) = @_;
3440  
3441 2 ▶ die "PairList object payload $id must be an array"
Branch: 1 branch
BranchTrueFalseTotal
if ref $payload ne "ARRAY" 0 2 2
3442 if ref($payload) ne 'ARRAY';
3443  
3444 2 my @list;
3445 my @weak;
3446 2 for my $pair ( @{ $payload } ) {
3447 4 my ( $key, $value, $is_weak ) = _decode_key_value_record(
3448 $runtime,
3449 "PairList object payload $id",
3450 $pair,
3451 $placeholders,
3452 );
3453 4 push @list, [ $key, undef ];
3454 4 store_value( \$list[-1][1], $value, $is_weak );
3455 4 ▶ push @weak, $is_weak ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$is_weak ? : 1 3 4
3456 }
3457  
3458 2 return ( \@list, \@weak );
3459 }
3460  
3461 10 ▶sub _decode_key_value_record {
Subroutine _decode_key_value_record: called CC=4 SCAR=14.8
3462 10 my ( $runtime, $context, $pair, $placeholders ) = @_;
3463  
3464 die "$context entries must be two-item arrays"
3465 10 ▶ if ref($pair) ne 'ARRAY' or scalar @{ $pair } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $pair ne "ARRAY" or scalar @{$pair;} != 2 0 10 10
Condition33%1/3
ref $pair ne "ARRAY" or scalar @{$pair;} != 2
l!l&&r!l&&!r
0010
MC/DC0%0/2
ref $pair ne "ARRAY" or scalar @{$pair;} != 2
ref $pair ne "ARRAY" scalar @{$pair;} != 2
Truth table33%1/3
A or B
A= ref $pair ne "ARRAY"B= scalar @{$pair;} != 2
ABresult
1X1
011
000
3466  
3467 10 my ( $key, $value ) = @{ $pair };
3468 10 ▶ die "$context keys must be text strings"
Branch: 1 branch
BranchTrueFalseTotal
unless is_text_string($key) 0 10 10
3469 if !is_text_string($key);
3470  
3471 return (
3472 10 text_value($key),
3473 _decode_stored_value(
3474 $runtime,
3475 $value,
3476 $placeholders,
3477 "$context value",
3478 ),
3479 );
3480 }
3481  
3482 32 ▶sub _decode_stored_value {
Subroutine _decode_stored_value: called CC=3 SCAR=11.0
3483 32 my ( $runtime, $value, $placeholders, $context ) = @_;
3484  
3485 32 ▶ $context //= 'Stored value';
Condition50%1/2
$context //= "Stored value"
l!l
320
MC/DC0%0/1
$context //= "Stored value"
$context
Truth table50%1/2
A
A= $context
Aresult
11
00
3486 32 ▶ if ( _is_weak_storage_record($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (_is_weak_storage_record($value)) 11 21 32
3487 11 _validate_weak_storage_record(
3488 $runtime,
3489 $value,
3490 $placeholders,
3491 $context,
3492 );
3493 return (
3494 11 _decode_value(
3495 $runtime,
3496 $value->[1],
3497 $placeholders,
3498 allow_weak => 0,
3499 context => "$context weak storage value",
3500 ),
3501 1,
3502 );
3503 }
3504  
3505 return (
3506 21 _decode_value(
3507 $runtime,
3508 $value,
3509 $placeholders,
3510 allow_weak => 0,
3511 context => $context,
3512 ),
3513 0,
3514 );
3515 }
3516  
3517 59 ▶sub _decode_value {
Subroutine _decode_value: called CC=17 SCAR=31.5
3518 59 my ( $runtime, $value, $placeholders, %opts ) = @_;
3519  
3520 59 ▶ my $allow_weak = exists $opts{allow_weak} ? $opts{allow_weak} : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $opts{'allow_weak'} ? : 59 0 59
3521 59 ▶ my $context = $opts{context} // 'Encoded value';
Condition50%1/2
$opts{"context"} // "Encoded value"
l!l
590
MC/DC0%0/1
$opts{"context"} // "Encoded value"
$opts{"context"}
Truth table50%1/2
A
A= $opts{"context"}
Aresult
11
00
3522  
3523 59 ▶ return _decode_scalar_value( $runtime, $value )
Branch: 1 branch
BranchTrueFalseTotal
if not ref $value or is_cbor_bool($value) or is_text_string($value) or is_byte_string($value) 27 32 59
Condition77%7/9
not ref $value or is_cbor_bool($value) or is_text_string($value) or is_byte_string($value)
l!l&&r!l&&!r
27032
not ref $value or is_cbor_bool($value) or is_text_string($value)
l!l&&r!l&&!r
23432
not ref $value or is_cbor_bool($value)
l!l&&r!l&&!r
23036
MC/DC50%2/4
not ref $value or is_cbor_bool($value) or is_text_string($value) or is_byte_string($value)
not ref $value is_cbor_bool($value) is_text_string($value) is_byte_string($value)
Truth table60%3/5
not(A) or B or C or D
A= not ref $valueB= is_cbor_bool($value)C= is_text_string($value)D= is_byte_string($value)
ABCDresult
1XXX1
01XX1
001X1
00011
00000
3524 if !ref($value)
3525 or is_cbor_bool($value)
3526 or is_text_string($value)
3527 or is_byte_string($value);
3528  
3529 32 ▶ if ( ref($value) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "ARRAY") 32 0 32
3530 die "$context array must be [0, id] or [1, value]"
3531 32 ▶ if scalar @{ $value } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @{$value;} != 2 1 31 32
3532 31 my ( $marker, $id ) = @{ $value };
3533 31 ▶ die "$context marker must be 0 or 1"
Branch: 1 branch
BranchTrueFalseTotal
if not _is_integer_value($marker) or $marker != 0 and $marker != 1 0 31 31
Condition50%3/6
not _is_integer_value($marker) or $marker != 0 and $marker != 1
l!l&&r!l&&!r
0031
$marker != 0 and $marker != 1
!ll&&!rl&&r
3010
MC/DC0%0/3
not _is_integer_value($marker) or $marker != 0 and $marker != 1
not _is_integer_value($marker) $marker != 0 $marker != 1
Truth table50%2/4
not(A) or B and C
A= not _is_integer_value($marker)B= $marker != 0C= $marker != 1
ABCresult
1XX1
0111
00X0
0100
3534 if !_is_integer_value($marker)
3535 or ( $marker != 0 and $marker != 1 );
3536 31 ▶ if ( $marker == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($marker == 1) 1 30 31
3537 1 _validate_weak_storage_record(
3538 $runtime,
3539 $value,
3540 $placeholders,
3541 $context,
3542 );
3543 0 ▶ die "$context weak storage record is not allowed here"
Branch: 1 branch
BranchTrueFalseTotal
unless $allow_weak 0 0 0
3544 if !$allow_weak;
3545 0 die "$context weak storage record is only allowed in a "
3546 . "stored value position";
3547 }
3548 30 ▶ die "Encoded reference id must be an integer"
Branch: 1 branch
BranchTrueFalseTotal
unless _is_integer_value($id) 0 30 30
3549 if !_is_integer_value($id);
3550 die "Reference id $id is outside the object table"
3551 30 ▶ if $id < 0 or $id > $#{ $placeholders };
Branch: 1 branch
BranchTrueFalseTotal
if $id < 0 or $id > $#{$placeholders;} 1 29 30
Condition66%2/3
$id < 0 or $id > $#{$placeholders;}
l!l&&r!l&&!r
0129
MC/DC50%1/2
$id < 0 or $id > $#{$placeholders;}
$id < 0 $id > $#{$placeholders;}
Truth table66%2/3
A or B
A= $id < 0B= $id > $#{$placeholders;}
ABresult
1X1
011
000
3552 29 return $placeholders->[$id];
3553 }
3554  
3555 0 die "Envelope root is not a scalar or supported reference";
3556 }
3557  
3558 12 ▶sub _validate_weak_storage_record {
Subroutine _validate_weak_storage_record: called CC=4 SCAR=14.2
3559 12 my ( $runtime, $record, $placeholders, $context ) = @_;
3560  
3561 die "$context weak storage record must be [1, value]"
3562 12 ▶ if ref($record) ne 'ARRAY' or scalar @{ $record } != 2;
Branch: 1 branch
BranchTrueFalseTotal
if ref $record ne "ARRAY" or scalar @{$record;} != 2 0 12 12
Condition33%1/3
ref $record ne "ARRAY" or scalar @{$record;} != 2
l!l&&r!l&&!r
0012
MC/DC0%0/2
ref $record ne "ARRAY" or scalar @{$record;} != 2
ref $record ne "ARRAY" scalar @{$record;} != 2
Truth table33%1/3
A or B
A= ref $record ne "ARRAY"B= scalar @{$record;} != 2
ABresult
1X1
011
000
3563 12 my ( undef, $inner ) = @{ $record };
3564 12 ▶ die "$context nested weak storage records are invalid"
Branch: 1 branch
BranchTrueFalseTotal
if _is_weak_storage_record($inner) 1 11 12
3565 if _is_weak_storage_record($inner);
3566 11 _decode_value(
3567 $runtime,
3568 $inner,
3569 $placeholders,
3570 allow_weak => 0,
3571 context => "$context weak storage value",
3572 );
3573  
3574 11 return 1;
3575 }
3576  
3577 6 ▶sub _reject_weak_storage_record {
Subroutine _reject_weak_storage_record: called CC=2 SCAR=6.9
3578 6 my ( $value, $context ) = @_;
3579  
3580 6 ▶ die "$context weak storage record is not allowed here"
Branch: 1 branch
BranchTrueFalseTotal
if _is_weak_storage_record($value) 1 5 6
3581 if _is_weak_storage_record($value);
3582  
3583 5 return;
3584 }
3585  
3586 50 ▶sub _is_weak_storage_record {
Subroutine _is_weak_storage_record: called CC=5 SCAR=16.2
3587 50 my ( $value ) = @_;
3588  
3589 return 0
3590 if ref($value) ne 'ARRAY'
3591 50 ▶ or scalar @{ $value } != 2
Branch: 1 branch
BranchTrueFalseTotal
if ref $value ne "ARRAY" or scalar @{$value;} != 2 or ref $value->[0] 22 28 50
Condition66%4/6
ref $value ne "ARRAY" or scalar @{$value;} != 2 or ref $value->[0]
l!l&&r!l&&!r
22028
ref $value ne "ARRAY" or scalar @{$value;} != 2
l!l&&r!l&&!r
22028
MC/DC33%1/3
ref $value ne "ARRAY" or scalar @{$value;} != 2 or ref $value->[0]
ref $value ne "ARRAY" scalar @{$value;} != 2 ref $value->[0]
Truth table50%2/4
A or B or C
A= ref $value ne "ARRAY"B= scalar @{$value;} != 2C= ref $value->[0]
ABCresult
1XX1
01X1
0011
0000
3592 or ref( $value->[0] );
3593  
3594 28 ▶ return $value->[0] == 1 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$value->[0] == 1 ? : 13 15 28
3595 }
3596  
3597 13 ▶sub IMPORT {
Subroutine IMPORT: called CC=1 SCAR=0.1
Pod undocumented
3598 13 my ( $class, $runtime ) = @_;
3599  
3600 13 my $exception_parent = $runtime->{_builtin_classes}{Exception};
3601 13 my $marshalling_exception = native_class(
3602 name => 'MarshallingException',
3603 parent => $exception_parent,
3604 );
3605 13 my $unmarshalling_exception = native_class(
3606 name => 'UnmarshallingException',
3607 parent => $exception_parent,
3608 );
3609  
3610 my $dump = native_function(
3611 name => 'dump',
3612 9 ▶ native => sub {
Subroutine __ANON__: called CC=2 SCAR=7.3
3613 9 my @args = @_;
3614 9 _assert_arity( $runtime, 'dump', \@args, 1 );
3615 9 my $bytes;
3616 eval {
3617 9 $bytes = dump_value( $runtime, $args[0] );
3618 9 1;
3619 9 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $bytes = dump_value($runtime, $args[0]); 1 } } or do { my $error = $@; _throw_object($runtime, $marshalling_exception, "std/marshal.dump failed: $error") } 9 0 9
3620 0 my $error = $@;
3621 0 _throw_object(
3622 $runtime,
3623 $marshalling_exception,
3624 "std/marshal.dump failed: $error",
3625 );
3626 };
3627 9 return Zuzu::Value::BinaryString->new( bytes => $bytes );
3628 },
3629 13 );
3630  
3631 my $load = native_function(
3632 name => 'load',
3633 9 ▶ native => sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
3634 9 my @args = @_;
3635 9 _assert_arity( $runtime, 'load', \@args, 1 );
3636 9 _assert_binary_string( $runtime, 'load', $args[0] );
3637 9 my $value;
3638 eval {
3639 9 $value = load_value( $runtime, $args[0]->bytes );
3640 8 1;
3641 9 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { $value = load_value($runtime, $args[0]->bytes); 1 } } or do { my $error = $@; _throw_object($runtime, $unmarshalling_exception, "std/marshal.load failed: $error") } 8 1 9
3642 1 my $error = $@;
3643 1 _throw_object(
3644 $runtime,
3645 $unmarshalling_exception,
3646 "std/marshal.load failed: $error",
3647 );
3648 };
3649 8 return $value;
3650 },
3651 13 );
3652  
3653 my $safe_to_dump = native_function(
3654 name => 'safe_to_dump',
3655 0 ▶ native => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3656 0 my @args = @_;
3657 0 _assert_arity( $runtime, 'safe_to_dump', \@args, 1 );
3658 0 ▶ return _safe_to_dump( $runtime, $args[0] ) ? $TRUE : $FALSE;
Branch: 1 branch
BranchTrueFalseTotal
_safe_to_dump($runtime, $args[0]) ? : 0 0 0
3659 },
3660 13 );
3661  
3662 return {
3663 13 dump => $dump,
3664 load => $load,
3665 safe_to_dump => $safe_to_dump,
3666 MarshallingException => $marshalling_exception,
3667 UnmarshallingException => $unmarshalling_exception,
3668 };
3669 }
3670  
3671 7 1;
3672  
3673 =pod
3674  
3675 =head1 NAME
3676  
3677 Zuzu::Module::Marshal - runtime support for std/marshal
3678  
3679 =head1 DESCRIPTION
3680  
3681 Runtime support for C<std/marshal>. The current implementation supports
3682 Zuzu Marshal CBOR v1 envelopes with scalars, Pair, Array, Dict,
3683 PairList, Set, Bag, Time, Path, user functions, user-defined classes,
3684 user-defined traits, user object values, and bound method values. User
3685 object C<__on_dump__> and C<__on_load__> lifecycle hooks are called
3686 during dump and load.
3687 C<safe_to_dump> performs the same dump traversal and returns false for
3688 values that cannot currently be marshalled. User-defined functions,
3689 classes, and traits are serialized through code table records
3690 containing source, scalar captures, and supported dependencies. Weak
3691 storage records are emitted and loaded only in stored value positions
3692 such as object slots and collection entries. Malformed, nested, or
3693 misplaced weak records are rejected. A weak edge that is not already
3694 strongly reachable is encoded as C<[1, null]> so that marshalling does
3695 not strengthen it during dump or load.
3696  
3697 =head1 COPYRIGHT AND LICENCE
3698  
3699 B<< Zuzu::Module::Marshal >> is copyright Toby Inkster.
3700  
3701 It is free software; you may redistribute it and/or modify it under
3702 the terms of either the Artistic License 1.0 or the GNU General Public
3703 License version 2.
3704  
3705 =cut
« blib/lib/Zuzu/Module/Proc.pm ↑ Summary blib/script/zuzu-highlight.pl »