SPVM::Native(3)

πŸ“¦ version 0.990125, in alpine 3.24

πŸ’… SPVM::Native πŸ’…

okay so bestie, welcome to SPVM::Native(3) β€” it's part of the User Contributed Perl Documentation and honestly? it's giving control room energy. This is the class that lets you reach out and grab the current native environment, stack, runtime, and compiler. iykyk πŸŽ€


✨ Name ✨

SPVM::Native β€” the class for getting the current native environment, stack, runtime, and compiler. no cap, that's the whole vibe. πŸ¦‹


🌸 Description 🌸

So the Native class of SPVM is the plug πŸ’…. It's got methods to get the current native environment, the stack, the runtime, and the compiler. literally the main character of "what's going on right now" energy. πŸ‘‘


πŸŽ€ Usage πŸŽ€

use Native;

that's it. that's the whole ritual. 🫢


πŸ’– Class Methods πŸ’–

⭐ get_current_stack

static method get_current_stack : Native::Stack ();

Returns the current execution stack. the receipts, basically. 🧾

⭐ get_current_env

static get_current_env : Native::Env ();

Returns the current execution environemnt. (yes bestie, the manpage really spells it "environemnt" β€” we do not fix, we respect the source πŸ’€)

⭐ get_current_runtime

static method get_current_runtime : Native::Runtime ();

Returns the current runtime. the whole engine room. πŸ”₯

⭐ get_current_compiler

static method get_current_compiler : Native::Compiler ();

Returns the current compiler. the one doing all the actual thinking. 🧚

⭐ check_bootstrap_method

static method check_bootstrap_method : void ($basic_type_name :
string);

Check the bootstrap method in the basic type $basic_type_name. like a vibe check but for bootstrap methods. βœ…

⭐ use

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. that's the whole thing. slay. ✨

⭐ use_anon_class

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. anonymous but make it iconic. 🎭

⭐ eval

static method eval : object ($eval_source : string);

This method emulates Perl's string eval <https://perldoc.perl.org/functions/eval#String-eval>. (yes, the link is literally in the docs, we keep it, we respect it 🫑)

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;

lowkey obsessed with the fact that you can just. eval a string. in SPVM. from Perl. πŸ™ˆ

⭐ inc

static method inc : string[] ();

Returns the current serach directories of the class search directories of the compiler of the current runtime. (again β€” "serach" is exactly what the docs say, we are not correcting it, periodt πŸ’…)

⭐ set_inc

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. full replacement, no leftovers. πŸ”„

⭐ push_inc

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. goes to the back of the line, respectfully. πŸšΆβ€β™€οΈ

⭐ unshift_inc

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. cuts the line, but make it legal. πŸ‘‘


Copyright (c) 2023 Yuki Kimoto

MIT License


and that's the tea, bestie πŸ“ β€” this page was served up as SPVM::Native(3) from perl v5.42.2, dated 2026-02-03. go forth and get your current native environment. πŸ’œπŸ¦‹βœ¨

πŸ“¦ where this page comes from