blib/lib/SPVM/Builder/Native/Runtime.pm

filter: Statementstmt 57.4% 50 / 87 Branchbran 44.4% 16 / 36 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 50.0% 5 / 10 Podpod 0.0% 0 / 8 totaltotal 49.6% 73 / 147 CC 23 SCAR 20.6
CC
23
Cov
54%
get_basic_types
10.0
get_basic_types
10.0
pointer
6.0
CRAP 7.8
« blib/lib/SPVM/Global.pm ↑ Summary blib/lib/SPVM/Builder/CompileInfo.pm »
1 package SPVM::Builder::Native::Runtime;
2  
3 293 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 293 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # Fields
7 0 ▶sub pointer {
Subroutine pointer: not called CC=2 SCAR=17.9
Pod undocumented
8 0 ▶ my $self = shift;
Subroutine pointer: not called CC=2 SCAR=17.9
Pod undocumented
9 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
if (@_) { } 0 0 0
10 0 $self->{pointer} = $_[0];
11 0 return $self;
12 }
13 else {
14 0 return $self->{pointer};
15 }
16 }
17  
18 0 ▶sub compiler {
Subroutine compiler: not called CC=2 SCAR=17.9
Pod undocumented
19 0 ▶ my $self = shift;
Subroutine compiler: not called CC=2 SCAR=17.9
Pod undocumented
20 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
if (@_) { } 0 0 0
21 0 $self->{compiler} = $_[0];
22 0 return $self;
23 }
24 else {
25 0 return $self->{compiler};
26 }
27 }
28  
29 483 ▶sub env {
Subroutine env: called CC=2 SCAR=16.5
Pod undocumented
30 0 ▶ my $self = shift;
Subroutine env: not called CC=2 SCAR=16.5
Pod undocumented
31 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
if (@_) { } 0 0 0
32 0 $self->{env} = $_[0];
33 0 return $self;
34 }
35 else {
36 0 return $self->{env};
37 }
38 }
39  
40 935 ▶sub get_basic_types {
Subroutine get_basic_types: called CC=9 SCAR=23.0
Pod undocumented
41 452 ▶ my ($self, $options) = @_;
Subroutine get_basic_types: called CC=9 SCAR=23.0
Pod undocumented
42
43 452 ▶ $options ||= {};
Condition50%2/4
$options ||= {}
l!l
4520
$options ||= {}
l!l
440
MC/DC0%0/1
$options ||= {}
$options
MC/DC0%0/1
$options ||= {}
$options
Truth table50%1/2
A
A= $options
Aresult
11
00
Truth table50%1/2
A
A= $options
Aresult
11
00
44
45 452 my $basic_types_length = $self->get_basic_types_length;
46
47 452 my $basic_types = [];
48
49 452 my $match = 1;
50
51 452 ▶ for (my $id = 0; $id < $basic_types_length; $id++) {
Branch: 2 branches
BranchTrueFalseTotal
if ($id < $basic_types_length) 15150 452 15602
if ($id < $basic_types_length) 2202 44 2246
52 15150 my $basic_type = $self->get_basic_type_by_id($id);
53
54 15150 ▶ if (exists $options->{category}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $options->{"category"}) 15150 0 15150
if (exists $options->{"category"}) 2202 0 2202
55 15150 my $categories = $options->{category};
56
57 15150 my $category_match = 0;
58 15150 for my $category (@$categories) {
59 36778 ▶ if ($basic_type->get_category == $category) {
Branch: 2 branches
BranchTrueFalseTotal
if ($basic_type->get_category == $category) 10178 26600 36778
if ($basic_type->get_category == $category) 1718 3230 4948
60 10178 $category_match = 1;
61 10178 last;
62 }
63 }
64
65 15150 ▶ unless ($category_match) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($category_match) 4972 10178 15150
unless ($category_match) 484 1718 2202
66 4972 next;
67 }
68 }
69
70 0 ▶ if (exists $options->{is_anon}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $options->{"is_anon"}) 0 10178 10178
if (exists $options->{"is_anon"}) 0 1718 1718
71 0 my $is_anon = $options->{is_anon};
72
73 0 my $basic_type_name = $basic_type->get_name;
74 0 my $basic_type_is_anon = $basic_type->is_anon;
75
76 0 my $is_anon_match = !!$basic_type->is_anon == !!$is_anon;
77
78 0 ▶ unless ($is_anon_match) {
Branch: 2 branches
BranchTrueFalseTotal
unless ($is_anon_match) 0 0 0
unless ($is_anon_match) 0 0 0
79 483 next;
80 }
81 }
82
83 10661 push @$basic_types, $basic_type;
84 }
85
86 935 return $basic_types;
87 }
88  
89 293 1;
90  
91 =head1 Name
92  
93 SPVM::Builder::Native::Runtime - Runtime
94  
95 =head1 Copyright & License
96  
97 Copyright (c) 2023 Yuki Kimoto
98  
99 MIT License
« blib/lib/SPVM/Global.pm ↑ Summary blib/lib/SPVM/Builder/CompileInfo.pm »