line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SPVM::Builder::Compiler; |
2
|
|
|
|
|
|
|
|
3
|
278
|
|
|
278
|
|
2005
|
use strict; |
|
278
|
|
|
|
|
580
|
|
|
278
|
|
|
|
|
8440
|
|
4
|
278
|
|
|
278
|
|
1397
|
use warnings; |
|
278
|
|
|
|
|
544
|
|
|
278
|
|
|
|
|
112880
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
### Fields |
7
|
|
|
|
|
|
|
|
8
|
2633
|
|
|
2633
|
0
|
25874
|
sub get_runtime { shift->{runtime} } |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub env_api { |
11
|
1061
|
|
|
1061
|
0
|
1781
|
my $self = shift; |
12
|
1061
|
50
|
|
|
|
2596
|
if (@_) { |
13
|
1061
|
|
|
|
|
2697
|
$self->{env_api} = $_[0]; |
14
|
1061
|
|
|
|
|
2017
|
return $self; |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
else { |
17
|
0
|
|
|
|
|
0
|
return $self->{env_api}; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub pointer { |
22
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
23
|
0
|
0
|
|
|
|
0
|
if (@_) { |
24
|
0
|
|
|
|
|
0
|
$self->{pointer} = $_[0]; |
25
|
0
|
|
|
|
|
0
|
return $self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
else { |
28
|
0
|
|
|
|
|
0
|
return $self->{pointer}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub include_dirs { |
33
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
34
|
0
|
0
|
|
|
|
0
|
if (@_) { |
35
|
0
|
|
|
|
|
0
|
$self->{include_dirs} = $_[0]; |
36
|
0
|
|
|
|
|
0
|
return $self; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else { |
39
|
0
|
|
|
|
|
0
|
return $self->{include_dirs}; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub print_error_messages { |
44
|
0
|
|
|
0
|
0
|
0
|
my ($self, $fh) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
0
|
my $error_messages = $self->get_error_messages; |
47
|
0
|
|
|
|
|
0
|
for my $error_message (@$error_messages) { |
48
|
0
|
|
|
|
|
0
|
printf $fh "[CompileError]$error_message\n"; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub new { |
53
|
1061
|
|
|
1061
|
0
|
2057
|
my $class = shift; |
54
|
|
|
|
|
|
|
|
55
|
1061
|
|
|
|
|
2476
|
my $self = {@_}; |
56
|
|
|
|
|
|
|
|
57
|
1061
|
|
|
|
|
2046
|
bless $self, $class; |
58
|
|
|
|
|
|
|
|
59
|
1061
|
|
|
|
|
25206
|
my $env_api = SPVM::Builder::Env->new; |
60
|
|
|
|
|
|
|
|
61
|
1061
|
|
|
|
|
3845
|
$self->env_api($env_api); |
62
|
|
|
|
|
|
|
|
63
|
1061
|
|
|
|
|
36737
|
$self->create_native_compiler; |
64
|
|
|
|
|
|
|
|
65
|
1061
|
|
|
|
|
3212
|
my $runtime = $self->get_runtime; |
66
|
|
|
|
|
|
|
|
67
|
1061
|
|
|
|
|
4376
|
$runtime->env_api($env_api); |
68
|
|
|
|
|
|
|
|
69
|
1061
|
|
|
|
|
2423
|
return $self; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub compile_with_exit { |
73
|
1572
|
|
|
1572
|
0
|
3942
|
my ($self, $basic_type_name, $file, $line) = @_; |
74
|
|
|
|
|
|
|
|
75
|
1572
|
|
|
|
|
26722391
|
my $success = $self->compile($basic_type_name, __FILE__, __LINE__); |
76
|
1572
|
50
|
|
|
|
11374
|
unless ($success) { |
77
|
0
|
|
|
|
|
|
$self->print_error_messages(*STDERR); |
78
|
0
|
|
|
|
|
|
exit(255); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
1; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 Name |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
SPVM::Builder::Compiler - SPVM Builder Compiler |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 Copyright & License |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Copyright (c) 2023 Yuki Kimoto |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
MIT License |