SPVM - Fast array and numeric operation, and provide easy way to C/C++ Binding
SPVM is before 1.0 under development! I will change implementation and specification without warnings.
Curent SPVM version is 0.3 serieses. This means implementation is finshed by 30% of version 1.0.
package MyMath { sub sum : int ($nums : int[]) { my $total = 0; for (my $i = 0; $i < @$nums; $i++) { $total += $nums->[$i]; } return $total; } }
SPVM provide fast array and numeric operation.
SPVM provide easy way to Bind C/C++ Language to Perl.
Fast array operation, Fast numeric operation, Static typing, Virtual machine, Precompile, Pre compile
Perlish syntax, Easy way to C/C++ binding, C99 math functions
SPVM Module:
# lib/MyMath.spvm package MyMath { sub sum : int ($nums : int[]) { my $total = 0; for (my $i = 0; $i < @$nums; $i++) { $total += $nums->[$i]; } return $total; } }
Use SPVM Module from Perl
use FindBin; use lib "$FindBin::Bin/lib"; use SPVM 'MyMath'; # New int array my $sp_nums = SPVM::new_int_array([3, 6, 8, 9]); # Call subroutine my $total = MyMath->sum($sp_nums); print $total . "\n";
See also SPVM::Document::SPVMAPI.
# lib/MyMathNative.spvm package MyMathNative { # Sub Declaration native sub sum int ($nums : int[]); }
C Source File;
// lib/MyMathNative.native/MyMathNative.c #include <spvm_native.h> int32_t SPVM_NATIVE_SUB(MyMathNative__sum) (SPVM_ENV* env, SPVM_VALUE* args) { // First argument void* sp_nums = args[0].oval; // Array length int32_t length = env->get_array_length(env, sp_nums); // Elements pointer int32_t* nums = env->get_int_array_elements(env, sp_nums); // Culcurate total int32_t total = 0; { int32_t i; for (i = 0; i < length; i++) { total += nums[i]; } } // Return value is set to args[0] args[0].ival = total; // If function success, return 0 return 0; }
Use Extension Module from Perl:
use FindBin; use lib "$FindBin::Bin/lib"; # Use SPVM module use SPVM 'MyMathNative'; # New SPVM int array my $sp_nums = SPVM::new_int_array([3, 6, 8, 9]); # Call SPVM subroutine my $total = MyMathNative->sum($sp_nums); print $total . "\n";
See also SPVM::Document::Extension, SPVM::Document::NativeInterface.
SPVM::Document::Functions
print, warn, time
SPVM::CORE, SPVM::Byte, SPVM::Short, SPVM::Int, SPVM::Long, SPVM::Float, SPVM::Double, SPVM::Bool
SPVM::Document::SPVMAPI
SPVM::Document::NativeInterface
SPVM::Document::Language
If you have problems or find bugs, comment to GitHub Issue.
SPVM(GitHub).
Yuki Kimoto <kimoto.yuki@gmail.com<gt>
akinomyoga (Koichi Murase)
[NAGAYASU Shinya
Reini Urban
chromatic
Kazutake Hiramatsu
Copyright 2017-2018 Yuki Kimoto, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install SPVM, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SPVM
CPAN shell
perl -MCPAN -e shell install SPVM
For more information on module installation, please visit the detailed CPAN module installation guide.