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

filter: Statementstmt 56.8% 58 / 102 Branchbran 31.2% 5 / 16 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 64.7% 11 / 17 Podpod 0.0% 0 / 13 totaltotal 50.0% 74 / 148 CC 11 SCAR 8.1
CC
11
Cov
53%
pointer
3.1
pointer
3.1
boot_env
2.7
CRAP 2.2
« blib/lib/SPVM/Builder/Config/Util.pm ↑ Summary blib/lib/SPVM/Builder/Accessor.pm »
1 package SPVM::Builder::Native::Compiler;
2  
3 2274 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 360 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1471 ▶use Scalar::Util 'weaken';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1471 ▶use SPVM::Builder::Native::Runtime;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 ### Fields
10  
11 917 ▶sub get_runtime { shift->{runtime} }
Subroutine get_runtime: called CC=1 SCAR=0.0
Pod undocumented
12  
13 795 ▶sub pointer {
Subroutine pointer: called CC=2 SCAR=11.2
Pod undocumented
14 0 ▶ my $self = shift;
Subroutine pointer: not called CC=2 SCAR=11.2
Pod undocumented
15 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 0 0 0
if (@_) { } 0 0 0
16 0 $self->{pointer} = $_[0];
17 0 return $self;
18 }
19 else {
20 0 return $self->{pointer};
21 }
22 }
23  
24 328 ▶sub boot_env {
Subroutine boot_env: called CC=2 SCAR=10.1
Pod undocumented
25 0 ▶ my $self = shift;
Subroutine boot_env: not called CC=2 SCAR=10.1
Pod undocumented
26 0 ▶ if (@_) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_) { } 1437 0 1437
if (@_) { } 0 0 0
27 0 $self->{boot_env} = $_[0];
28 0 return $self;
29 }
30 else {
31 0 return $self->{boot_env};
32 }
33 }
34  
35 406 ▶sub get_formatted_error_messages {
Subroutine get_formatted_error_messages: called CC=2 SCAR=9.2
Pod undocumented
36 0 ▶ my ($self, $fh) = @_;
Subroutine get_formatted_error_messages: not called CC=2 SCAR=9.2
Pod undocumented
37
38 0 my $formatted_error_messages = [];
39 0 my $error_messages = $self->get_error_messages;
40 0 for my $error_message (@$error_messages) {
41 0 push @$formatted_error_messages, "[Compilation Error]$error_message\n";
42 }
43
44 0 return $formatted_error_messages;
45 }
46  
47 730 ▶sub new {
Subroutine new: called CC=1 SCAR=1.2
Pod undocumented
48 0 ▶ my $class = shift;
Subroutine new: not called CC=1 SCAR=1.2
Pod undocumented
49
50 0 my $self = {@_};
51
52 0 bless $self, $class;
53
54 0 my $boot_env = SPVM::Builder::Native::Env->new;
55
56 0 $self->boot_env($boot_env);
57
58 0 $self->create_native_compiler;
59
60 0 my $runtime = $self->get_runtime;
61
62 0 $runtime->{compiler} = $self;
63
64 0 weaken $runtime->{compiler};
65
66 0 return $self;
67 }
68  
69 894 ▶sub compile_with_exit {
Subroutine compile_with_exit: called CC=2 SCAR=9.2
Pod undocumented
70 0 ▶ my ($self, $class_name, $file, $line) = @_;
Subroutine compile_with_exit: not called CC=2 SCAR=9.2
Pod undocumented
71
72 0 $self->set_start_file($file);
73
74 0 $self->set_start_line($line);
75
76 0 eval { $self->compile($class_name); };
77
78 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 2 1283 1285
if ($@) 0 0 0
79 0 Carp::confess(join("\n", @{$self->get_formatted_error_messages}));
80 }
81 }
82  
83 484 ▶sub compile_anon_class_with_exit {
Subroutine compile_anon_class_with_exit: called CC=2 SCAR=9.2
Pod undocumented
84 0 ▶ my ($self, $source, $file, $line) = @_;
Subroutine compile_anon_class_with_exit: not called CC=2 SCAR=9.2
Pod undocumented
85
86 0 $self->set_start_file($file);
87
88 0 $self->set_start_line($line);
89
90 0 my $anon_class_name;
91
92 0 eval { $anon_class_name = $self->compile_anon_class($source); };
93
94 0 ▶ if ($@) {
Branch: 2 branches
BranchTrueFalseTotal
if ($@) 2 80 82
if ($@) 0 0 0
95 0 Carp::confess(join("\n", @{$self->get_formatted_error_messages}));
96 }
97
98 0 return $anon_class_name;
99 }
100  
101 360 1;
102  
103 =head1 Name
104  
105 SPVM::Builder::Native::Compiler - Compiler Native APIs
106  
107 =head1 Copyright & License
108  
109 Copyright (c) 2023 Yuki Kimoto
110  
111 MIT License
« blib/lib/SPVM/Builder/Config/Util.pm ↑ Summary blib/lib/SPVM/Builder/Accessor.pm »