SPVM::Native − Getting the current native environment, stack, runtime, compiler.
The Native class of SPVM has methods to get the current native environment, stack, runtime, compiler.
use Native;
"static method get_current_stack : Native::Stack ();"
Returns the current execution stack.
"static get_current_env : Native::Env ();"
Returns the current execution environemnt.
"static method get_current_runtime : Native::Runtime ();"
Returns the current runtime.
"static method get_current_compiler : Native::Compiler ();"
Returns the current compiler.
"static method check_bootstrap_method : void ($basic_type_name : string);"
Check the bootstrap method in the basic type $basic_type_name.
"static method use : void (static method use : void ($class_name : string, $file : string = undef, $line : int = −1));"
Compiles the class $class_name using the compiler of the current runtime.
"static method use_anon_class : string ($source : string, $file : string = undef, $line : int = −1);"
Compiles the anon class source $source using the compiler of the current runtime.
"static method eval : object ($eval_source : string);"
This method emulates Perl's string eval <https://perldoc.perl.org/functions/eval#String-eval>.
This method creates the following source code.
"
class {
static method eval : object () {
#line 1
$eval_source
}
}
"
And calls "compile_anon_class" given this source code and gets the anon class name.
And calls call_class_method in the Native::MethodCall class.
Native::MethodCall−>call_class_method($anon_class_name, "eval");
Examples:
my $value =
(Int)Native−>eval("my $total = 1 + 2; return
$total;");
say $value−>value;
"static method inc : string[] ();"
Returns the current serach directories of the class search directories of the compiler of the current runtime.
"static method set_inc : void ($include_dirs : string[]);"
Set the current serach directories $include_dirs to the class search directories of the compiler of the current runtime.
"static method push_inc : void ($include_dir : string);"
Add the class search directory $include_dir at the tail of the class search directories of the compiler of the current runtime.
"static method unshift_inc : void ($include_dir : string);"
Add the class search directory $include_dir at the head of the class search directories of the compiler of the current runtime.
Copyright (c) 2023 Yuki Kimoto
MIT License