lib/SIRTX/VM/Assembler.pm

filter: Statementstmt 7.7% 56 / 726 Branchbran 0.0% 0 / 394 Conditioncond 0.0% 0 / 343 MC/DCmcdc 0.0% 0 / 174 Subroutinesub 26.1% 11 / 42 Podpod 100% 3 / 3 totaltotal 4.1% 70 / 1682 CC 356 SCAR 105.5
CC
356
Cov
4%
_proc_parts
61256.0
run
552.0
_get_value_type
210.0
CRAP 38165.9
↑ Summary blib/lib/SIRTX/VM/Assembler.pm »
1 # Copyright (c) 2025-2026 Philipp Schafft
2  
3 # licensed under Artistic License 2.0 (see LICENSE file)
4  
5 # ABSTRACT: module for assembling SIRTX VM code
6  
7  
8 package SIRTX::VM::Assembler;
9  
10 1 ▶use v5.16;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Fcntl qw(SEEK_SET SEEK_CUR SEEK_END);
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use List::Util qw(uniq);
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 ▶use String::Super;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use SIRTX::VM::RegisterFile;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶use SIRTX::VM::Opcode;
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 1 ▶use parent 'Data::Identifier::Interface::Userdata';
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 1 our $VERSION = v0.12;
27  
28 1 my %_escapes = (
29 '\\' => '\\',
30 '0' => chr(0x00),
31 'n' => chr(0x0A),
32 'r' => chr(0x0D),
33 't' => chr(0x09),
34 'e' => chr(0x1B),
35 );
36 1 my %_type_to_sni = %SIRTX::VM::Opcode::_logicals_to_sni; # copy
37 1 my %_sni_to_type = map {$_type_to_sni{$_} => $_} keys %_type_to_sni;
38  
39 1 my %_header_ids = (
40 init => 1,
41 header => 2,
42 rodata => 3,
43 text => 4,
44 trailer => 5,
45 resources => 6,
46 );
47  
48 1 our %_header_ids_rev = reverse %_header_ids;
49  
50 1 my @_section_order = qw(header init text rodata resources trailer);
51 1 my @_section_text = qw(header init text);
52 1 my @_section_load = (@_section_text, qw(rodata resources));
53  
54 my %_disabled_sections = (
55 1 'resources_only' => {map {$_ => 1} qw(init text)},
56 );
57  
58 1 my %_info = map {$_ => 1} (
59 qw(.author .license .copyright_years .copyright_holder),
60 qw(.description .comment .displayname .displaycolour .icon .icontext),
61 qw(.subject_webpage .vendor_webpage .author_webpage .webpage),
62 qw(.repo_uri),
63 );
64  
65 1 my %_profiles = (
66 default => 0,
67 resources_only => 1,
68 minimal => 2,
69 );
70  
71 my %_synthetic = (
72 default => {
73 mul => [['"out"' => 'undef', reg => 1, '"arg"' => 'undef'] => ['user*' => 2] => [
74 ['open', \2, 0],
75 ['control', \2, 'sni:81', \1],
76 ],
77 ['"out"' => 'undef', reg => 1, reg => 2] => ['arg' => 3] => [
78 ['replace', \3, \2],
79 ['mul', 'out', \1, \3],
80 ],
81 ['"out"' => 'undef', reg => 1, int => 2] => ['arg' => 3] => [
82 ['open', \3, \2],
83 ['mul', 'out', \1, \3],
84 ]],
85 contents => [[reg => 1, int => 2] => ['user*' => 3] => [
86 ['open_function*', \3, \2],
87 ['contents*', \1, \3],
88 ],
89 [reg => 1, id => 2] => ['user*' => 3] => [
90 ['open*', \3, \2],
91 ['contents*', \1, \3],
92 ]],
93 call => [[reg => 1, int => 2] => ['user*' => 3] => [
94 ['open_function*', \3, \2],
95 ['call*', \1, \3]
96 ],
97 [reg => 1, id => 2] => ['user*' => 3] => [
98 ['open*', \3, \2],
99 ['call*', \1, \3],
100 ],
101 [[qw(reg int id)] => 1] => ['user*' => 2] => [
102 ['open_context*', \2],
103 ['call*', \2, \1],
104 ]],
105 transfer => [[reg => 1, string => 2] => ['user*' => 3] => [
106 ['open', \3, \2],
107 ['transfer', \1, \3],
108 ]],
109 control => [[reg => 1, [qw(reg sni:)] => 2, [qw(string bool)] => 3] => ['user*' => 4] => [
110 ['open', \4, \3],
111 ['control', \1, \2, \4],
112 ],
113 [reg => 1, [qw(reg sni:)] => 2, [qw(string bool)] => 3, reg => 4] => ['user*' => 5, 'arg' => 6] => [
114 ['open', \5, \3],
115 ['replace', \6, \4],
116 ['control', \1, \2, \5],
117 ],
118 [reg => 1, [qw(reg sni:)] => 2, [qw(string bool)] => 3, any => 4] => ['user*' => 5, 'arg' => 6] => [
119 ['open', \5, \3],
120 ['open', \6, \4],
121 ['control', \1, \2, \5],
122 ],
123 [any => 1, any => 2, any => 3, reg => 4] => ['arg' => 5] => [
124 ['replace', \5, \4],
125 ['control', \1, \2, \3, \5],
126 ],
127 [any => 1, any => 2, any => 3, any => 4] => ['arg' => 5] => [
128 ['open', \5, \4],
129 ['control', \1, \2, \3, \5],
130 ]],
131 push => [[any => 1, string => 2] => ['user*' => 3] => [
132 ['open', \3, \2],
133 ['push', \1, \3],
134 ],
135 [any => 1, any => 2] => ['user*' => 3] => [
136 ['open', \3, \2],
137 ['push', \1, \3],
138 ],
139 [any => 1, [qw(int id string bool)] => 2, '"arg"' => 3] => ['user*' => 4] => [
140 ['open', \4, \2],
141 ['control', \1, 'sni:180', \4, \3],
142 ],
143 [any => 1, reg => 2, '"arg"' => 3] => [] => [
144 ['control', \1, 'sni:180', \2, \3],
145 ],
146 [any => 1, [qw(int id string bool)] => 2, reg => 3] => ['user*' => 4, 'arg' => 5] => [
147 ['open', \4, \2],
148 ['replace', \5, \3],
149 ['control', \1, 'sni:180', \4, \3],
150 ],
151 [any => 1, reg => 2, reg => 3] => ['arg' => 4] => [
152 ['replace', \4, \3],
153 ['control', \1, 'sni:180', \2, \4],
154 ],
155 [any => 1, [qw(int id string bool)] => 2, any => 3] => ['user*' => 4, 'arg' => 5] => [
156 ['open', \4, \2],
157 ['open', \5, \3],
158 ['control', \1, 'sni:180', \4, \3],
159 ],
160 [any => 1, reg => 2, any => 3] => ['arg' => 4] => [
161 ['open', \4, \3],
162 ['control', \1, 'sni:180', \2, \4],
163 ]],
164 pop => [[reg => 1, reg => 2] => [] => [
165 ['control', \2, 'sni:181'],
166 ['replace', \1, 'out'],
167 ]],
168 setvalue => [
169 [reg => 1, reg => 2, '"arg"' => 3] => [] => [
170 ['control', \1, 'sni:102', \2, \3],
171 ],
172 [reg => 1, any => 2, '"arg"' => 3] => ['user*' => 4] => [
173 ['open', \4, \2],
174 ['control', \1, 'sni:102', \4, \3],
175 ],
176 [reg => 1, reg => 2, reg => 3] => ['arg' => 4] => [
177 ['replace', \4, \3],
178 ['control', \1, 'sni:102', \2, \4],
179 ],
180 [reg => 1, any => 2, reg => 3] => ['arg' => 4, 'user*' => 5] => [
181 ['replace', \4, \3],
182 ['open', \5, \2],
183 ['control', \1, 'sni:102', \5, \4],
184 ],
185 [reg => 1, reg => 2, any => 3] => ['arg' => 4] => [
186 ['open', \4, \3],
187 ['control', \1, 'sni:102', \2, \4],
188 ],
189 [reg => 1, any => 2, any => 3] => ['arg' => 4, 'user*' => 5] => [
190 ['open', \4, \3],
191 ['open', \5, \2],
192 ['control', \1, 'sni:102', \5, \4],
193 ]],
194 getvalue => [
195 ['"out"' => 1, reg => 2, any => 3] => ['user*' => 4] => [
196 ['open', \4, \3],
197 ['getvalue', \1, \2, \4],
198 ],
199 [reg => 1, reg => 2, reg => 3] => [] => [
200 ['getvalue', 'out', \2, \3],
201 ['replace', \1, 'out'],
202 ],
203 [reg => 1, reg => 2, any => 3] => ['user*' => 4] => [
204 ['open', \4, \3],
205 ['getvalue', 'out', \2, \4],
206 ['replace', \1, 'out'],
207 ]],
208 relations => [[alias => 1, reg => 2, id => 3, any => 4] => ['user*' => 5, 'user*' => 6] => [
209 ['.force_mapped', \5],
210 ['open_function', \5, \1],
211 ['open', \6, \3],
212 ['relations', \5, \2, \6, \4],
213 ]],
214 write_be8 => [
215 [reg => 1, reg => 2] => [arg => 3] => [
216 ['replace', \3, \2],
217 ['control', \1, 'sni:144', '8'],
218 ],
219 [reg => 1, any => 2] => [arg => 3] => [
220 ['open', \3, \2],
221 ['control', \1, 'sni:144', '8'],
222 ]],
223 write_be16 => [
224 [reg => 1, reg => 2] => [arg => 3] => [
225 ['replace', \3, \2],
226 ['control', \1, 'sni:144', '16'],
227 ],
228 [reg => 1, any => 2] => [arg => 3] => [
229 ['open', \3, \2],
230 ['control', \1, 'sni:144', '16'],
231 ]],
232 '.autosectionstart' => [['"header"' => 1] => [] => [
233 ['.section', \1, '"VM\\r\\n\\xc0\\n"'],
234 ['filesize', 'size$out$'],
235 ['text_boundary', 'end$boundary$text'],
236 ['load_boundary', 'end$boundary$load'],
237 1 (map {['section_pointer', 'section$'.$_.'//section$header']} @_section_order),
238 ],
239 ['"rodata"' => 1] => [] => [
240 ['.section', \1],
241 ['.rodata'], # INTERNAL COMMAND, NOT FOR DOCS!
242 ['.align', 2],
243 ],
244 [any => 1] => [] => [
245 ['.section', \1]
246 ]],
247 '.autosection' => [[any => 1] => [] => [
248 ['.autosectionstart', \1],
249 ['.endsection']
250 ]],
251 '.filechunk' => [[string => 1, 'any...' => 2] => [] => [
252 ['.chunk', \2],
253 ['.cat', \1],
254 ['.endchunk'],
255 ]],
256 '.paddingchunk' => [['any...' => 1] => [] => [
257 ['.chunk', 'of', 'sni:237'],
258 ['.org', \1],
259 ['.endchunk'],
260 ]],
261 },
262 minimal => {
263 '.autosection' => [
264 ['"rodata"' => 1] => [] => [
265 ['data_start_marker'],
266 ['.rodata'], # INTERNAL COMMAND, NOT FOR DOCS!
267 ],
268 [any => 1] => [] => [
269 ]],
270 },
271 );
272  
273 1 my %_section_order_bad;
274  
275 {
276 1 my @got;
277 1 foreach my $section (reverse @_section_order) {
278 6 $_section_order_bad{$section} = {map {$_ => 1} @got};
279 6 push(@got, $section);
280 }
281 }
282  
283  
284 sub new {
285 0 ▶ my ($pkg, %opts) = @_;
Subroutine new: not called CC=11 SCAR=48.8
Pod documented
286 0 my $self = bless({
287 alive => 1,
288 alignment => 1024,
289 aliases => {},
290 current => {},
291 rf => SIRTX::VM::RegisterFile->new,
292 regmap_last_used_c => 0,
293 regmap_last_used => {},
294 regmap_mapped => {},
295 sections => {},
296 pushback => [],
297 settings => {
298 synthetic_auto_unref => 1,
299 regmap_auto => undef,
300 },
301 rodata => String::Super->new,
302 alias_rodata_idx => {},
303 auto_host_defined => undef,
304 profiles => [],
305 profiles_hash => undef,
306 }, $pkg);
307  
308 {
309 0 my $fh = delete $opts{in};
310 0 ▶ croak 'No input given' unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
311  
312 0 ▶ unless (ref $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $fh) 0 0 0
313 0 ▶ open(my $x, '<', $fh) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $x, "<", $fh or die $! 0 0 0
314 0 $fh = $x;
315 }
316  
317 0 $fh->binmode;
318 0 $fh->binmode(':utf8');
319 0 $self->{in} = $fh;
320 }
321  
322 {
323 0 my $fh = delete $opts{out};
324 0 ▶ croak 'No output given' unless defined $fh;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fh 0 0 0
325  
326 0 ▶ unless (ref $fh) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $fh) 0 0 0
327 0 ▶ open(my $x, '>', $fh) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $x, ">", $fh or die $! 0 0 0
328 0 $fh = $x;
329 }
330  
331 0 $fh->binmode;
332 0 $self->{out} = $fh;
333 }
334  
335 0 $self->_join_profile('default');
336  
337 0 ▶ if (defined(my $profile = delete $opts{profile})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $profile = delete $opts{"profile"})) 0 0 0
338 0 ▶ $profile = [$profile] unless ref $profile;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $profile 0 0 0
339  
340 0 foreach my $p (@{$profile}) {
341 0 $self->_join_profile(split(/(?:\s*,\s*|\s+)/, $p));
342 }
343 }
344  
345 0 ▶ croak 'Stray options passed' if scalar keys %opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar keys %opts 0 0 0
346  
347 0 return $self;
348 }
349  
350  
351 sub run {
352 0 ▶ my ($self, @opts) = @_;
Subroutine run: not called CC=23 SCAR=63.1
Pod documented
353  
354 0 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 0 0
355  
356 0 $self->_save_position('out$');
357 0 $self->_proc_input($self->{in});
358  
359 0 eval {
360 0 my $size;
361 0 $self->{out}->seek(0, SEEK_END);
362 0 $size = $self->{out}->tell;
363 0 ▶ if ($size & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($size & 1) 0 0 0
364 0 carp sprintf('WARNING: Final file size is %u bytes, this is a odd number', $size);
365 }
366 0 $self->_save_endposition('out$');
367 };
368  
369 {
370 0 my $boundary = 0;
371  
372 0 foreach my $section (@_section_text) {
373 0 ▶ my $s = $self->{aliases}{'end$inner$section$'.$section} // next;
Condition0%0/2
$self->{"aliases"}{'end$inner$section$' . $section} // (next)
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'end$inner$section$' . $section} // (next)
$self->{"aliases"}{'end$inner$section$' . $section}
Truth table0%0/2
A
A= $self->{"aliases"}{'end$inner$section$' . $section}
Aresult
11
00
374 0 ▶ $boundary = $s->[-1] if $boundary < $s->[-1];
Branch: 1 branch
BranchTrueFalseTotal
if $boundary < $s->[-1] 0 0 0
375 }
376  
377 0 ▶ if ($boundary & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($boundary & 1) 0 0 0
378 0 ▶ if (defined($self->{aliases}{'size$out$'}) && $self->{aliases}{'size$out$'}[-1] > $boundary) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'aliases'}{'size$out$'} and $self->{'aliases'}{'size$out$'}[-1] > $boundary) { } 0 0 0
Condition0%0/3
defined $self->{"aliases"}{"size\$out\$"} and $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"aliases"}{"size\$out\$"} and $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
defined $self->{"aliases"}{"size\$out\$"} $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
Truth table0%0/3
A and B
A= defined $self->{"aliases"}{"size\$out\$"}B= $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
ABresult
0X0
100
111
379 0 $boundary++;
380 } else {
381 0 croak sprintf('Error: Text boundary has odd size and output size is invalid/too low');
382 }
383 }
384  
385 0 ▶ push(@{$self->{aliases}{'boundary$text'} //= []}, 0);
Condition0%0/2
$self->{"aliases"}{"boundary\$text"} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{"boundary\$text"} //= []
$self->{"aliases"}{"boundary\$text"}
Truth table0%0/2
A
A= $self->{"aliases"}{"boundary\$text"}
Aresult
11
00
386 0 ▶ push(@{$self->{aliases}{'end$boundary$text'} //= []}, $boundary);
Condition0%0/2
$self->{"aliases"}{"end\$boundary\$text"} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{"end\$boundary\$text"} //= []
$self->{"aliases"}{"end\$boundary\$text"}
Truth table0%0/2
A
A= $self->{"aliases"}{"end\$boundary\$text"}
Aresult
11
00
387 }
388  
389 {
390 0 my $boundary = 0;
391  
392 0 foreach my $section (@_section_load) {
393 0 ▶ my $s = $self->{aliases}{'end$inner$section$'.$section} // next;
Condition0%0/2
$self->{"aliases"}{'end$inner$section$' . $section} // (next)
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'end$inner$section$' . $section} // (next)
$self->{"aliases"}{'end$inner$section$' . $section}
Truth table0%0/2
A
A= $self->{"aliases"}{'end$inner$section$' . $section}
Aresult
11
00
394 0 ▶ $boundary = $s->[-1] if $boundary < $s->[-1];
Branch: 1 branch
BranchTrueFalseTotal
if $boundary < $s->[-1] 0 0 0
395 }
396  
397 0 ▶ if ($boundary & 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($boundary & 1) 0 0 0
398 0 ▶ if (defined($self->{aliases}{'size$out$'}) && $self->{aliases}{'size$out$'}[-1] > $boundary) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'aliases'}{'size$out$'} and $self->{'aliases'}{'size$out$'}[-1] > $boundary) { } 0 0 0
Condition0%0/3
defined $self->{"aliases"}{"size\$out\$"} and $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"aliases"}{"size\$out\$"} and $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
defined $self->{"aliases"}{"size\$out\$"} $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
Truth table0%0/3
A and B
A= defined $self->{"aliases"}{"size\$out\$"}B= $self->{"aliases"}{"size\$out\$"}[-1] > $boundary
ABresult
0X0
100
111
399 0 $boundary++;
400 } else {
401 0 croak sprintf('Error: Load boundary has odd size and output size is invalid/too low');
402 }
403 }
404  
405 0 ▶ push(@{$self->{aliases}{'boundary$load'} //= []}, 0);
Condition0%0/2
$self->{"aliases"}{"boundary\$load"} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{"boundary\$load"} //= []
$self->{"aliases"}{"boundary\$load"}
Truth table0%0/2
A
A= $self->{"aliases"}{"boundary\$load"}
Aresult
11
00
406 0 ▶ push(@{$self->{aliases}{'end$boundary$load'} //= []}, $boundary);
Condition0%0/2
$self->{"aliases"}{"end\$boundary\$load"} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{"end\$boundary\$load"} //= []
$self->{"aliases"}{"end\$boundary\$load"}
Truth table0%0/2
A
A= $self->{"aliases"}{"end\$boundary\$load"}
Aresult
11
00
407 }
408  
409 # We are past the first pass.
410 # We disable automapping here. If there is still mapping needed there is a bug somewhere as this all should be resolved by now.
411 # So turning it off to let any requests fail is the safest option.
412 0 $self->{settings}{regmap_auto} = undef;
413  
414 {
415 0 my $pushback = $self->{pushback};
416  
417 0 $self->{pushback} = []; # reset
418  
419 0 foreach my $entry (@{$pushback}) {
420 0 local $self->{rf} = $entry->{rf};
421 0 $self->{out}->seek($entry->{pos}, SEEK_SET);
422 0 ▶ $entry->{update}->($self, $entry) if defined $entry->{update};
Branch: 1 branch
BranchTrueFalseTotal
if defined $entry->{"update"} 0 0 0
423 0 $self->_proc_parts($entry->{parts}, $entry->{opts}, undef, 1);
424 }
425 }
426  
427 0 ▶ if (scalar(@{$self->{pushback}})) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"pushback"};}) 0 0 0
428 0 foreach my $entry (@{$self->{pushback}}) {
429 0 carp sprintf('Warning: Still active pushback from line %u', $entry->{opts}{line});
430 }
431  
432 0 croak sprintf('Error: There are still %u open pushbacks', scalar(@{$self->{pushback}}));
433 }
434 }
435  
436  
437 sub dump {
438 0 ▶ my ($self, $dumpfilename, @opts) = @_;
Subroutine dump: not called CC=11 SCAR=48.8
Pod documented
439 0 my $aliases = $self->{aliases};
440 0 my $rf = $self->{rf};
441 0 my $dumpfh;
442  
443 0 ▶ croak 'Stray options passed' if scalar @opts;
Branch: 1 branch
BranchTrueFalseTotal
if scalar @opts 0 0 0
444  
445 0 ▶ if (ref($dumpfilename)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $dumpfilename) { } 0 0 0
446 0 $dumpfh = $dumpfilename;
447 } else {
448 0 $dumpfh = $self->_open_file($dumpfilename, '>');
449 }
450 0 $dumpfh->binmode;
451 0 $dumpfh->binmode(':utf8');
452  
453 0 say $dumpfh '; Profiles:';
454 0 foreach my $key (@{$self->{profiles}}) {
455 0 printf $dumpfh "; %s\n", $key;
456 }
457  
458 0 say $dumpfh '';
459 0 say $dumpfh '; Settings:';
460 0 foreach my $key (sort keys %{$self->{settings}}) {
461 0 ▶ printf $dumpfh "; %-32s -> %s\n", $key, $self->{settings}{$key} // '<undef>';
Condition0%0/2
$self->{"settings"}{$key} // "<undef>"
l!l
00
MC/DC0%0/1
$self->{"settings"}{$key} // "<undef>"
$self->{"settings"}{$key}
Truth table0%0/2
A
A= $self->{"settings"}{$key}
Aresult
11
00
462 }
463  
464 0 say $dumpfh '';
465 0 say $dumpfh '; Register map:';
466 0 foreach my $reg ($rf->expand('r*')) {
467 0 ▶ printf $dumpfh "; %-32s -> %s\n", $reg, scalar(eval {$rf->get_physical_by_name($reg)->name}) // '<?>';
Condition0%0/2
scalar eval { do { $rf->get_physical_by_name($reg)->name } } // "<?>"
l!l
00
MC/DC0%0/1
scalar eval { do { $rf->get_physical_by_name($reg)->name } } // "<?>"
scalar eval { do { $rf->get_physical_by_name($reg)->name } }
Truth table0%0/2
A
A= scalar eval { do { $rf->get_physical_by_name($reg)->name } }
Aresult
11
00
468 }
469  
470 0 say $dumpfh '';
471 0 say $dumpfh '; Register attributes:';
472 0 foreach my $reg ($rf->expand('r*', 'user*', 'system*')) {
473 0 my $physical = $rf->get_physical_by_name($reg)->physical;
474 0 my $temperature = $rf->register_temperature($reg);
475 0 my $owner = $rf->register_owner($reg);
476 0 ▶ printf $dumpfh "; %-32s -> %2u: %8s %8s %8u\n", $reg, $physical, $temperature, $owner, $self->{regmap_last_used}{$physical} // 0;
Condition0%0/2
$self->{"regmap_last_used"}{$physical} // 0
l!l
00
MC/DC0%0/1
$self->{"regmap_last_used"}{$physical} // 0
$self->{"regmap_last_used"}{$physical}
Truth table0%0/2
A
A= $self->{"regmap_last_used"}{$physical}
Aresult
11
00
477 }
478  
479 0 say $dumpfh '';
480 0 say $dumpfh '; Aliases:';
481 0 foreach my $key (sort keys %{$aliases}) {
482 0 printf $dumpfh "; %-32s = %s\n", $key, join(', ', @{$aliases->{$key}});
483 }
484 }
485 # ---- Private helpers ----
486 sub _open_file {
487 0 ▶ my ($self, $filename, $mode) = @_;
Subroutine _open_file: not called CC=3 SCAR=24.8
488 0 ▶ $mode //= '<';
Condition0%0/2
$mode //= "<"
l!l
00
MC/DC0%0/1
$mode //= "<"
$mode
Truth table0%0/2
A
A= $mode
Aresult
11
00
489 0 ▶ open(my $fh, $mode, $filename) or die $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, $mode, $filename or die $! 0 0 0
490 0 return $fh;
491 }
492  
493 sub _alive {
494 0 ▶ my ($self) = @_;
Subroutine _alive: not called CC=1 SCAR=6.9
495 0 return $self->{alive};
496 }
497  
498 sub _quit {
499 0 ▶ my ($self) = @_;
Subroutine _quit: not called CC=1 SCAR=6.9
500 0 delete $self->{alive};
501 }
502  
503 sub _join_profile {
504 0 ▶ my ($self, @profiles) = @_;
Subroutine _join_profile: not called CC=3 SCAR=24.8
505 0 push(@profiles, @{$self->{profiles}});
506  
507 0 ▶ $self->{profiles} = [uniq sort {($_profiles{$b} // croak 'Bad profile: '.$b) <=> ($_profiles{$a} // croak 'Bad profile: '.$a)} @profiles];
Condition0%0/6
$_profiles{$b} // croak('Bad profile: ' . $b)
l!l&&r!l&&!r
000
$_profiles{$a} // croak('Bad profile: ' . $a)
l!l&&r!l&&!r
000
MC/DC0%0/2
$_profiles{$b} // croak('Bad profile: ' . $b)
$_profiles{$b} croak('Bad profile: ' . $b)
MC/DC0%0/2
$_profiles{$a} // croak('Bad profile: ' . $a)
$_profiles{$a} croak('Bad profile: ' . $a)
Truth table0%0/3
A // B
A= $_profiles{$b}B= croak('Bad profile: ' . $b)
ABresult
1X1
011
000
Truth table0%0/3
A // B
A= $_profiles{$a}B= croak('Bad profile: ' . $a)
ABresult
1X1
011
000
508 0 $self->{profiles_hash} = {map {$_ => 1} @{$self->{profiles}}};
509 }
510  
511 sub _using_profile {
512 0 ▶ my ($self, @profile) = @_;
Subroutine _using_profile: not called CC=3 SCAR=24.8
513 0 my $hash = $self->{profiles_hash};
514  
515 0 foreach my $profile (@profile) {
516 0 ▶ return 1 if $hash->{$profile};
Branch: 1 branch
BranchTrueFalseTotal
if $hash->{$profile} 0 0 0
517 }
518  
519 0 return undef;
520 }
521  
522 sub _get_synthetic {
523 0 ▶ my ($self, $cmd) = @_;
Subroutine _get_synthetic: not called CC=3 SCAR=24.8
524  
525 0 foreach my $profile (@{$self->{profiles}}) {
526 0 ▶ if (defined(my $entry = $_synthetic{$profile}{$cmd})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $entry = $_synthetic{$profile}{$cmd})) 0 0 0
527 0 return $entry;
528 }
529 }
530  
531 0 return undef;
532 }
533  
534 sub _align {
535 0 ▶ my ($self, $req, $warn) = @_;
Subroutine _align: not called CC=6 SCAR=37.4
536 0 ▶ if ($self->{alignment} % $req) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"alignment"} % $req) 0 0 0
537 0 my $pos = $self->{out}->tell;
538 0 my $error = $pos % $req;
539 0 ▶ if ($error) {
Branch: 1 branch
BranchTrueFalseTotal
if ($error) 0 0 0
540 0 ▶ $warn //= 0;
Condition0%0/2
$warn //= 0
l!l
00
MC/DC0%0/1
$warn //= 0
$warn
Truth table0%0/2
A
A= $warn
Aresult
11
00
541 0 ▶ if ($warn > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if ($warn > 1) { } 0 0 0
elsif ($warn) { } 0 0 0
542 0 croak sprintf('Fatal alignment missmatch would need to skip %u bytes', $req - $error);
543 } elsif ($warn) {
544 0 carp sprintf('Alignment missmatch, auto skipping %u bytes', $req - $error);
545 }
546 0 $self->{out}->seek($req - $error, SEEK_CUR);
547 0 $self->{alignment} = $req;
548 }
549 }
550 }
551  
552 sub _set_alignment {
553 0 ▶ my ($self, $value) = @_;
Subroutine _set_alignment: not called CC=1 SCAR=6.9
554 0 $self->{alignment} = $value;
555 }
556  
557 sub _save_position {
558 0 ▶ my ($self, $name) = @_;
Subroutine _save_position: not called CC=2 SCAR=17.9
559 0 ▶ push(@{$self->{aliases}{$name} //= []}, $self->{out}->tell);
Condition0%0/2
$self->{"aliases"}{$name} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{$name} //= []
$self->{"aliases"}{$name}
Truth table0%0/2
A
A= $self->{"aliases"}{$name}
Aresult
11
00
560 }
561 sub _save_endposition {
562 0 ▶ my ($self, $name) = @_;
Subroutine _save_endposition: not called CC=4 SCAR=30.0
563 0 ▶ push(@{$self->{aliases}{'end$' .$name} //= []}, $self->{out}->tell);
Condition0%0/2
$self->{"aliases"}{'end$' . $name} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'end$' . $name} //= []
$self->{"aliases"}{'end$' . $name}
Truth table0%0/2
A
A= $self->{"aliases"}{'end$' . $name}
Aresult
11
00
564 0 ▶ push(@{$self->{aliases}{'size$'.$name} //= []}, $self->{aliases}{'end$'.$name}->[-1] - $self->{aliases}{$name}->[-1]) if defined $self->{aliases}{$name};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"aliases"}{$name} 0 0 0
Condition0%0/2
$self->{"aliases"}{'size$' . $name} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'size$' . $name} //= []
$self->{"aliases"}{'size$' . $name}
Truth table0%0/2
A
A= $self->{"aliases"}{'size$' . $name}
Aresult
11
00
565 }
566  
567 sub _write_opcode {
568 0 ▶ my ($self, $opcode) = @_;
Subroutine _write_opcode: not called CC=1 SCAR=6.9
569 0 $self->_align($opcode->required_alignment, 1);
570 0 $opcode->write($self->{out});
571 0 $self->_set_alignment($opcode->new_alignment);
572 }
573  
574 sub _reg_map {
575 0 ▶ my ($self, $loc, $phy) = @_;
Subroutine _reg_map: not called CC=1 SCAR=6.9
576 0 my $rf = $self->{rf};
577 0 $loc = $rf->get_logical_by_name($loc);
578 0 $phy = $rf->get_physical_by_name($phy);
579 0 $rf->map($loc, $phy);
580 0 return ($loc, $phy);
581 }
582 sub _reg_map_and_write {
583 0 ▶ my ($self, @args) = @_;
Subroutine _reg_map_and_write: not called CC=1 SCAR=6.9
584 0 my ($loc, $phy) = $self->_reg_map(@args);
585 0 $self->_write_opcode(SIRTX::VM::Opcode->new(code => 0, codeX => 3, P => $loc, ST => $phy->physical));
586 }
587  
588 sub _force_mapped {
589 0 ▶ my ($self, $register) = @_;
Subroutine _force_mapped: not called CC=7 SCAR=40.3
590 0 my $regmap_last_used = $self->{regmap_last_used};
591 0 my $rf = $self->{rf};
592 0 my $loc = eval {$rf->get_logical_by_name($register)};
593 0 my $inc = 5;
594  
595 0 ▶ unless (defined $loc) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $loc) 0 0 0
596 0 ▶ if ($self->{settings}{regmap_auto}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"settings"}{"regmap_auto"}) 0 0 0
597 # Try to auto-map a register.
598 0 my $regmap_mapped = $self->{regmap_mapped};
599 0 ▶ my ($reg) = sort {($regmap_last_used->{$a} // 0) <=> ($regmap_last_used->{$b} // 0)} map {$_->physical} map {$rf->get_physical_by_name($_)} grep {$rf->register_owner($_) eq SIRTX::VM::Register::OWNER_YOURS()} grep {!$regmap_mapped->{$_}} $rf->expand('r*');
Condition0%0/4
$regmap_last_used->{$a} // 0
l!l
00
$regmap_last_used->{$b} // 0
l!l
00
MC/DC0%0/1
$regmap_last_used->{$a} // 0
$regmap_last_used->{$a}
MC/DC0%0/1
$regmap_last_used->{$b} // 0
$regmap_last_used->{$b}
Truth table0%0/2
A
A= $regmap_last_used->{$a}
Aresult
11
00
Truth table0%0/2
A
A= $regmap_last_used->{$b}
Aresult
11
00
600  
601 0 ▶ croak 'No suitable register found for auto mapping, did you set enough registers with .yours?' unless defined $reg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reg 0 0 0
602  
603 0 $loc = $rf->get_logical_by_physical($reg);
604 0 $regmap_mapped->{'r'.$loc} = 1;
605 0 $self->_reg_map_and_write('r'.$loc, $register);
606 }
607  
608 0 ▶ croak 'Cannot map register: '.$register unless defined $loc;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $loc 0 0 0
609 }
610  
611 {
612 0 my $physical = $rf->get_logical($loc)->physical;
613 0 $regmap_last_used->{$physical} = $self->{regmap_last_used_c} + $inc;
614 0 $self->{regmap_last_used_c} += 5;
615 }
616 0 return $loc;
617 }
618  
619 sub _reg_alloc_phy {
620 0 ▶ my ($self, @names) = @_;
Subroutine _reg_alloc_phy: not called CC=4 SCAR=30.0
621 0 my $regmap_mapped = $self->{regmap_mapped};
622 0 my $rf = $self->{rf};
623 0 ▶ my ($reg) = sort {(eval {$rf->get_logical_by_name($a)} // 999) <=> (eval {$rf->get_logical_by_name($b)} // 999)}
Condition0%0/4
eval { do { $rf->get_logical_by_name($a) } } // 999
l!l
00
eval { do { $rf->get_logical_by_name($b) } } // 999
l!l
00
MC/DC0%0/1
eval { do { $rf->get_logical_by_name($a) } } // 999
eval { do { $rf->get_logical_by_name($a) } }
MC/DC0%0/1
eval { do { $rf->get_logical_by_name($b) } } // 999
eval { do { $rf->get_logical_by_name($b) } }
Truth table0%0/2
A
A= eval { do { $rf->get_logical_by_name($a) } }
Aresult
11
00
Truth table0%0/2
A
A= eval { do { $rf->get_logical_by_name($b) } }
Aresult
11
00
624 0 grep {$rf->register_owner($_) eq SIRTX::VM::Register::OWNER_YOURS()}
625 0 grep {!$regmap_mapped->{$_}}
626 $rf->expand(@names);
627  
628 0 ▶ croak 'No suitable physical register found for auto mapping, did you set enough registers with .yours?' unless defined $reg;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $reg 0 0 0
629  
630 0 $regmap_mapped->{$reg} = 1;
631  
632 0 return $reg;
633 }
634  
635 sub _autostring_allocate {
636 0 ▶ my ($self, $str) = @_;
Subroutine _autostring_allocate: not called CC=2 SCAR=17.9
637 0 state $autostring = 0;
638 0 my $key = sprintf('autostring$%u', $autostring++);
639  
640 0 $self->{alias_rodata_idx}{$key} = $self->{rodata}->add_blob($str);
641 0 ▶ push(@{$self->{aliases}{'size$'.$key} //= []}, length($str));
Condition0%0/2
$self->{"aliases"}{'size$' . $key} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'size$' . $key} //= []
$self->{"aliases"}{'size$' . $key}
Truth table0%0/2
A
A= $self->{"aliases"}{'size$' . $key}
Aresult
11
00
642  
643 0 return $key;
644 }
645  
646 sub _auto_host_defined {
647 0 ▶ my ($self) = @_;
Subroutine _auto_host_defined: not called CC=4 SCAR=30.0
648 0 my $auto_host_defined = $self->{auto_host_defined};
649 0 my $res;
650  
651 0 ▶ croak 'No auto host defined IDs available' unless defined($auto_host_defined) && defined($auto_host_defined->[2]);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $auto_host_defined and defined $auto_host_defined->[2] 0 0 0
Condition0%0/3
defined $auto_host_defined and defined $auto_host_defined->[2]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $auto_host_defined and defined $auto_host_defined->[2]
defined $auto_host_defined defined $auto_host_defined->[2]
Truth table0%0/3
A and B
A= defined $auto_host_definedB= defined $auto_host_defined->[2]
ABresult
0X0
100
111
652  
653 0 $res = $auto_host_defined->[2]++;
654  
655 0 ▶ if ($auto_host_defined->[2] > $auto_host_defined->[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($auto_host_defined->[2] > $auto_host_defined->[1]) 0 0 0
656 0 $auto_host_defined->[2] = undef;
657 }
658  
659 0 return '~'.$res;
660 }
661  
662 sub _pushback {
663 0 ▶ my ($self, %opts) = @_;
Subroutine _pushback: not called CC=1 SCAR=6.9
664 0 $opts{rf} = $self->{rf}->clone;
665 0 push(@{$self->{pushback}}, \%opts);
666 }
667  
668 sub _proc_input {
669 0 ▶ my ($self, $in) = @_;
Subroutine _proc_input: not called CC=11 SCAR=48.8
670  
671 0 ▶ while ($self->_alive && defined(my $line = <$in>)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_alive and defined(my $line = readline $in)) 0 0 0
Condition0%0/3
$self->_alive and defined(my $line = readline $in)
!ll&&!rl&&r
000
MC/DC0%0/2
$self->_alive and defined(my $line = readline $in)
$self->_alive defined(my $line = readline $in)
Truth table0%0/3
A and B
A= $self->_aliveB= defined(my $line = readline $in)
ABresult
0X0
100
111
672 0 my @parts;
673 my %opts;
674 0 my $autodie;
675  
676 0 $line =~ s/\r?\n$//;
677 0 $line =~ s/^\s+//;
678 0 $line =~ s/\s+$//;
679 0 $line =~ s/^(?:;|\/\/|#).*$//;
680 0 $line =~ s/\s+/ /g;
681  
682 0 ▶ next if $line eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $line eq "" 0 0 0
683  
684 0 ▶ while (length($line)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $line) 0 0 0
685 0 ▶ if ($line =~ s/^("[^"]*")//) {
Branch: 3 branches
BranchTrueFalseTotal
if ($line =~ s/^("[^"]*")//u) { } 0 0 0
elsif ($line =~ m[^(?:;|//|#)]u) { } 0 0 0
elsif ($line =~ s/^([^\s,=]+)//u) { } 0 0 0
686 0 push(@parts, $1);
687 } elsif ($line =~ /^(?:;|\/\/|#)/) {
688 # this is a comment, so just leave the rest alone
689 0 last;
690 } elsif ($line =~ s/^([^\s,=]+)//) {
691 0 push(@parts, $1);
692 } else {
693 0 croak 'Bad line: '.$in->input_line_number;
694 }
695  
696 0 $line =~ s/^\s*[,=]\s*//;
697 0 $line =~ s/^\s+//;
698 }
699  
700 0 ▶ next unless scalar @parts;
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @parts 0 0 0
701  
702 0 $autodie = undef;
703 0 ▶ if ($parts[0] =~ s/([\?\!])$//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parts[0] =~ s/([\?\!])$//u) 0 0 0
704 0 ▶ if ($1 eq '!') {
Branch: 1 branch
BranchTrueFalseTotal
if ($1 eq "!") 0 0 0
705 0 $autodie = 1;
706 }
707 }
708  
709 0 %opts = (line => $in->input_line_number);
710  
711 0 $self->{regmap_mapped} = {};
712 0 $self->_proc_parts(\@parts, \%opts, \$autodie);
713 }
714 }
715  
716 sub _proc_parts {
717 0 ▶ my ($self, $parts, $opts, $autodie, $allow_alts) = @_;
Subroutine _proc_parts: not called CC=247 SCAR=110.2
718 0 my $out = $self->{out};
719 0 my ($cmd, @args) = @{$parts};
720 0 my $was_return;
721 my $opcode;
722  
723 0 ▶ $autodie //= do { \my $x };
Condition0%0/3
$autodie //= do { \my $x }
l!l&&r!l&&!r
000
MC/DC0%0/2
$autodie //= do { \my $x }
$autodie do { \my $x }
Truth table0%0/3
A //= B
A= $autodieB= do { \my $x }
ABresult
1X1
011
000
724  
725 0 ▶ if ($cmd ne '.pushname' && $cmd ne '.popname') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd ne ".pushname" and $cmd ne ".popname") 0 0 0
Condition0%0/3
$cmd ne ".pushname" and $cmd ne ".popname"
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd ne ".pushname" and $cmd ne ".popname"
$cmd ne ".pushname" $cmd ne ".popname"
Truth table0%0/3
A and B
A= $cmd ne ".pushname"B= $cmd ne ".popname"
ABresult
0X0
100
111
726 0 foreach my $part (@{$parts}) {
727 0 my @alts;
728  
729 0 ▶ next unless $part =~ /^[a-z0-9]*\$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $part =~ /^[a-z0-9]*\$/u 0 0 0
730  
731 0 @alts = split(m#//#, $part);
732  
733 0 ▶ if ($allow_alts) {
Branch: 1 branch
BranchTrueFalseTotal
if ($allow_alts) { } 0 0 0
734 0 foreach my $alt (@alts) {
735 0 ▶ if (defined $self->{aliases}{$alt}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"aliases"}{$alt}) 0 0 0
736 0 $part = $self->{aliases}{$alt}[-1];
737 0 last;
738 }
739 }
740 } else {
741 0 ▶ $part = $self->{aliases}{$alts[0]}[-1] if defined $self->{aliases}{$alts[0]};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"aliases"}{$alts[0]} 0 0 0
742 }
743 }
744 0 ($cmd, @args) = @{$parts};
745 }
746  
747 0 foreach my $arg (@args) {
748 0 ▶ if ($arg eq '~auto') {
Branch: 1 branch
BranchTrueFalseTotal
if ($arg eq "~auto") 0 0 0
749 0 $arg = $self->_auto_host_defined;
750 }
751 }
752  
753 0 ▶ if ($cmd eq '.quit' && scalar(@args) == 0) {
Branch: 41 branches
BranchTrueFalseTotal
if ($cmd eq '.quit' and scalar @args == 0) { } 0 0 0
elsif ($cmd eq '.profile' and scalar @args > 0) { } 0 0 0
elsif ($cmd eq '.pushname' and not scalar @args & 1) { } 0 0 0
elsif ($cmd eq '.popname') { } 0 0 0
elsif ($cmd eq '.tag' and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and defined $_type_to_sni{$args[1]}) { } 0 0 0
elsif ($cmd eq '.tag' and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) =~ /:$/u) { } 0 0 0
elsif ($cmd eq '.tag' and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) eq 'int') { } 0 0 0
elsif ($cmd eq '.tag' and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $args[1] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[2]) eq 'int') { } 0 0 0
elsif ($cmd eq '.utf8') { } 0 0 0
elsif ($cmd eq '.byte') { } 0 0 0
elsif ($cmd eq '.uint16') { } 0 0 0
elsif ($cmd eq '.uint16_half_up') { } 0 0 0
elsif ($cmd eq '.string' and scalar @args >= 2) { } 0 0 0
elsif ($cmd eq 'open' and scalar @args == 2 and $self->_get_value_type($args[0]) eq 'reg' and $self->_get_value_type($args[1]) eq 'string') { } 0 0 0
elsif ($cmd eq 'open' and scalar @args == 2 and $self->_get_value_type($args[0]) eq 'reg' and $self->_get_value_type($args[1]) eq 'port') { } 0 0 0
elsif ($cmd eq 'byte_transfer' and scalar @args == 2 and $self->_get_value_type($args[0]) eq 'reg' and $self->_get_value_type($args[1]) eq 'string') { } 0 0 0
elsif ($cmd eq '.rodata' and scalar @args == 0) { } 0 0 0
elsif ($cmd eq '.include') { } 0 0 0
elsif ($cmd eq '.cat') { } 0 0 0
elsif ($cmd eq '.noops' and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.org' and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.align' and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.host_defined_auto_range' and scalar @args == 2 and $self->_get_value_type($args[0]) eq 'int' and $self->_get_value_type($args[1]) eq 'int') { } 0 0 0
elsif ($cmd eq '.label' and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/u) { } 0 0 0
elsif ($cmd eq '.endlabel' and scalar @args == 0 and defined $self->{'current'}{'label'}) { } 0 0 0
elsif ($cmd eq '.function' and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/u) { } 0 0 0
elsif ($cmd eq '.endfunction' and scalar @args == 0 and defined $self->{'current'}{'function'}) { } 0 0 0
elsif ($cmd eq '.section' and scalar @args == 1 || scalar @args == 2 and not defined $self->{'current'}{'section'}) { } 0 0 0
elsif ($cmd eq '.endsection' and scalar @args == 0 and defined(my $section = $self->{'current'}{'section'})) { } 0 0 0
elsif ($cmd eq '.chunk' and scalar @args >= 2) { } 0 0 0
elsif ($cmd eq '.endchunk' and scalar @args == 0 and defined $self->{'current'}{'chunk'}) { } 0 0 0
elsif ($cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/u and scalar @args == 1) { } 0 0 0
elsif ($cmd eq '.map' and scalar @args == 2) { } 0 0 0
elsif ($cmd eq '.force_mapped') { } 0 0 0
elsif ($cmd eq '.mine' or $cmd eq '.yours' or $cmd eq '.theirs') { } 0 0 0
elsif ($cmd eq '.hot' or $cmd eq '.cold' or $cmd eq '.lukewarm') { } 0 0 0
elsif ($cmd eq '.regattr' and scalar @args >= 1) { } 0 0 0
elsif ($cmd eq 'map' and scalar @args == 2) { } 0 0 0
elsif (defined($opcode = eval { do { 'SIRTX::VM::Opcode'->from_template('parts', $parts, 'assembler', $self, 'size', $opts->{'size'}, 'line', $opts->{'line'}, 'out', $out, 'autodie', $autodie) } })) { } 0 0 0
elsif (defined($opcode = eval { do { 'SIRTX::VM::Opcode'->from_template('parts', [$parts->[0], map({scalar eval { do { $self->_get_value_type($_) eq 'alias' } } ? 65520 : $_;} @$parts[1 .. scalar(@{$parts;}) - 1])], 'assembler', $self, 'size', $opts->{'size'}, 'line', $opts->{'line'}, 'out', $out, 'autodie', $autodie) } })) { } 0 0 0
elsif (defined $_info{$cmd} and scalar @args > 1 and $args[0] =~ /^~0?$/u) { } 0 0 0
Condition0%0/3
$cmd eq ".quit" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".quit" and scalar @args == 0
$cmd eq ".quit" scalar @args == 0
Truth table0%0/3
A and B
A= $cmd eq ".quit"B= scalar @args == 0
ABresult
0X0
100
111
754 0 $self->_quit;
755 ▶ } elsif ($cmd eq '.profile' && scalar(@args) > 0) {
Condition0%0/3
$cmd eq ".profile" and scalar @args > 0
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".profile" and scalar @args > 0
$cmd eq ".profile" scalar @args > 0
Truth table0%0/3
A and B
A= $cmd eq ".profile"B= scalar @args > 0
ABresult
0X0
100
111
756 0 $self->_join_profile(@args);
757 ▶ } elsif ($cmd eq '.pushname' && !(scalar(@args) & 1)) {
Condition0%0/3
$cmd eq ".pushname" and not scalar @args & 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".pushname" and not scalar @args & 1
$cmd eq ".pushname" not scalar @args & 1
Truth table0%0/3
A and not(B)
A= $cmd eq ".pushname"B= not scalar @args & 1
ABresult
0X0
100
111
758 0 ▶ for (my $i = 0; $i < scalar(@args); $i += 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @args) 0 0 0
759 0 my $key = $args[$i + 0];
760 0 my $value = $args[$i + 1];
761  
762 0 $key =~ s/^\$?/\$/; # ensure it starts with a '$'.
763 0 ▶ if ($key !~ /^\$[0-9a-zA-Z_]+/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($key =~ /^\$[0-9a-zA-Z_]+/u) 0 0 0
764 0 croak sprintf('Bad key name: line %s: key %s', $opts->{line}, $key);
765 }
766 0 ▶ push(@{$self->{aliases}{$key} //= []}, $value);
Condition0%0/2
$self->{"aliases"}{$key} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{$key} //= []
$self->{"aliases"}{$key}
Truth table0%0/2
A
A= $self->{"aliases"}{$key}
Aresult
11
00
767 }
768 } elsif ($cmd eq '.popname') {
769 0 foreach my $key (@args) {
770 0 $key =~ s/^\$?/\$/; # ensure it starts with a '$'.
771 0 ▶ unless (defined $self->{aliases}{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"aliases"}{$key}) 0 0 0
772 0 croak sprintf('Bad/unknown key name: line %s: key %s', $opts->{line}, $key);
773 }
774  
775 0 pop(@{$self->{aliases}{$key}});
776 0 ▶ delete $self->{aliases}{$key} unless scalar @{$self->{aliases}{$key}};
Branch: 1 branch
BranchTrueFalseTotal
unless scalar @{$self->{"aliases"}{$key};} 0 0 0
777 }
778 ▶ } elsif ($cmd eq '.tag' && scalar(@args) == 2 && $args[0] =~ /^[0-9a-zA-Z_]+$/ && defined($_type_to_sni{$args[1]})) {
Condition0%0/9
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and defined $_type_to_sni{$args[1]}
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and defined $_type_to_sni{$args[1]}
$cmd eq ".tag" scalar @args == 2 $args[0] =~ /^[0-9a-zA-Z_]+$/u defined $_type_to_sni{$args[1]}
Truth table0%0/5
A and B and C and D
A= $cmd eq ".tag"B= scalar @args == 2C= $args[0] =~ /^[0-9a-zA-Z_]+$/uD= defined $_type_to_sni{$args[1]}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
779 0 ▶ push(@{$self->{aliases}{'tag$'.$args[0]} //= []}, 'sni:'.$_type_to_sni{$args[1]});
Condition0%0/2
$self->{"aliases"}{'tag$' . $args[0]} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'tag$' . $args[0]} //= []
$self->{"aliases"}{'tag$' . $args[0]}
Truth table0%0/2
A
A= $self->{"aliases"}{'tag$' . $args[0]}
Aresult
11
00
780 ▶ } elsif ($cmd eq '.tag' && scalar(@args) == 2 && $args[0] =~ /^[0-9a-zA-Z_]+$/ && $self->_get_value_type($args[1]) =~ /:$/) {
Condition0%0/9
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) =~ /:$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) =~ /:$/u
$cmd eq ".tag" scalar @args == 2 $args[0] =~ /^[0-9a-zA-Z_]+$/u $self->_get_value_type($args[1]) =~ /:$/u
Truth table0%0/5
A and B and C and D
A= $cmd eq ".tag"B= scalar @args == 2C= $args[0] =~ /^[0-9a-zA-Z_]+$/uD= $self->_get_value_type($args[1]) =~ /:$/u
ABCDresult
0XXX0
10XX0
110X0
11100
11111
781 0 ▶ push(@{$self->{aliases}{'tag$'.$args[0]} //= []}, $args[1]);
Condition0%0/2
$self->{"aliases"}{'tag$' . $args[0]} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'tag$' . $args[0]} //= []
$self->{"aliases"}{'tag$' . $args[0]}
Truth table0%0/2
A
A= $self->{"aliases"}{'tag$' . $args[0]}
Aresult
11
00
782 ▶ } elsif ($cmd eq '.tag' && scalar(@args) == 2 && $args[0] =~ /^[0-9a-zA-Z_]+$/ && $self->_get_value_type($args[1]) eq 'int') {
Condition0%0/9
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) eq "int"
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq ".tag" and scalar @args == 2 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[1]) eq "int"
$cmd eq ".tag" scalar @args == 2 $args[0] =~ /^[0-9a-zA-Z_]+$/u $self->_get_value_type($args[1]) eq "int"
Truth table0%0/5
A and B and C and D
A= $cmd eq ".tag"B= scalar @args == 2C= $args[0] =~ /^[0-9a-zA-Z_]+$/uD= $self->_get_value_type($args[1]) eq "int"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
783 0 ▶ push(@{$self->{aliases}{'tag$'.$args[0]} //= []}, 'sni:'.$self->_parse_int($args[1]));
Condition0%0/2
$self->{"aliases"}{'tag$' . $args[0]} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'tag$' . $args[0]} //= []
$self->{"aliases"}{'tag$' . $args[0]}
Truth table0%0/2
A
A= $self->{"aliases"}{'tag$' . $args[0]}
Aresult
11
00
784 ▶ } elsif ($cmd eq '.tag' && scalar(@args) == 3 && $args[0] =~ /^[0-9a-zA-Z_]+$/ && $args[1] =~ /^[0-9a-zA-Z_]+$/ && $self->_get_value_type($args[2]) eq 'int') {
Condition0%0/12
$cmd eq ".tag" and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $args[1] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[2]) eq "int"
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $args[1] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".tag" and scalar @args == 3
!ll&&!rl&&r
000
MC/DC0%0/5
$cmd eq ".tag" and scalar @args == 3 and $args[0] =~ /^[0-9a-zA-Z_]+$/u and $args[1] =~ /^[0-9a-zA-Z_]+$/u and $self->_get_value_type($args[2]) eq "int"
$cmd eq ".tag" scalar @args == 3 $args[0] =~ /^[0-9a-zA-Z_]+$/u $args[1] =~ /^[0-9a-zA-Z_]+$/u $self->_get_value_type($args[2]) eq "int"
Truth table0%0/6
A and B and C and D and E
A= $cmd eq ".tag"B= scalar @args == 3C= $args[0] =~ /^[0-9a-zA-Z_]+$/uD= $args[1] =~ /^[0-9a-zA-Z_]+$/uE= $self->_get_value_type($args[2]) eq "int"
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
785 0 ▶ push(@{$self->{aliases}{'tag$'.$args[0]} //= []}, $args[1].':'.$self->_parse_int($args[2]));
Condition0%0/2
$self->{"aliases"}{'tag$' . $args[0]} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'tag$' . $args[0]} //= []
$self->{"aliases"}{'tag$' . $args[0]}
Truth table0%0/2
A
A= $self->{"aliases"}{'tag$' . $args[0]}
Aresult
11
00
786 } elsif ($cmd eq '.utf8') {
787 0 foreach my $str (@args) {
788 0 print $out $self->_parse_string($str);
789 }
790 0 $self->_set_alignment(1);
791 } elsif ($cmd eq '.byte') {
792 0 my $last;
793 0 foreach my $str (@args) {
794 0 my $c = $self->_parse_int($str, $last);
795 0 print $out pack('C', $c);
796 0 $last = $c;
797 }
798 0 $self->_set_alignment(1);
799 } elsif ($cmd eq '.uint16') { # INTERNAL COMMAND! NOT FOR DOCS!
800 0 my $last;
801 0 foreach my $str (@args) {
802 0 my $c = $self->_parse_int($str, $last);
803 0 print $out pack('n', $c);
804 0 $last = $c;
805 }
806 0 $self->_set_alignment(1);
807 } elsif ($cmd eq '.uint16_half_up') { # INTERNAL COMMAND! NOT FOR DOCS!
808 0 my $last;
809 0 foreach my $str (@args) {
810 0 my $c = $self->_parse_int($str, $last);
811 0 print $out pack('n', ($c / 2) + ($c & 1));
812 0 $last = $c;
813 }
814 0 $self->_set_alignment(1);
815 ▶ } elsif ($cmd eq '.string' && scalar(@args) >= 2) {
Condition0%0/3
$cmd eq ".string" and scalar @args >= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".string" and scalar @args >= 2
$cmd eq ".string" scalar @args >= 2
Truth table0%0/3
A and B
A= $cmd eq ".string"B= scalar @args >= 2
ABresult
0X0
100
111
816 0 my $key = 'string$'.$args[0];
817 0 my $catted = '';
818 0 foreach my $str (@args[1..$#args]) {
819 0 $catted .= $self->_parse_string($str);
820 }
821 0 $self->{alias_rodata_idx}{$key} = $self->{rodata}->add_blob($catted);
822 0 ▶ push(@{$self->{aliases}{'size$'.$key} //= []}, length($catted));
Condition0%0/2
$self->{"aliases"}{'size$' . $key} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'size$' . $key} //= []
$self->{"aliases"}{'size$' . $key}
Truth table0%0/2
A
A= $self->{"aliases"}{'size$' . $key}
Aresult
11
00
823 ▶ } elsif ($cmd eq 'open' && scalar(@args) == 2 && $self->_get_value_type($args[0]) eq 'reg' && $self->_get_value_type($args[1]) eq 'string') {
Condition0%0/9
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "string"
!ll&&!rl&&r
000
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg"
!ll&&!rl&&r
000
$cmd eq "open" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "string"
$cmd eq "open" scalar @args == 2 $self->_get_value_type($args[0]) eq "reg" $self->_get_value_type($args[1]) eq "string"
Truth table0%0/5
A and B and C and D
A= $cmd eq "open"B= scalar @args == 2C= $self->_get_value_type($args[0]) eq "reg"D= $self->_get_value_type($args[1]) eq "string"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
824 0 my $key = $self->_autostring_allocate($self->_parse_string($args[1]));
825 0 $self->_proc_parts(['substr', $args[0], 'program_text', $key, 'end$'.$key], $opts);
826 ▶ } elsif ($cmd eq 'open' && scalar(@args) == 2 && $self->_get_value_type($args[0]) eq 'reg' && $self->_get_value_type($args[1]) eq 'port') {
Condition0%0/9
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "port"
!ll&&!rl&&r
000
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg"
!ll&&!rl&&r
000
$cmd eq "open" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq "open" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "port"
$cmd eq "open" scalar @args == 2 $self->_get_value_type($args[0]) eq "reg" $self->_get_value_type($args[1]) eq "port"
Truth table0%0/5
A and B and C and D
A= $cmd eq "open"B= scalar @args == 2C= $self->_get_value_type($args[0]) eq "reg"D= $self->_get_value_type($args[1]) eq "port"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
827 0 my $reg = $self->_reg_alloc_phy('user*');
828  
829 0 ▶ $self->_reg_alloc_phy('out') if $args[0] ne 'out';
Branch: 1 branch
BranchTrueFalseTotal
if $args[0] ne "out" 0 0 0
830  
831 0 $self->_proc_parts(['open', $reg, $args[1] =~ s/^%//r], $opts);
832 0 $self->_proc_parts(['getvalue', 'out', 'context', $reg], $opts);
833  
834 0 ▶ if ($args[0] ne 'out') {
Branch: 1 branch
BranchTrueFalseTotal
if ($args[0] ne "out") 0 0 0
835 0 $self->_proc_parts(['replace', $args[0], 'out'], $opts);
836 }
837  
838 0 ▶ $self->_proc_parts(['unref', $reg], $opts) if $self->{settings}{synthetic_auto_unref};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"settings"}{"synthetic_auto_unref"} 0 0 0
839 ▶ } elsif ($cmd eq 'byte_transfer' && scalar(@args) == 2 && $self->_get_value_type($args[0]) eq 'reg' && $self->_get_value_type($args[1]) eq 'string') {
Condition0%0/9
$cmd eq "byte_transfer" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "string"
!ll&&!rl&&r
000
$cmd eq "byte_transfer" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg"
!ll&&!rl&&r
000
$cmd eq "byte_transfer" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq "byte_transfer" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "reg" and $self->_get_value_type($args[1]) eq "string"
$cmd eq "byte_transfer" scalar @args == 2 $self->_get_value_type($args[0]) eq "reg" $self->_get_value_type($args[1]) eq "string"
Truth table0%0/5
A and B and C and D
A= $cmd eq "byte_transfer"B= scalar @args == 2C= $self->_get_value_type($args[0]) eq "reg"D= $self->_get_value_type($args[1]) eq "string"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
840 0 my $key = $self->_autostring_allocate($self->_parse_string($args[1]));
841 0 my $reg = $self->_reg_alloc_phy('user*');
842  
843 0 $self->_proc_parts(['substr', $reg, 'program_text', $key, 'end$'.$key], $opts);
844 0 $self->_proc_parts(['byte_transfer', $args[0], $reg, 'size$'.$key], $opts);
845 0 ▶ $self->_proc_parts(['unref', $reg], $opts) if $self->{settings}{synthetic_auto_unref};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"settings"}{"synthetic_auto_unref"} 0 0 0
846 ▶ } elsif ($cmd eq '.rodata' && scalar(@args) == 0) { # INTERNAL COMMAND! NOT FOR DOCS!
Condition0%0/3
$cmd eq ".rodata" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".rodata" and scalar @args == 0
$cmd eq ".rodata" scalar @args == 0
Truth table0%0/3
A and B
A= $cmd eq ".rodata"B= scalar @args == 0
ABresult
0X0
100
111
847 0 my $aliases = $self->{aliases};
848 0 my $rodata = $self->{rodata};
849 0 my $base = $out->tell;
850 0 print $out $rodata->result;
851 0 $self->_set_alignment(1);
852 0 foreach my $key (keys %{$self->{alias_rodata_idx}}) {
853 0 my $idx = $self->{alias_rodata_idx}{$key};
854 0 my $offset = $rodata->offset(index => $idx) + $base;
855 0 my $size = $aliases->{'size$'.$key}[-1];
856 0 ▶ push(@{$aliases->{$key} //= []}, $offset);
Condition0%0/2
$aliases->{$key} //= []
l!l
00
MC/DC0%0/1
$aliases->{$key} //= []
$aliases->{$key}
Truth table0%0/2
A
A= $aliases->{$key}
Aresult
11
00
857 0 ▶ push(@{$aliases->{'end$'.$key} //= []}, $offset + $size) if defined $size;
Branch: 1 branch
BranchTrueFalseTotal
if defined $size 0 0 0
Condition0%0/2
$$aliases{'end$' . $key} //= []
l!l
00
MC/DC0%0/1
$$aliases{'end$' . $key} //= []
$$aliases{'end$' . $key}
Truth table0%0/2
A
A= $$aliases{'end$' . $key}
Aresult
11
00
858 }
859 } elsif ($cmd eq '.include') {
860 0 foreach my $arg (@args) {
861 0 my $fh = $self->_open_file($self->_parse_string($arg));
862 0 $fh->binmode;
863 0 $fh->binmode(':utf8');
864  
865 0 $self->_proc_input($fh);
866 }
867 } elsif ($cmd eq '.cat') {
868 0 local $/ = \4096;
869 0 foreach my $arg (@args) {
870 0 my $fh = $self->_open_file($self->_parse_string($arg));
871 0 $fh->binmode;
872  
873 0 ▶ print $out $_ while <$fh>;
Branch: 1 branch
BranchTrueFalseTotal
defined($_ = readline $fh) and do { print $out $_ } 0 0 0
874 }
875 0 $self->_set_alignment(1);
876 ▶ } elsif ($cmd eq '.noops' && scalar(@args) == 1) {
Condition0%0/3
$cmd eq ".noops" and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".noops" and scalar @args == 1
$cmd eq ".noops" scalar @args == 1
Truth table0%0/3
A and B
A= $cmd eq ".noops"B= scalar @args == 1
ABresult
0X0
100
111
877 0 my $num = $self->_parse_int($args[0]);
878 0 my $opcode = SIRTX::VM::Opcode->from_template(parts => [qw(noop)], assembler => $self);
879  
880 0 $self->_align($opcode->required_alignment, 1);
881 0 ▶ for (my $i = 0; $i < $num; $i++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $num) 0 0 0
882 0 $opcode->write($out);
883 }
884 0 $self->_set_alignment($opcode->new_alignment);
885 ▶ } elsif ($cmd eq '.org' && scalar(@args) == 1) {
Condition0%0/3
$cmd eq ".org" and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".org" and scalar @args == 1
$cmd eq ".org" scalar @args == 1
Truth table0%0/3
A and B
A= $cmd eq ".org"B= scalar @args == 1
ABresult
0X0
100
111
886 0 my $p = $self->_parse_int($args[0], $out->tell);
887 0 ▶ carp 'New address in .org is not a multiple of the word size: line '.$opts->{line} if $p & 1;
Branch: 1 branch
BranchTrueFalseTotal
if $p & 1 0 0 0
888 0 $out->seek($p, SEEK_SET);
889 0 $self->_set_alignment(1);
890 ▶ } elsif ($cmd eq '.align' && scalar(@args) == 1) {
Condition0%0/3
$cmd eq ".align" and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".align" and scalar @args == 1
$cmd eq ".align" scalar @args == 1
Truth table0%0/3
A and B
A= $cmd eq ".align"B= scalar @args == 1
ABresult
0X0
100
111
891 0 my $p = $self->_parse_int($args[0]);
892 0 $self->_align($p);
893 ▶ } elsif ($cmd eq '.host_defined_auto_range' && scalar(@args) == 2 && $self->_get_value_type($args[0]) eq 'int' && $self->_get_value_type($args[1]) eq 'int') {
Condition0%0/9
$cmd eq ".host_defined_auto_range" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "int" and $self->_get_value_type($args[1]) eq "int"
!ll&&!rl&&r
000
$cmd eq ".host_defined_auto_range" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "int"
!ll&&!rl&&r
000
$cmd eq ".host_defined_auto_range" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/4
$cmd eq ".host_defined_auto_range" and scalar @args == 2 and $self->_get_value_type($args[0]) eq "int" and $self->_get_value_type($args[1]) eq "int"
$cmd eq ".host_defined_auto_range" scalar @args == 2 $self->_get_value_type($args[0]) eq "int" $self->_get_value_type($args[1]) eq "int"
Truth table0%0/5
A and B and C and D
A= $cmd eq ".host_defined_auto_range"B= scalar @args == 2C= $self->_get_value_type($args[0]) eq "int"D= $self->_get_value_type($args[1]) eq "int"
ABCDresult
0XXX0
10XX0
110X0
11100
11111
894 0 my $start = $self->_parse_int($args[0]);
895 0 my $end = $self->_parse_int($args[1], $start);
896 0 ▶ croak 'Invalid range for host defined identifiers: '.$start.' to '.$end if $end < $start || $start < 1;
Branch: 1 branch
BranchTrueFalseTotal
if $end < $start or $start < 1 0 0 0
Condition0%0/3
$end < $start or $start < 1
l!l&&r!l&&!r
000
MC/DC0%0/2
$end < $start or $start < 1
$end < $start $start < 1
Truth table0%0/3
A or B
A= $end < $startB= $start < 1
ABresult
1X1
011
000
897 0 ▶ croak 'Host defined range already set, trying to set it again in line '.$opts->{line} if defined $self->{auto_host_defined};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"auto_host_defined"} 0 0 0
898 0 $self->{auto_host_defined} = [$start, $end, $start];
899 ▶ } elsif ($cmd eq '.label' && (scalar(@args) == 1 || scalar(@args) == 3) && $args[0] =~ /^[a-z0-9A-Z_]+$/ && (scalar(@args) == 1 || ($args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/))) {
Condition0%0/18
$cmd eq ".label" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq "as" && $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
$cmd eq ".label" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".label" and scalar @args == 1 || scalar @args == 3
!ll&&!rl&&r
000
scalar @args == 1 or scalar @args == 3
l!l&&r!l&&!r
000
scalar @args == 1 or $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
l!l&&r!l&&!r
000
$args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
MC/DC0%0/7
$cmd eq ".label" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq "as" && $args[2] =~ /^~[0-9]+$/u
$cmd eq ".label" scalar @args == 1 scalar @args == 3 $args[0] =~ /^[a-z0-9A-Z_]+$/u scalar @args == 1 $args[1] eq "as" $args[2] =~ /^~[0-9]+$/u
Truth table0%0/12
A and B or C and D and E or F and G
A= $cmd eq ".label"B= scalar @args == 1C= scalar @args == 3D= $args[0] =~ /^[a-z0-9A-Z_]+$/uE= scalar @args == 1F= $args[1] eq "as"G= $args[2] =~ /^~[0-9]+$/u
ABCDEFGresult
0XXXXXX0
100XXXX0
11X0XXX0
1010XXX0
11X100X0
11X10100
101100X0
10110100
11X11XX1
11X10111
10111XX1
10110111
900 0 $self->{current}{label} = 'label$'.$args[0];
901 0 $self->_save_position($self->{current}{label});
902 0 ▶ if (scalar(@args) == 3 && $args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u) 0 0 0
Condition0%0/6
scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
scalar @args == 3 and $args[1] eq "as"
!ll&&!rl&&r
000
MC/DC0%0/3
scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
scalar @args == 3 $args[1] eq "as" $args[2] =~ /^~[0-9]+$/u
Truth table0%0/4
A and B and C
A= scalar @args == 3B= $args[1] eq "as"C= $args[2] =~ /^~[0-9]+$/u
ABCresult
0XX0
10X0
1100
1111
903 0 ▶ push(@{$self->{aliases}{'hostdefined$label$'.$self->{current}{label}} //= []}, $args[2]);
Condition0%0/2
$self->{"aliases"}{'hostdefined$label$' . $self->{"current"}{"label"}} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'hostdefined$label$' . $self->{"current"}{"label"}} //= []
$self->{"aliases"}{'hostdefined$label$' . $self->{"current"}{"label"}}
Truth table0%0/2
A
A= $self->{"aliases"}{'hostdefined$label$' . $self->{"current"}{"label"}}
Aresult
11
00
904 }
905 ▶ } elsif ($cmd eq '.endlabel' && scalar(@args) == 0 && defined($self->{current}{label})) {
Condition0%0/6
$cmd eq ".endlabel" and scalar @args == 0 and defined $self->{"current"}{"label"}
!ll&&!rl&&r
000
$cmd eq ".endlabel" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/3
$cmd eq ".endlabel" and scalar @args == 0 and defined $self->{"current"}{"label"}
$cmd eq ".endlabel" scalar @args == 0 defined $self->{"current"}{"label"}
Truth table0%0/4
A and B and C
A= $cmd eq ".endlabel"B= scalar @args == 0C= defined $self->{"current"}{"label"}
ABCresult
0XX0
10X0
1100
1111
906 0 $self->_save_endposition($self->{current}{label});
907 0 $self->{current}{label} = undef;
908 ▶ } elsif ($cmd eq '.function' && (scalar(@args) == 1 || scalar(@args) == 3) && $args[0] =~ /^[a-z0-9A-Z_]+$/ && (scalar(@args) == 1 || ($args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/))) {
Condition0%0/18
$cmd eq ".function" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq "as" && $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
$cmd eq ".function" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u
!ll&&!rl&&r
000
$cmd eq ".function" and scalar @args == 1 || scalar @args == 3
!ll&&!rl&&r
000
scalar @args == 1 or scalar @args == 3
l!l&&r!l&&!r
000
scalar @args == 1 or $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
l!l&&r!l&&!r
000
$args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
MC/DC0%0/7
$cmd eq ".function" and scalar @args == 1 || scalar @args == 3 and $args[0] =~ /^[a-z0-9A-Z_]+$/u and scalar @args == 1 || $args[1] eq "as" && $args[2] =~ /^~[0-9]+$/u
$cmd eq ".function" scalar @args == 1 scalar @args == 3 $args[0] =~ /^[a-z0-9A-Z_]+$/u scalar @args == 1 $args[1] eq "as" $args[2] =~ /^~[0-9]+$/u
Truth table0%0/12
A and B or C and D and E or F and G
A= $cmd eq ".function"B= scalar @args == 1C= scalar @args == 3D= $args[0] =~ /^[a-z0-9A-Z_]+$/uE= scalar @args == 1F= $args[1] eq "as"G= $args[2] =~ /^~[0-9]+$/u
ABCDEFGresult
0XXXXXX0
100XXXX0
11X0XXX0
1010XXX0
11X100X0
11X10100
101100X0
10110100
11X11XX1
11X10111
10111XX1
10110111
909 0 $self->_align(2, 1);
910 0 $self->{current}{function} = $args[0];
911 0 $self->_save_position('function$'.$self->{current}{function});
912 0 $self->{rf}->map_reset;
913 0 ▶ if (scalar(@args) == 3 && $args[1] eq 'as' && $args[2] =~ /^~[0-9]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u) 0 0 0
Condition0%0/6
scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
!ll&&!rl&&r
000
scalar @args == 3 and $args[1] eq "as"
!ll&&!rl&&r
000
MC/DC0%0/3
scalar @args == 3 and $args[1] eq "as" and $args[2] =~ /^~[0-9]+$/u
scalar @args == 3 $args[1] eq "as" $args[2] =~ /^~[0-9]+$/u
Truth table0%0/4
A and B and C
A= scalar @args == 3B= $args[1] eq "as"C= $args[2] =~ /^~[0-9]+$/u
ABCresult
0XX0
10X0
1100
1111
914 0 ▶ push(@{$self->{aliases}{'hostdefined$function$'.$self->{current}{function}} //= []}, $args[2]);
Condition0%0/2
$self->{"aliases"}{'hostdefined$function$' . $self->{"current"}{"function"}} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'hostdefined$function$' . $self->{"current"}{"function"}} //= []
$self->{"aliases"}{'hostdefined$function$' . $self->{"current"}{"function"}}
Truth table0%0/2
A
A= $self->{"aliases"}{'hostdefined$function$' . $self->{"current"}{"function"}}
Aresult
11
00
915 }
916 ▶ } elsif ($cmd eq '.endfunction' && scalar(@args) == 0 && defined($self->{current}{function})) {
Condition0%0/6
$cmd eq ".endfunction" and scalar @args == 0 and defined $self->{"current"}{"function"}
!ll&&!rl&&r
000
$cmd eq ".endfunction" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/3
$cmd eq ".endfunction" and scalar @args == 0 and defined $self->{"current"}{"function"}
$cmd eq ".endfunction" scalar @args == 0 defined $self->{"current"}{"function"}
Truth table0%0/4
A and B and C
A= $cmd eq ".endfunction"B= scalar @args == 0C= defined $self->{"current"}{"function"}
ABCresult
0XX0
10X0
1100
1111
917 0 ▶ unless ($self->{was_return}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"was_return"}) 0 0 0
918 0 $self->_save_position('return$function$'.$self->{current}{function});
919 0 $self->_write_opcode(SIRTX::VM::Opcode->from_template(parts => ['return'], assembler => $self));
920 }
921 0 $self->_save_endposition('function$'.$self->{current}{function});
922 0 $self->{current}{function} = undef;
923 ▶ } elsif ($cmd eq '.section' && (scalar(@args) == 1 || scalar(@args) == 2) && !defined($self->{current}{section})) {
Condition0%0/9
$cmd eq ".section" and scalar @args == 1 || scalar @args == 2 and not defined $self->{"current"}{"section"}
!ll&&!rl&&r
000
$cmd eq ".section" and scalar @args == 1 || scalar @args == 2
!ll&&!rl&&r
000
scalar @args == 1 or scalar @args == 2
l!l&&r!l&&!r
000
MC/DC0%0/4
$cmd eq ".section" and scalar @args == 1 || scalar @args == 2 and not defined $self->{"current"}{"section"}
$cmd eq ".section" scalar @args == 1 scalar @args == 2 not defined $self->{"current"}{"section"}
Truth table0%0/6
A and B or C and not(D)
A= $cmd eq ".section"B= scalar @args == 1C= scalar @args == 2D= not defined $self->{"current"}{"section"}
ABCDresult
0XXX0
100X0
11X00
10100
11X11
10111
924 0 my $S = $_header_ids{$args[0]};
925 0 my $T = 4;
926 0 my $extra;
927 my %tpl;
928  
929 0 ▶ unless (defined $S) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $S) 0 0 0
930 0 croak sprintf('Invalid section: line %s: section %s', $opts->{line}, $args[0]);
931 }
932  
933 0 foreach my $profile (@{$self->{profiles}}) {
934 0 ▶ if (defined(my $disabled = $_disabled_sections{$profile})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $disabled = $_disabled_sections{$profile})) 0 0 0
935 0 ▶ if ($disabled->{$args[0]}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$disabled{$args[0]}) 0 0 0
936 0 croak sprintf('Invalid section for profile: line %s: section %s not allowed in profile %s', $opts->{line}, $args[0], $profile);
937 }
938 }
939 }
940  
941 0 ▶ if (defined(my $bad = $_section_order_bad{$args[0]})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $bad = $_section_order_bad{$args[0]})) 0 0 0
942 0 foreach my $key (@_section_order) {
943 0 ▶ next unless defined $self->{sections}{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"sections"}{$key} 0 0 0
944 0 ▶ croak sprintf('Invalid section: line %s: section %s must not follow section %s', $opts->{line}, $args[0], $key) if defined $bad->{$key};
Branch: 1 branch
BranchTrueFalseTotal
if defined $bad->{$key} 0 0 0
945 }
946 }
947  
948 0 ▶ if (scalar(@args) == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @args == 2) 0 0 0
949 0 $extra = $self->_parse_string($args[1]);
950 0 my $l = length($extra);
951 0 ▶ croak sprintf('Invalid section magic: line %s: section %s: magic length %u', $opts->{line}, $args[0], $l) if $l != 6 && $l != 4 && $l != 2 && $l != 0;
Branch: 1 branch
BranchTrueFalseTotal
if $l != 6 and $l != 4 and $l != 2 and $l != 0 0 0 0
Condition0%0/9
$l != 6 and $l != 4 and $l != 2 and $l != 0
!ll&&!rl&&r
000
$l != 6 and $l != 4 and $l != 2
!ll&&!rl&&r
000
$l != 6 and $l != 4
!ll&&!rl&&r
000
MC/DC0%0/4
$l != 6 and $l != 4 and $l != 2 and $l != 0
$l != 6 $l != 4 $l != 2 $l != 0
Truth table0%0/5
A and B and C and D
A= $l != 6B= $l != 4C= $l != 2D= $l != 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
952 0 $T += $l/2;
953 }
954  
955 0 $self->_align(2, 1);
956 0 $self->_save_position('section$'.$args[0]);
957  
958 0 %tpl = (code => 0, P => 0, codeX => 0, S => $S, T => 0);
959  
960 $self->{current}{section} = {
961 0 close_opcode => SIRTX::VM::Opcode->new(%tpl),
962 name => $args[0],
963 };
964  
965 0 ▶ unless ($self->_using_profile('minimal')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_using_profile("minimal")) 0 0 0
966 0 $self->_write_opcode(SIRTX::VM::Opcode->new(%tpl, T => $T, extra => $extra));
967 }
968 0 $self->_save_position('inner$section$'.$args[0]);
969  
970 0 $self->{sections}{$args[0]} = {};
971 ▶ } elsif ($cmd eq '.endsection' && scalar(@args) == 0 && defined(my $section = $self->{current}{section})) {
Condition0%0/6
$cmd eq ".endsection" and scalar @args == 0 and defined(my $section = $self->{"current"}{"section"})
!ll&&!rl&&r
000
$cmd eq ".endsection" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/3
$cmd eq ".endsection" and scalar @args == 0 and defined(my $section = $self->{"current"}{"section"})
$cmd eq ".endsection" scalar @args == 0 defined(my $section = $self->{"current"}{"section"})
Truth table0%0/4
A and B and C
A= $cmd eq ".endsection"B= scalar @args == 0C= defined(my $section = $self->{"current"}{"section"})
ABCresult
0XX0
10X0
1100
1111
972 0 my $section_suffix = 'section$'.$section->{name};
973 0 $self->_save_endposition('inner$'.$section_suffix);
974 0 ▶ unless ($self->_using_profile('minimal')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->_using_profile("minimal")) 0 0 0
975 0 ▶ $self->_write_opcode($section->{close_opcode}) if defined $section->{close_opcode};
Branch: 1 branch
BranchTrueFalseTotal
if defined $section->{"close_opcode"} 0 0 0
976 }
977 0 $self->_save_endposition($section_suffix);
978 0 $self->{current}{section} = undef;
979 ▶ } elsif ($cmd eq '.chunk' && scalar(@args) >= 2) {
Condition0%0/3
$cmd eq ".chunk" and scalar @args >= 2
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".chunk" and scalar @args >= 2
$cmd eq ".chunk" scalar @args >= 2
Truth table0%0/3
A and B
A= $cmd eq ".chunk"B= scalar @args >= 2
ABresult
0X0
100
111
980 0 my @in = @args;
981 0 my $flags = 0;
982 0 my $type;
983 0 my $identifier = 0;
984 0 my %info;
985 0 $self->_align(2, 1);
986  
987 0 ▶ while (scalar(@in)) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @in) 0 0 0
988 0 my $c = shift(@in);
989  
990 0 ▶ if (($c eq 'of' || $c eq 'as' || $c eq 'name') && scalar(@in)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($c eq 'of' || $c eq 'as' || $c eq 'name' and scalar @in) { } 0 0 0
elsif ($c eq 'standalone') { } 0 0 0
Condition0%0/8
$c eq "of" || $c eq "as" || $c eq "name" and scalar @in
!ll
00
$c eq "of" or $c eq "as" or $c eq "name"
l!l&&r!l&&!r
000
$c eq "of" or $c eq "as"
l!l&&r!l&&!r
000
MC/DC0%0/3
$c eq "of" || $c eq "as" || $c eq "name" and scalar @in
$c eq "of" $c eq "as" $c eq "name"
Truth table0%0/4
A or B or C
A= $c eq "of"B= $c eq "as"C= $c eq "name"
ABCresult
0000
1XX1
01X1
0011
991 0 $info{$c} = shift(@in);
992 } elsif ($c eq 'standalone') {
993 0 $info{$c} = 1;
994 } else {
995 0 croak sprintf('Invalid chunk option: line %s: %s', $opts->{line}, $c);
996 }
997 }
998  
999 0 ▶ if (defined(my $as = $info{as})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $as = $info{"as"})) 0 0 0
1000 0 ▶ if ($as !~ /^~([0-9]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($as =~ /^~([0-9]+)$/u) 0 0 0
1001 0 croak sprintf('Invalid chunk option: line %s: as %s', $opts->{line}, $as);
1002 }
1003  
1004 0 $identifier = int($1);
1005 }
1006  
1007 0 ▶ if (defined($info{name}) && length($info{name})) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $info{'name'} and length $info{'name'}) { } 0 0 0
elsif ($identifier) { } 0 0 0
Condition0%0/3
defined $info{"name"} and length $info{"name"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $info{"name"} and length $info{"name"}
defined $info{"name"} length $info{"name"}
Truth table0%0/3
A and B
A= defined $info{"name"}B= length $info{"name"}
ABresult
0X0
100
111
1008 0 ▶ unless ($info{name} =~ /^[0-9a-z]+$/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($info{"name"} =~ /^[0-9a-z]+$/u) 0 0 0
1009 0 croak sprintf('Invalid chunk name: line %s: %s', $opts->{line}, $info{name});
1010 }
1011 } elsif ($identifier) {
1012 0 $info{name} = sprintf('idchunk$%u', $identifier);
1013 } else {
1014 0 state $autochunk = 0;
1015 0 $info{name} = sprintf('autochunk$%u', $autochunk++);
1016 }
1017  
1018 # Allow for chunks' ID to be accessed via it's name
1019 0 ▶ push(@{$self->{aliases}{'hostdefined$chunk$'.$info{name}} //= []}, $info{as}) if defined $info{as};
Branch: 1 branch
BranchTrueFalseTotal
if defined $info{"as"} 0 0 0
Condition0%0/2
$self->{"aliases"}{'hostdefined$chunk$' . $info{"name"}} //= []
l!l
00
MC/DC0%0/1
$self->{"aliases"}{'hostdefined$chunk$' . $info{"name"}} //= []
$self->{"aliases"}{'hostdefined$chunk$' . $info{"name"}}
Truth table0%0/2
A
A= $self->{"aliases"}{'hostdefined$chunk$' . $info{"name"}}
Aresult
11
00
1020  
1021 0 ▶ if (defined(my $of = $info{of})) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $of = $info{'of'})) { } 0 0 0
1022 0 ▶ if ($of =~ /^~([0-9]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($of =~ /^~([0-9]+)$/u) { } 0 0 0
1023 0 $type = int($1);
1024 0 $flags |= 1<<15;
1025 } else {
1026 0 my $t;
1027 0 ($t, $type) = $self->_parse_id($of);
1028  
1029 0 ▶ if ($t eq 'sid') {
Branch: 2 branches
BranchTrueFalseTotal
if ($t eq 'sid') { } 0 0 0
elsif ($t eq 'sni') { } 0 0 0
1030 0 $flags |= 1<<14;
1031 } elsif ($t eq 'sni') {
1032 # no-op
1033 } else {
1034 0 croak sprintf('Invalid chunk type: line %s: of type %s not supported', $opts->{line}, $t);
1035 }
1036 }
1037 } else {
1038 0 croak sprintf('Invalid chunk: line %s: no of (type) given', $opts->{line});
1039 }
1040  
1041 0 ▶ $flags |= 1<<7 if $info{standalone};
Branch: 1 branch
BranchTrueFalseTotal
if $info{"standalone"} 0 0 0
1042 0 ▶ $flags |= 1<<1 if $identifier > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $identifier > 0 0 0 0
1043  
1044 0 print $out chr(0x06), chr(0x38+1);
1045 0 $self->_pushback(pos => $out->tell, parts => ['.uint16_half_up', 'size$chunk$'.$info{name}], opts => {%{$opts}, size => 2});
1046 0 print $out chr(0) x 2;
1047  
1048 0 $self->{current}{chunk} = $info{name};
1049 0 $self->_save_position('chunk$'.$info{name});
1050  
1051 0 $self->_pushback(pos => $out->tell, parts => ['.uint16', $flags], opts => {%{$opts}, size => 2}, update => sub {
1052 0 ▶ my (undef, $entry) = @_;
Subroutine __ANON__: not called CC=1 SCAR=6.9
1053 0 $entry->{parts}[1] |= $self->{aliases}{'size$chunk$'.$info{name}}[-1] & 1; # update padding flag
1054 0 });
1055 0 print $out chr(0) x 2;
1056  
1057 0 print $out pack('n', $type);
1058 0 ▶ print $out pack('n', $identifier) if $identifier > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $identifier > 0 0 0 0
1059 0 $self->_save_position('inner$chunk$'.$info{name});
1060 ▶ } elsif ($cmd eq '.endchunk' && scalar(@args) == 0 && defined($self->{current}{chunk})) {
Condition0%0/6
$cmd eq ".endchunk" and scalar @args == 0 and defined $self->{"current"}{"chunk"}
!ll&&!rl&&r
000
$cmd eq ".endchunk" and scalar @args == 0
!ll&&!rl&&r
000
MC/DC0%0/3
$cmd eq ".endchunk" and scalar @args == 0 and defined $self->{"current"}{"chunk"}
$cmd eq ".endchunk" scalar @args == 0 defined $self->{"current"}{"chunk"}
Truth table0%0/4
A and B and C
A= $cmd eq ".endchunk"B= scalar @args == 0C= defined $self->{"current"}{"chunk"}
ABCresult
0XX0
10X0
1100
1111
1061 0 $self->_save_endposition('inner$chunk$'.$self->{current}{chunk});
1062 0 $self->_save_endposition('chunk$'.$self->{current}{chunk});
1063 0 $self->{current}{chunk} = undef;
1064 0 $self->_align(2);
1065 ▶ } elsif ($cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/ && scalar(@args) == 1) {
Condition0%0/3
$cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/u and scalar @args == 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/u and scalar @args == 1
$cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/u scalar @args == 1
Truth table0%0/3
A and B
A= $cmd =~ /^\.(regmap_auto|synthetic_auto_unref)$/uB= scalar @args == 1
ABresult
0X0
100
111
1066 0 $self->{settings}{$1} = $self->_parse_bool($args[0]);
1067 ▶ } elsif ($cmd eq '.map' && scalar(@args) == 2) {
Condition0%0/3
$cmd eq ".map" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".map" and scalar @args == 2
$cmd eq ".map" scalar @args == 2
Truth table0%0/3
A and B
A= $cmd eq ".map"B= scalar @args == 2
ABresult
0X0
100
111
1068 0 $self->_reg_map(@args);
1069 } elsif ($cmd eq '.force_mapped') {
1070 0 $self->_force_mapped($_) foreach $self->{rf}->expand(@args);
1071 ▶ } elsif ($cmd eq '.mine' || $cmd eq '.yours' || $cmd eq '.theirs') {
Condition0%0/6
$cmd eq ".mine" or $cmd eq ".yours" or $cmd eq ".theirs"
l!l&&r!l&&!r
000
$cmd eq ".mine" or $cmd eq ".yours"
l!l&&r!l&&!r
000
MC/DC0%0/3
$cmd eq ".mine" or $cmd eq ".yours" or $cmd eq ".theirs"
$cmd eq ".mine" $cmd eq ".yours" $cmd eq ".theirs"
Truth table0%0/4
A or B or C
A= $cmd eq ".mine"B= $cmd eq ".yours"C= $cmd eq ".theirs"
ABCresult
1XX1
01X1
0011
0000
1072 0 ▶ my $mode = $cmd eq '.mine' ? SIRTX::VM::Register::OWNER_MINE() : $cmd eq '.yours' ? SIRTX::VM::Register::OWNER_YOURS() : SIRTX::VM::Register::OWNER_THEIRS();
Branch: 2 branches
BranchTrueFalseTotal
$cmd eq '.mine' ? : 0 0 0
$cmd eq '.yours' ? : 0 0 0
1073 0 my $rf = $self->{rf};
1074 0 foreach my $reg ($rf->expand(@args)) {
1075 0 $rf->register_owner($reg, $mode);
1076 }
1077 ▶ } elsif ($cmd eq '.hot' || $cmd eq '.cold' || $cmd eq '.lukewarm') {
Condition0%0/6
$cmd eq ".hot" or $cmd eq ".cold" or $cmd eq ".lukewarm"
l!l&&r!l&&!r
000
$cmd eq ".hot" or $cmd eq ".cold"
l!l&&r!l&&!r
000
MC/DC0%0/3
$cmd eq ".hot" or $cmd eq ".cold" or $cmd eq ".lukewarm"
$cmd eq ".hot" $cmd eq ".cold" $cmd eq ".lukewarm"
Truth table0%0/4
A or B or C
A= $cmd eq ".hot"B= $cmd eq ".cold"C= $cmd eq ".lukewarm"
ABCresult
1XX1
01X1
0011
0000
1078 0 ▶ my $mode = $cmd eq '.hot' ? SIRTX::VM::Register::TEMPERATURE_HOT() : $cmd eq '.cold' ? SIRTX::VM::Register::TEMPERATURE_COLD() : SIRTX::VM::Register::TEMPERATURE_LUKEWARM();
Branch: 2 branches
BranchTrueFalseTotal
$cmd eq '.hot' ? : 0 0 0
$cmd eq '.cold' ? : 0 0 0
1079 0 my $rf = $self->{rf};
1080 0 foreach my $reg ($rf->expand(@args)) {
1081 0 $rf->register_temperature($reg, $mode);
1082 }
1083 ▶ } elsif ($cmd eq '.regattr' && scalar(@args) >= 1) {
Condition0%0/3
$cmd eq ".regattr" and scalar @args >= 1
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq ".regattr" and scalar @args >= 1
$cmd eq ".regattr" scalar @args >= 1
Truth table0%0/3
A and B
A= $cmd eq ".regattr"B= scalar @args >= 1
ABresult
0X0
100
111
1084 0 my ($reg, @attrs) = @args;
1085 0 my $rf = $self->{rf};
1086  
1087 0 foreach my $attr (@attrs) {
1088 0 ▶ if ($attr eq 'mine') {
Branch: 7 branches
BranchTrueFalseTotal
if ($attr eq 'mine') { } 0 0 0
elsif ($attr eq 'yours') { } 0 0 0
elsif ($attr eq 'theirs') { } 0 0 0
elsif ($attr eq 'hot') { } 0 0 0
elsif ($attr eq 'cold') { } 0 0 0
elsif ($attr eq 'lukewarm') { } 0 0 0
elsif ($attr eq 'volatile') { } 0 0 0
1089 0 $rf->register_owner($reg, SIRTX::VM::Register::OWNER_MINE());
1090 } elsif ($attr eq 'yours') {
1091 0 $rf->register_owner($reg, SIRTX::VM::Register::OWNER_YOURS());
1092 } elsif ($attr eq 'theirs') {
1093 0 $rf->register_owner($reg, SIRTX::VM::Register::OWNER_THEIRS());
1094 } elsif ($attr eq 'hot') {
1095 0 $rf->register_temperature($reg, SIRTX::VM::Register::TEMPERATURE_HOT());
1096 } elsif ($attr eq 'cold') {
1097 0 $rf->register_temperature($reg, SIRTX::VM::Register::TEMPERATURE_COLD());
1098 } elsif ($attr eq 'lukewarm') {
1099 0 $rf->register_temperature($reg, SIRTX::VM::Register::TEMPERATURE_LUKEWARM());
1100 } elsif ($attr eq 'volatile') {
1101 # No-op
1102 } else {
1103 0 croak sprintf('Invalid register attribute: line %s: register %s: attribute: %s', $opts->{line}, $reg, $attr);
1104 }
1105 }
1106  
1107 ▶ } elsif ($cmd eq 'map' && scalar(@args) == 2) {
Condition0%0/3
$cmd eq "map" and scalar @args == 2
!ll&&!rl&&r
000
MC/DC0%0/2
$cmd eq "map" and scalar @args == 2
$cmd eq "map" scalar @args == 2
Truth table0%0/3
A and B
A= $cmd eq "map"B= scalar @args == 2
ABresult
0X0
100
111
1108 0 $self->_reg_map_and_write(@args);
1109  
1110 0 } elsif (defined($opcode = eval {SIRTX::VM::Opcode->from_template(parts => $parts, assembler => $self, size => $opts->{size}, line => $opts->{line}, out => $out, autodie => $autodie)})) {
1111 0 $self->_write_opcode($opcode);
1112 0 $was_return = $opcode->is_return;
1113 0 ▶ ${$autodie} = undef if $opcode->is_autodie;
Branch: 1 branch
BranchTrueFalseTotal
if $opcode->is_autodie 0 0 0
1114 } elsif (defined($opcode = eval {SIRTX::VM::Opcode->from_template(parts => [
1115 $parts->[0],
1116 0 ▶ map {scalar(eval {$self->_get_value_type($_) eq 'alias'}) ? 0xFFF0 : $_} $parts->@[1 .. (scalar(@{$parts}) - 1)]
Branch: 1 branch
BranchTrueFalseTotal
scalar eval { do { $self->_get_value_type($_) eq 'alias' } } ? : 0 0 0
1117 0 ], assembler => $self, size => $opts->{size}, line => $opts->{line}, out => $out, autodie => $autodie)})) {
1118 0 my $pos;
1119  
1120 # first align, then look where we are.
1121 0 $self->_align($opcode->required_alignment, 1);
1122 0 $pos = $self->{out}->tell;
1123  
1124 0 $self->_write_opcode($opcode);
1125 0 $was_return = $opcode->is_return;
1126 0 ▶ ${$autodie} = undef if $opcode->is_autodie;
Branch: 1 branch
BranchTrueFalseTotal
if $opcode->is_autodie 0 0 0
1127 0 $self->_pushback(pos => $pos, parts => $parts, opts => {%{$opts}, size => $opcode->required_size});
1128 ▶ } elsif (defined($_info{$cmd}) && scalar(@args) > 1 && $args[0] =~ /^~0?$/) {
Condition0%0/6
defined $_info{$cmd} and scalar @args > 1 and $args[0] =~ /^~0?$/u
!ll&&!rl&&r
000
defined $_info{$cmd} and scalar @args > 1
!ll&&!rl&&r
000
MC/DC0%0/3
defined $_info{$cmd} and scalar @args > 1 and $args[0] =~ /^~0?$/u
defined $_info{$cmd} scalar @args > 1 $args[0] =~ /^~0?$/u
Truth table0%0/4
A and B and C
A= defined $_info{$cmd}B= scalar @args > 1C= $args[0] =~ /^~0?$/u
ABCresult
0XX0
10X0
1100
1111
1129 # no-op for now.
1130 } else {
1131 0 my $done;
1132  
1133 0 ▶ if (defined(my $entry = $self->_get_synthetic($cmd))) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $entry = $self->_get_synthetic($cmd))) 0 0 0
1134 outer:
1135 0 ▶ for (my $i = 0; $i < scalar(@{$entry}); $i += 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < scalar @{$entry;}) 0 0 0
1136 0 my @argmap = @{$entry->[$i]};
1137 0 my @requests = @{$entry->[$i+1]};
1138 0 my %updates;
1139 my @allocations;
1140 0 my $reset_autodie;
1141  
1142 0 ▶ if (scalar(@argmap) >= 2 && $argmap[-2] eq 'any...') {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @argmap >= 2 and $argmap[-2] eq 'any...') { } 0 0 0
Condition0%0/3
scalar @argmap >= 2 and $argmap[-2] eq "any..."
!ll&&!rl&&r
000
MC/DC0%0/2
scalar @argmap >= 2 and $argmap[-2] eq "any..."
scalar @argmap >= 2 $argmap[-2] eq "any..."
Truth table0%0/3
A and B
A= scalar @argmap >= 2B= $argmap[-2] eq "any..."
ABresult
0X0
100
111
1143 0 ▶ next unless (scalar(@args)*2) >= scalar(@argmap);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar(@args) * 2 >= scalar @argmap 0 0 0
1144 } else {
1145 0 ▶ next unless (scalar(@args)*2) == scalar(@argmap);
Branch: 1 branch
BranchTrueFalseTotal
unless scalar(@args) * 2 == scalar @argmap 0 0 0
1146 }
1147  
1148 # Process argument map:
1149 0 ▶ for (my $j = 0; ($j*2) < scalar(@argmap); $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j * 2 < scalar @argmap) 0 0 0
1150 0 my $type = $argmap[$j*2 + 0];
1151 0 my $dst = $argmap[$j*2 + 1];
1152 0 my $val = $args[$j];
1153  
1154 0 ▶ if ($type =~ /^".+"$/) {
Branch: 3 branches
BranchTrueFalseTotal
if ($type =~ /^".+"$/u) { } 0 0 0
elsif ($type eq 'any') { } 0 0 0
elsif ($type eq 'any...') { } 0 0 0
1155 0 ▶ next outer if $val ne $self->_parse_string($type);
Branch: 1 branch
BranchTrueFalseTotal
if $val ne $self->_parse_string($type) 0 0 0
1156 } elsif ($type eq 'any') {
1157 # no-op.
1158 } elsif ($type eq 'any...') {
1159 0 $val = [@args[$j..$#args]];
1160 } else {
1161 0 my $t = $self->_get_value_type($val);
1162 0 ▶ if (ref $type) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $type) { } 0 0 0
1163 0 my $found;
1164 inner:
1165 0 foreach my $tw (@{$type}) {
1166 0 ▶ next inner if $t ne $tw && !($t =~ /:$/ && $tw eq 'id');
Branch: 1 branch
BranchTrueFalseTotal
if $t ne $tw and not $t =~ /:$/u && $tw eq "id" 0 0 0
Condition0%0/6
$t ne $tw and not $t =~ /:$/u && $tw eq "id"
!ll&&!rl&&r
000
$t =~ /:$/u && $tw eq 'id'
!ll&&!rl&&r
000
MC/DC0%0/3
$t ne $tw and not $t =~ /:$/u && $tw eq "id"
$t ne $tw $t =~ /:$/u $tw eq 'id'
Truth table0%0/4
A and not(B && C)
A= $t ne $twB= $t =~ /:$/uC= $tw eq 'id'
ABCresult
0XX0
1110
10X1
1101
1167 0 $found = 1;
1168 0 last;
1169 }
1170 0 ▶ next outer unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
1171 } else {
1172 0 ▶ next outer if $t ne $type && !($t =~ /:$/ && $type eq 'id');
Branch: 1 branch
BranchTrueFalseTotal
if $t ne $type and not $t =~ /:$/u && $type eq "id" 0 0 0
Condition0%0/6
$t ne $type and not $t =~ /:$/u && $type eq "id"
!ll&&!rl&&r
000
$t =~ /:$/u && $type eq 'id'
!ll&&!rl&&r
000
MC/DC0%0/3
$t ne $type and not $t =~ /:$/u && $type eq "id"
$t ne $type $t =~ /:$/u $type eq 'id'
Truth table0%0/4
A and not(B && C)
A= $t ne $typeB= $t =~ /:$/uC= $type eq 'id'
ABCresult
0XX0
1110
10X1
1101
1173 }
1174 }
1175  
1176 0 ▶ if ($dst eq 'undef') {
Branch: 1 branch
BranchTrueFalseTotal
if ($dst eq 'undef') { } 0 0 0
1177 # ignore this value
1178 } else {
1179 0 $updates{$dst} = $val;
1180 }
1181 }
1182  
1183 # Find suitable temp registers:
1184 0 ▶ for (my $j = 0; ($j*2) < scalar(@requests); $j++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j * 2 < scalar @requests) 0 0 0
1185 0 my $req = $requests[$j*2 + 0];
1186 0 my $dst = $requests[$j*2 + 1];
1187 0 my $found = $self->_reg_alloc_phy($req);
1188  
1189 0 $updates{$dst} = $found;
1190 0 push(@allocations, $found);
1191 }
1192  
1193 # Actually run the parts:
1194 0 foreach my $parts (@{$entry->[$i+2]}) {
1195 0 ▶ my @parts = map {ref ? ref($updates{${$_}}) ? @{$updates{${$_}}} : $updates{${$_}} : $_} @{$parts};
Branch: 2 branches
BranchTrueFalseTotal
ref $_ ? : 0 0 0
ref $updates{${$_;}} ? : 0 0 0
1196 0 my $ad;
1197  
1198 0 ▶ if ($parts[0] =~ s/\*$//) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parts[0] =~ s/\*$//u) 0 0 0
1199 0 $ad = ${$autodie};
1200 0 $reset_autodie = 1;
1201 }
1202  
1203 0 $self->_proc_parts(\@parts, $opts, \$ad);
1204 }
1205  
1206 0 ▶ if ($self->{settings}{synthetic_auto_unref}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"settings"}{"synthetic_auto_unref"}) 0 0 0
1207 0 $self->_proc_parts(['unref', $_], $opts) foreach @allocations;
1208 }
1209  
1210 0 $done = 1;
1211 0 ▶ ${$autodie} = undef if $reset_autodie;
Branch: 1 branch
BranchTrueFalseTotal
if $reset_autodie 0 0 0
1212 0 last outer;
1213 }
1214 }
1215  
1216 0 ▶ croak sprintf('Invalid input: line %s: command %s: arguments: %s', $opts->{line}, $cmd, join(', ', @args)) unless $done;
Branch: 1 branch
BranchTrueFalseTotal
unless $done 0 0 0
1217 }
1218  
1219 0 ▶ if (${$autodie}) {
Branch: 1 branch
BranchTrueFalseTotal
if (${$autodie;}) 0 0 0
1220 0 $opcode = SIRTX::VM::Opcode->from_template(parts => ['autodie'], assembler => $self, line => $opts->{line});
1221 0 $self->_write_opcode($opcode);
1222 }
1223  
1224 0 $self->{was_return} = $was_return;
1225 }
1226  
1227 sub _type_to_sni {
1228 0 ▶ my ($self, $type) = @_;
Subroutine _type_to_sni: not called CC=2 SCAR=17.9
1229 0 ▶ return $_type_to_sni{$type} // croak 'Unknown type: '.$type;
Condition0%0/3
$_type_to_sni{$type} // croak('Unknown type: ' . $type)
l!l&&r!l&&!r
000
MC/DC0%0/2
$_type_to_sni{$type} // croak('Unknown type: ' . $type)
$_type_to_sni{$type} croak('Unknown type: ' . $type)
Truth table0%0/3
A // B
A= $_type_to_sni{$type}B= croak('Unknown type: ' . $type)
ABresult
1X1
011
000
1230 }
1231  
1232 sub _get_value_type {
1233 0 ▶ my ($self, $value) = @_;
Subroutine _get_value_type: not called CC=14 SCAR=53.5
1234 0 ▶ return 'reg' if defined(scalar(eval {$self->{rf}->get_physical_by_name($value)}));
Branch: 1 branch
BranchTrueFalseTotal
if defined scalar eval { do { $self->{"rf"}->get_physical_by_name($value) } } 0 0 0
1235 0 ▶ return 'bool' if $value eq 'true' || $value eq 'false';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "true" or $value eq "false" 0 0 0
Condition0%0/3
$value eq "true" or $value eq "false"
l!l&&r!l&&!r
000
MC/DC0%0/2
$value eq "true" or $value eq "false"
$value eq "true" $value eq "false"
Truth table0%0/3
A or B
A= $value eq "true"B= $value eq "false"
ABresult
1X1
011
000
1236 0 ▶ return 'undef' if $value eq 'undef';
Branch: 1 branch
BranchTrueFalseTotal
if $value eq "undef" 0 0 0
1237 0 ▶ return 'string' if $value =~ /^(?:"|U\+)/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^(?:"|U\+)/u 0 0 0
1238 0 ▶ return 'int' if $value =~ /^'?[\+\-]?(?:0|[1-9][0-9]*|0x[0-9a-fA-F]+|0[0-7]+|0b[01]+)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^'?[\+\-]?(?:0|[1-9][0-9]*|0x[0-9a-fA-F]+|0[0-7]+|0b[01]+)$/u 0 0 0
1239 0 ▶ return 'port' if $value =~ /^%[a-zA-Z][:a-zA-Z0-9]*$/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^%[a-zA-Z][:a-zA-Z0-9]*$/u 0 0 0
1240  
1241 0 ▶ if ($value =~ /^([a-z]+):(?:0|[1-9][0-9]*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^([a-z]+):(?:0|[1-9][0-9]*)$/u) 0 0 0
1242 0 my $type = $1;
1243 0 ▶ return $type.':' if defined $_type_to_sni{$type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $_type_to_sni{$type} 0 0 0
1244 }
1245  
1246 0 $value =~ s/^\/(0|[1-9][0-9]*)$/127:$1/;
1247 0 ▶ if ($value =~ /^([1-9][0-9]*):(?:0|[1-9][0-9]*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($value =~ /^([1-9][0-9]*):(?:0|[1-9][0-9]*)$/u) 0 0 0
1248 0 my $type = $1;
1249 0 ▶ if (defined $_sni_to_type{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_sni_to_type{$type}) { } 0 0 0
1250 0 $type = $_sni_to_type{$type};
1251 } else {
1252 0 $_type_to_sni{$type} = $type;
1253 }
1254 0 return $type.':';
1255 }
1256 0 ▶ return 'logical:' if $value =~ /^logical:/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^logical:/u 0 0 0
1257 0 ▶ return 'alias' if $value =~ /^[a-z0-9]*\$/;
Branch: 1 branch
BranchTrueFalseTotal
if $value =~ /^[a-z0-9]*\$/u 0 0 0
1258 0 die 'Bad value: '.$value;
1259 }
1260  
1261 sub _parse_bool {
1262 0 ▶ my ($self, $bool) = @_;
Subroutine _parse_bool: not called CC=1 SCAR=6.9
1263 0 return $bool eq 'true';
1264 }
1265  
1266 sub _parse_int {
1267 0 ▶ my ($self, $val, $rel) = @_;
Subroutine _parse_int: not called CC=7 SCAR=40.3
1268 0 my $neg;
1269  
1270 0 $val =~ s/^'//;
1271  
1272 0 ▶ $rel //= 0;
Condition0%0/2
$rel //= 0
l!l
00
MC/DC0%0/1
$rel //= 0
$rel
Truth table0%0/2
A
A= $rel
Aresult
11
00
1273  
1274 0 ▶ if ($val =~ s/^-//) {
Branch: 2 branches
BranchTrueFalseTotal
if ($val =~ s/^-//u) { } 0 0 0
elsif ($val =~ s/^\+//u) { } 0 0 0
1275 0 $neg = 1;
1276 } elsif ($val =~ s/^\+//) {
1277 # no-op
1278 } else {
1279 0 $rel = 0;
1280 }
1281  
1282 0 ▶ if ($val =~ /^[1-9]/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($val =~ /^[1-9]/u) { } 0 0 0
elsif ($val =~ /^(?:0[0-7]*|0x[0-9a-fA-F]+|0b[01]+)$/u) { } 0 0 0
1283 0 $val = int($val);
1284 } elsif ($val =~ /^(?:0[0-7]*|0x[0-9a-fA-F]+|0b[01]+)$/) {
1285 0 $val = oct($val);
1286 } else {
1287 0 die 'Bad integer';
1288 }
1289  
1290 0 ▶ $val *= -1 if $neg;
Branch: 1 branch
BranchTrueFalseTotal
if $neg 0 0 0
1291  
1292 0 return $val + $rel;
1293 }
1294  
1295 sub _parse_escape {
1296 0 ▶ my ($esc) = @_;
Subroutine _parse_escape: not called CC=3 SCAR=24.8
1297  
1298 0 ▶ return $_escapes{$esc} if defined $_escapes{$esc};
Branch: 1 branch
BranchTrueFalseTotal
if defined $_escapes{$esc} 0 0 0
1299 0 ▶ return chr(hex($1)) if $esc =~ /^x([0-9a-f]{2})$/;
Branch: 1 branch
BranchTrueFalseTotal
if $esc =~ /^x([0-9a-f]{2})$/u 0 0 0
1300 }
1301  
1302 sub _parse_string {
1303 0 ▶ my ($self, $str) = @_;
Subroutine _parse_string: not called CC=3 SCAR=24.8
1304  
1305 0 ▶ if ($str =~ s/^"(.*)"$/$1/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($str =~ s/^"(.*)"$/$1/u) { } 0 0 0
elsif ($str =~ /^U\+([0-9a-fA-F]{4,6})$/u) { } 0 0 0
1306 # no-op
1307 } elsif ($str =~ /^U\+([0-9a-fA-F]{4,6})$/) {
1308 0 my $char = chr(hex($1));
1309 0 state $UTF_8 = Encode::find_encoding('UTF-8');
1310 0 return $UTF_8->encode($char);
1311 } else {
1312 0 die 'Bad string';
1313 }
1314  
1315 0 $str =~ s/\\(\\|[0nrte]|x[0-9a-f]{2})/_parse_escape($1)/ge;
1316  
1317 0 return $str;
1318 }
1319  
1320 sub _parse_id {
1321 0 ▶ my ($self, $str) = @_;
Subroutine _parse_id: not called CC=4 SCAR=30.0
1322  
1323 0 $str =~ s/^\/(0|[1-9][0-9]*)$/127:$1/;
1324  
1325 0 ▶ if ($str =~ /^([a-z]+):(0|[1-9][0-9]*)$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($str =~ /^([a-z]+):(0|[1-9][0-9]*)$/u) { } 0 0 0
elsif ($str =~ /^([1-9][0-9]*):(0|[1-9][0-9]*)$/u) { } 0 0 0
1326 0 my ($type, $num) = ($1, $2);
1327 0 return ($type, $self->_parse_int($num));
1328 } elsif ($str =~ /^([1-9][0-9]*):(0|[1-9][0-9]*)$/) {
1329 0 my ($type, $num) = ($1, $2);
1330 0 ▶ if (defined $_sni_to_type{$type}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_sni_to_type{$type}) { } 0 0 0
1331 0 $type = $_sni_to_type{$type};
1332 } else {
1333 0 $_type_to_sni{$type} = $type;
1334 }
1335 0 return ($type, $self->_parse_int($num));
1336 } else {
1337 0 die 'Bad ID';
1338 }
1339 }
1340  
1341 1 1;
1342  
1343 __END__
↑ Summary blib/lib/SIRTX/VM/Assembler.pm »