line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
278
|
|
|
278
|
|
19735602
|
use 5.008007; |
|
278
|
|
|
|
|
3792
|
|
2
|
|
|
|
|
|
|
package SPVM; |
3
|
278
|
|
|
278
|
|
2763
|
use strict; |
|
278
|
|
|
|
|
786
|
|
|
278
|
|
|
|
|
8553
|
|
4
|
278
|
|
|
278
|
|
1720
|
use warnings; |
|
278
|
|
|
|
|
592
|
|
|
278
|
|
|
|
|
8876
|
|
5
|
|
|
|
|
|
|
|
6
|
278
|
|
|
278
|
|
136658
|
use SPVM::Global; |
|
278
|
|
|
|
|
1113
|
|
|
278
|
|
|
|
|
48187
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = "0.989047"; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require XSLoader; |
11
|
|
|
|
|
|
|
XSLoader::load('SPVM', $VERSION); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
387
|
|
|
387
|
|
86395
|
my ($class, $basic_type_name) = @_; |
15
|
|
|
|
|
|
|
|
16
|
387
|
|
|
|
|
1874
|
my ($file, $line) = (caller)[1, 2]; |
17
|
|
|
|
|
|
|
|
18
|
387
|
100
|
|
|
|
17072
|
if (defined $basic_type_name) { |
19
|
377
|
|
|
|
|
1578
|
SPVM::Global::build_module($basic_type_name, $file, $line); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
13342
|
|
|
13342
|
1
|
12384114
|
sub api { SPVM::Global::api() } |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
1; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=encoding utf8 |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 Name |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
SPVM - SPVM Language |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 Description |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
SPVM is a statically typed programming language with the syntax of Perl. |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
SPVM has not yet reached a stable release of version 1.0. For now, L of methods and features will not be kept. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 Usage |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
A class of SPVM: |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# lib/SPVM/MyMath.spvm |
44
|
|
|
|
|
|
|
class MyMath { |
45
|
|
|
|
|
|
|
C |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $total = 0; |
48
|
|
|
|
|
|
|
for (my $i = 0; $i < @$nums; $i++) { |
49
|
|
|
|
|
|
|
$total += $nums->[$i]; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return $total; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Calling a SPVM method from Perl: |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# sum.pl |
59
|
|
|
|
|
|
|
use FindBin; |
60
|
|
|
|
|
|
|
use lib "$FindBin::Bin/lib"; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
use SPVM 'MyMath'; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Call method |
65
|
|
|
|
|
|
|
my $total = SPVM::MyMath->sum([3, 6, 8, 9]); |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 Documents |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over 2 |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item * L - SPVM Tutorial |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=item * L - SPVM Language Specification |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=item * L - SPVM Standard Modules |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item * L - Exchange APIs |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item * L - Native Class |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=item * L - Native APIs |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item * L - Resource |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=item * L - Creating Executable File |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=item * L - Creating SPVM Distribution |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * L - SPVM Performance Benchmarks |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=back |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 use |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
use SPVM; |
96
|
|
|
|
|
|
|
use SPVM 'SomeClass'; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Loads the L module. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
If a class name of SPVM is given as the first argument, the SPVM module is loaded and is bound to a Perl module. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
The bound Perl class name is prefixed with C. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Exceptions: |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
If the SPVM module cannot be loaded, an exception is thrown. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Examples: |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
use SPVM 'Int'; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
my $int_object = SPVM::Int->new(3); |
113
|
|
|
|
|
|
|
my $value = $int_object->value. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 Functions |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 api |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
my $api = SPVM::api(); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Gets the global L object for this Perl interpreter. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 Environment Variables |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
If an environment variable is an empty string, it is treated as an undefined value. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head2 SPVM_BUILD_DIR |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
A directory for files generated by the compiler and linker. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
C source codes for precompilation, dynamic link libraries and object files are stored into this directory. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
These files are output when attempting to build a module containing methods with the C attribute or the C attribute. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
If these files are output and the directory given by the C environment variable does not exist, an exception is thrown. |
136
|
|
|
|
|
|
|
Examples: |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# bash |
139
|
|
|
|
|
|
|
export SPVM_BUILD_DIR=~/.spvm_build |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# csh |
142
|
|
|
|
|
|
|
setenv SPVM_BUILD_DIR ~/.spvm_build |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head2 SPVM_CC_DEBUG |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
If the C environement variable is a true value of Perl, debug messages and messages from the L compiler and linker are printed to stderr. |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head2 SPVM_CC_QUIET |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
If the C environement variable is a true value of Perl, messages the L compiler and linker are not printed to stderr. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
If it is defined and a false value of Perl, the messages are printed. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This setting has a higher priority than the L field of the L module. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=head2 SPVM_CC_FORCE |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
If the C environement variable is a true value of Perl, the compilation and link by the L compiler and linker are forced. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
This setting has a higher priority than the L field of the L module. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head1 Repository |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
L |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 Author |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Yuki Kimoto Ekimoto.yuki@gmail.comE |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 Core Developers |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
motiEmotohiko.ave@gmail.comE |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head1 Contributors |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=over 2 |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=item * Mohammad S Anwar |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=item * akinomyoga |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=item * NAGAYASU Shinya |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
=item * Reini Urban |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=item * chromatic |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=item * Kazutake Hiramatsu |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item * Yasuaki Omokawa |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
=item * Suman Khanal |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item * L |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=item * L |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item * L |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item * L |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=back |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 Copyright & License |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Copyright (c) 2023 Yuki Kimoto |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
MIT License |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=cut |