SPVM::D...Compiler(3)
π Name π
okay so this is the SPVM::Document::NativeAPI::Compiler(3) page from the User Contributed Perl Documentation β and it's literally all about the Compiler Native APIs π
β¨
πΈ Usage πΈ
SPVM_API_COMPILER* api_compiler = env->api->compiler;
void* compiler = api_compiler->new_instance();
api_compiler->add_include_dir(compiler, "lib");
api_compiler->set_start_file(compiler, __FILE__);
api_compiler->get_start_line(compiler, __LINE__ + 1);
int32_t status = api_compiler->compile(compiler, "MyClass");
api_compiler->free_instance(compiler);
π¦ Description π¦
The compiler native APIs in SPVM are the APIs for SPVM compilers. That's the whole vibe β compiler native APIs, for SPVM compilers, no cap.
π Compiler Native APIs π
okay bestie, here's the full roster in order β no skips, no gaps, we're doing all of them π«Ά
π new_instance π
"void* (*new_instance)(void);"
Creates a new compiler and returns it. New compiler energy β¨
π free_instance π
"void (*free_instance)(void* compiler);"
Frees the compiler compiler. (The original says "Frees the compiler compiler" β iconic little echo, but yes, free that compiler π)
π get_start_line π
"int32_t (*get_start_line)(void* compiler);"
Returns the value of the "start_line" field. The starting line for an exception call stack is stored to this field. Line tracking core π
π set_start_line π
"void (*set_start_line)(void* compiler, int32_t start_line);"
Sets start_line to the "start_line" field. yep, that's the assignment vibe π
π get_start_file π
"const char* (*get_start_file)(void* compiler);"
Returns the value of the "start_file" field. The starting file path for an exception call stack is stored to this field. File path main character energy π
π set_start_file π
"void (*set_start_file)(void* compiler, const char* start_file);"
Sets start_file to the "start_file" field. periodt π
π get_include_dirs_length π
"int32_t (*get_include_dirs_length)(void* compiler);"
Returns the length of the class search directories. Length check slay π
π get_include_dir π
"const char* (*get_include_dir)(void* compiler, int32_t index);"
Searches a class search directory given the index index (yes, index index β iconic).
If it is found, returns it. Otherwise, returns "NULL". NULL is the fallback queen π
π add_include_dir π
"void (*add_include_dir)(void* compiler, const char* include_dir);"
Adds include_dir at the end of the class search directories. append era π₯
π clear_include_dirs π
"void (*clear_include_dirs)(SPVM_COMPILER* compiler);"
Removes all class search directories. clean sweep π§
π add_class_file π
"void (*add_class_file)(void* compiler, const char* class_name);"
Creates the class file for the class given by class_name, and adds it to the symbol table of the compiler compiler.
If the class file already exists, nothing is performed. no duplicate drama, we love that π
π delete_class_file π
"void (*delete_class_file)(void* compiler, const char* class_name);"
Removes the class file for the class given by the class name class_name. delete delete delete π
π get_class_file π
"void* (*get_class_file)(void* compiler, const char* class_name);"
Returns the class file for the class given by the class name class_name. class file retrieval moment π¦
π compile π
"int32_t (*compile)(void* compiler, const char* class_name);"
Compiles the SPVM class given by the class name class_name. Classes loaded by the class and classes subsequently loaded are also compiled.
The runtime is build. (Not me fixing the grammar β that's literally what the page says, and the meaning is the runtime is built π)
If the compilation is successful, returns 0. Otherwise, returns a non-zero value.
This native API can be called repeatedly to compile other classes. reusable compile energy β¨
π get_error_messages_length π
"int32_t (*get_error_messages_length)(void* compiler);"
Returns the length of the compilation error messages. error message count check π
π get_error_message π
"const char* (*get_error_message)(void* compiler, int32_t index);"
Searches the compiler error message given the index index.
If it is found, returns it. Otherwise, returns "NULL". NULL again, consistent icon π
π get_runtime π
"void* (*get_runtime)(void* compiler);"
Returns the runtime that is build by the compiler compiler. runtime reveal πΈ
π prepend_include_dir π
"void (*prepend_include_dir)(void* compiler, const char* include_dir);"
Prepends include_dir to the class search directory. note: singular directory here β keeping it exactly as the page says π«Ά
π compile_anon_class π
"int32_t (*compile_anon_class)(void* compiler, const char* source, const char** anon_basic_type_name_ptr);"
Compiles an SPVM anon class given the source code source. Classes loaded by the class and classes subsequently loaded are also compiled.
The runtime is build.
If the compilation is successful, returns 0. Otherwise, returns a non-zero value.
The generated anon class name is set to the value referenced by anon_basic_type_name_ptr.
This native API can be called repeatedly to compile other classes.
Examples:
const char* source = "
class {
use Fn;
static method main : void () {
my $var = 1;
say $var;
}
}
";
π compile_script π
"int32_t (*compile_script)(void* compiler, const char* source, const char** anon_basic_type_name_ptr);"
Same as "compile_anon_class" β literally same energy, same behavior π
Examples:
const char* source = "
use Fn;
my $var = 1;
say $var;
";
π Native API IDs π
0 new_instance
1 free_instance
2 get_start_line
3 set_start_line
4 get_start_file
5 set_start_file
6 get_include_dirs_length
7 get_include_dir
8 add_include_dir
9 clear_include_dirs
10 add_class_file
11 delete_class_file
12 get_class_file
13 compile
14 get_error_message
15 get_error_messages_length
16 get_runtime
17 prepend_include_dir
18 compile_anon_class
19 compile_script
π«Ά See Also π«Ά
SPVM::Document::NativeAPISPVM::Document::NativeAPI::ClassFileSPVM::Document::NativeAPI::RuntimeSPVM::Document::NativeClassSPVM::Document
π Copyright & License π
Copyright (c) 2023 Yuki Kimoto
MIT License
that's the whole manual page, bestie β source/version: perl v5.42.2; date: 2026-02-03. bye and slay π
β¨
π¦ where this page comes from
- alpine 3.24: spvm-doc 0.990125-r0 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms