| 1 | package SPVM; | ||||||||||||||
| 2 | 1542 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 3 | 1542 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | |||||||||||||||
| 5 | 776 | ▶ | use SPVM::Global; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 6 | |||||||||||||||
| 7 | our $VERSION = "0.990209"; | ||||||||||||||
| 8 | |||||||||||||||
| 9 | require XSLoader; | ||||||||||||||
| 10 | XSLoader::load('SPVM', $VERSION); | ||||||||||||||
| 11 | |||||||||||||||
| 12 | 667 | ▶ | sub import { | ||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||
| 13 | 10 | ▶ | my ($class, $class_name) = @_; | ||||||||||||
|
Subroutine
import: called CC=2 SCAR=6.9
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | 10 | my ($file, $line) = (caller)[1, 2]; | |||||||||||||
| 16 | |||||||||||||||
| 17 | 10 | SPVM::Global::init_api(); | |||||||||||||
| 18 | |||||||||||||||
| 19 | 10 | ▶ | if (defined $class_name) { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 20 | 10 | SPVM::Global::build_class($class_name, $file, $line); | |||||||||||||
| 21 | } | ||||||||||||||
| 22 | } | ||||||||||||||
| 23 | |||||||||||||||
| 24 | 6036 | ▶ | sub api { SPVM::Global::api() } | ||||||||||||
|
Subroutine
api: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||
| 25 | |||||||||||||||
| 26 | 1; | ||||||||||||||
| 27 | |||||||||||||||
| 28 | =encoding utf8 | ||||||||||||||
| 29 | |||||||||||||||
| 30 | =head1 Name | ||||||||||||||
| 31 | |||||||||||||||
| 32 | SPVM - The SPVM Language | ||||||||||||||
| 33 | |||||||||||||||
| 34 | =begin html | ||||||||||||||
| 35 | |||||||||||||||
| 36 | <img src="https://github.com/yuki-kimoto/SPVM/raw/master/logo/spvm_logo.jpg" width="80px" alt="SPVM cat"> | ||||||||||||||
| 37 | |||||||||||||||
| 38 | =end html | ||||||||||||||
| 39 | |||||||||||||||
| 40 | =head1 Description | ||||||||||||||
| 41 | |||||||||||||||
| 42 | SPVM is a statically typed programming language that has Perl-like syntax. | ||||||||||||||
| 43 | |||||||||||||||
| 44 | SPVM has not yet reached a stable release of version 1.0. For now, there is currently no policy to keep the L<backward compatibility|https://github.com/yuki-kimoto/SPVM/wiki/Backward-Compatibility>. | ||||||||||||||
| 45 | |||||||||||||||
| 46 | =head1 Usage | ||||||||||||||
| 47 | |||||||||||||||
| 48 | =head2 One Liner | ||||||||||||||
| 49 | |||||||||||||||
| 50 | Run a one liner using L<spvm> command. | ||||||||||||||
| 51 | |||||||||||||||
| 52 | # Hello World! | ||||||||||||||
| 53 | spvm -e 'say "Hello World!";'; | ||||||||||||||
| 54 | |||||||||||||||
| 55 | Run a one liner with loading a class. | ||||||||||||||
| 56 | |||||||||||||||
| 57 | # foo,bar,baz | ||||||||||||||
| 58 | spvm -M Fn -e 'say Fn->join(",", ["foo", "bar", "baz"]);' | ||||||||||||||
| 59 | |||||||||||||||
| 60 | =head2 Executing An SPVM Program | ||||||||||||||
| 61 | |||||||||||||||
| 62 | Write a L<SPVM class|SPVM::Document::Language::Class> named C<hello.spvm> to print "Hello World!" using L<say operator|SPVM::Document::Language::Operators/"say Operator">. | ||||||||||||||
| 63 | |||||||||||||||
| 64 | # hello.spvm | ||||||||||||||
| 65 | say "Hello World!"; | ||||||||||||||
| 66 | |||||||||||||||
| 67 | This class is an L<anon class|SPVM::Document::Language::Class/"Anon Class"> and has C<main> method that is an L<bootstrap method|SPVM::Document::Language::Class/"Bootstrap Method">. | ||||||||||||||
| 68 | |||||||||||||||
| 69 | Run the SPVM program using L<spvm> command. | ||||||||||||||
| 70 | |||||||||||||||
| 71 | spvm hello.spvm | ||||||||||||||
| 72 | |||||||||||||||
| 73 | =head2 Generating An Executable File | ||||||||||||||
| 74 | |||||||||||||||
| 75 | Generate an executable file using L<spvmcc> command. | ||||||||||||||
| 76 | |||||||||||||||
| 77 | spvmcc -B ~/.spvm_build -o ./hello --no-config hello.spvm | ||||||||||||||
| 78 | |||||||||||||||
| 79 | Run the executable file. | ||||||||||||||
| 80 | |||||||||||||||
| 81 | ./hello | ||||||||||||||
| 82 | |||||||||||||||
| 83 | =head2 Calling An SPVM Method from Perl | ||||||||||||||
| 84 | |||||||||||||||
| 85 | Write an SPVM class. | ||||||||||||||
| 86 | |||||||||||||||
| 87 | # lib/SPVM/MyMath.spvm | ||||||||||||||
| 88 | class MyMath { | ||||||||||||||
| 89 | static method sum : int ($nums : int[]) { | ||||||||||||||
| 90 | |||||||||||||||
| 91 | my $total = 0; | ||||||||||||||
| 92 | for (my $i = 0; $i < @$nums; $i++) { | ||||||||||||||
| 93 | $total += $nums->[$i]; | ||||||||||||||
| 94 | } | ||||||||||||||
| 95 | |||||||||||||||
| 96 | return $total; | ||||||||||||||
| 97 | } | ||||||||||||||
| 98 | } | ||||||||||||||
| 99 | |||||||||||||||
| 100 | Write a Perl program calling an SPVM method using L<exchange APIs|SPVM::ExchangeAPI>. | ||||||||||||||
| 101 | |||||||||||||||
| 102 | # sum.pl | ||||||||||||||
| 103 | use FindBin; | ||||||||||||||
| 104 | use lib "$FindBin::Bin/lib"; | ||||||||||||||
| 105 | |||||||||||||||
| 106 | use SPVM 'MyMath'; | ||||||||||||||
| 107 | |||||||||||||||
| 108 | my $total = SPVM::MyMath->sum([3, 6, 8, 9]); | ||||||||||||||
| 109 | |||||||||||||||
| 110 | print "$total\n"; | ||||||||||||||
| 111 | |||||||||||||||
| 112 | Run the Perl program. | ||||||||||||||
| 113 | |||||||||||||||
| 114 | # Run | ||||||||||||||
| 115 | perl sum.pl | ||||||||||||||
| 116 | |||||||||||||||
| 117 | =head1 Features | ||||||||||||||
| 118 | |||||||||||||||
| 119 | =over 2 | ||||||||||||||
| 120 | |||||||||||||||
| 121 | =item * L<Perl starndard functions|SPVM::Fn> and L<Perl standard modules|SPVM::Document::Modules>. | ||||||||||||||
| 122 | |||||||||||||||
| 123 | =item * L<Native threads|SPVM::Thread> and L<goroutines|SPVM::Go>. | ||||||||||||||
| 124 | |||||||||||||||
| 125 | =item * L<Executing SPVM programs|spvm> | ||||||||||||||
| 126 | |||||||||||||||
| 127 | =item * L<Generating an executable file|spvmcc> | ||||||||||||||
| 128 | |||||||||||||||
| 129 | =item * AOT(Ahead-of-time compilation) and JIT(Just-in-time compilation). | ||||||||||||||
| 130 | |||||||||||||||
| 131 | =item * Static types, type inference and L<static analysis|SPVM::Native::Compiler>. | ||||||||||||||
| 132 | |||||||||||||||
| 133 | =item * L<C and C++ binding|SPVM::Document::NativeClass> and L<resource system|SPVM::Document::Resource> for C and C++ libraries. | ||||||||||||||
| 134 | |||||||||||||||
| 135 | =item * L<Perl binding for SPVM methods|SPVM::ExchangeAPI>. | ||||||||||||||
| 136 | |||||||||||||||
| 137 | =item * L<Perl-like syntax|SPVM::Document::Language> with class syntax. | ||||||||||||||
| 138 | |||||||||||||||
| 139 | =item * L<High performance|https://github.com/yuki-kimoto/SPVM/wiki/Benchmark> | ||||||||||||||
| 140 | |||||||||||||||
| 141 | =item * Paralell compilation and link support. Paralell test support. Debug build support(gdb can show the stack trace). ASan support on Linux (-fsanitize=address). LLVM support(clang, lld). MSVC(Microsoft Visual C++) support(cl, link). MSVC debug build support(cdb can show the stack trace). MSVC with LLVM support(clang-cl, lld-link). See L<Makefile.PL|https://github.com/yuki-kimoto/SPVM/blob/master/Makefile.PL>. L<spvmdist> command generates Makefile.PL which has the same options. | ||||||||||||||
| 142 | |||||||||||||||
| 143 | =back | ||||||||||||||
| 144 | |||||||||||||||
| 145 | =head1 Tutorial | ||||||||||||||
| 146 | |||||||||||||||
| 147 | =over 2 | ||||||||||||||
| 148 | |||||||||||||||
| 149 | =item * L<SPVM Tutorial|https://github.com/yuki-kimoto/SPVM/wiki/Tutorial> | ||||||||||||||
| 150 | |||||||||||||||
| 151 | =back | ||||||||||||||
| 152 | |||||||||||||||
| 153 | =head1 Documentation | ||||||||||||||
| 154 | |||||||||||||||
| 155 | =over 2 | ||||||||||||||
| 156 | |||||||||||||||
| 157 | =item * L<SPVM Documentation|SPVM::Document> | ||||||||||||||
| 158 | |||||||||||||||
| 159 | =back | ||||||||||||||
| 160 | |||||||||||||||
| 161 | =head1 Modules | ||||||||||||||
| 162 | |||||||||||||||
| 163 | =over 2 | ||||||||||||||
| 164 | |||||||||||||||
| 165 | =item * L<Standard Modules|SPVM::Document::Modules> | ||||||||||||||
| 166 | |||||||||||||||
| 167 | =item * L<CPAN Modules|https://github.com/yuki-kimoto/SPVM/wiki/CPAN-Modules> | ||||||||||||||
| 168 | |||||||||||||||
| 169 | =back | ||||||||||||||
| 170 | |||||||||||||||
| 171 | =head1 Examples | ||||||||||||||
| 172 | |||||||||||||||
| 173 | =over 2 | ||||||||||||||
| 174 | |||||||||||||||
| 175 | =item * L<SPVM Test Cases|https://github.com/yuki-kimoto/SPVM/tree/doc/t/02_vm/lib/SPVM/TestCase> | ||||||||||||||
| 176 | |||||||||||||||
| 177 | =item * L<Binding C/C++ Libraries|https://github.com/yuki-kimoto/SPVM/tree/doc/examples/native> | ||||||||||||||
| 178 | |||||||||||||||
| 179 | =back | ||||||||||||||
| 180 | |||||||||||||||
| 181 | =head1 Wiki | ||||||||||||||
| 182 | |||||||||||||||
| 183 | =over 2 | ||||||||||||||
| 184 | |||||||||||||||
| 185 | =item * L<Wiki|https://github.com/yuki-kimoto/SPVM/wiki> | ||||||||||||||
| 186 | |||||||||||||||
| 187 | =back | ||||||||||||||
| 188 | |||||||||||||||
| 189 | =head1 Repository | ||||||||||||||
| 190 | |||||||||||||||
| 191 | L<SPVM - Github|https://github.com/yuki-kimoto/SPVM> | ||||||||||||||
| 192 | |||||||||||||||
| 193 | =head1 Author | ||||||||||||||
| 194 | |||||||||||||||
| 195 | Yuki Kimoto E<lt>kimoto.yuki@gmail.comE<gt> | ||||||||||||||
| 196 | |||||||||||||||
| 197 | =head1 Core Developers | ||||||||||||||
| 198 | |||||||||||||||
| 199 | motiE<lt>motohiko.ave@gmail.comE<gt> | ||||||||||||||
| 200 | |||||||||||||||
| 201 | =head1 Contributors | ||||||||||||||
| 202 | |||||||||||||||
| 203 | =over 2 | ||||||||||||||
| 204 | |||||||||||||||
| 205 | =item * Mohammad S Anwar | ||||||||||||||
| 206 | |||||||||||||||
| 207 | =item * akinomyoga | ||||||||||||||
| 208 | |||||||||||||||
| 209 | =item * NAGAYASU Shinya | ||||||||||||||
| 210 | |||||||||||||||
| 211 | =item * Reini Urban | ||||||||||||||
| 212 | |||||||||||||||
| 213 | =item * chromatic | ||||||||||||||
| 214 | |||||||||||||||
| 215 | =item * Kazutake Hiramatsu | ||||||||||||||
| 216 | |||||||||||||||
| 217 | =item * Yasuaki Omokawa | ||||||||||||||
| 218 | |||||||||||||||
| 219 | =item * Suman Khanal | ||||||||||||||
| 220 | |||||||||||||||
| 221 | =item * L<Ryunosuke Murakami|https://github.com/ryun0suke22> | ||||||||||||||
| 222 | |||||||||||||||
| 223 | =item * L<Yoshiyuki Itoh|https://github.com/YoshiyukiItoh> | ||||||||||||||
| 224 | |||||||||||||||
| 225 | =item * L<Tore Aursand|https://github.com/toreau> | ||||||||||||||
| 226 | |||||||||||||||
| 227 | =item * L<greengorcer|https://github.com/greengorcer> | ||||||||||||||
| 228 | |||||||||||||||
| 229 | =back | ||||||||||||||
| 230 | |||||||||||||||
| 231 | =head1 Copyright & License | ||||||||||||||
| 232 | |||||||||||||||
| 233 | Copyright (c) 2023 Yuki Kimoto | ||||||||||||||
| 234 | |||||||||||||||
| 235 | MIT License | ||||||||||||||
| 236 | |||||||||||||||
| 237 | =cut | ||||||||||||||