SPVM::Document::NativeAPI::Compiler - Compiler Native APIs
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);
The compiler native APIs in SPVM are the APIs for SPVM compilers.
void* (*new_instance)(void);
Creates a new compiler and returns it.
void (*free_instance)(void* compiler);
Frees the compiler compiler.
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.
start_line
void (*set_start_line)(void* compiler, int32_t start_line);
Sets start_line to the start_line field.
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.
start_file
void (*set_start_file)(void* compiler, const char* start_file);
Sets start_file to the start_file field.
int32_t (*get_include_dirs_length)(void* compiler);
Returns the length of the class search directories.
const char* (*get_include_dir)(void* compiler, int32_t index);
Searches a class search directory given the index index.
If it is found, returns it, otherwise returns NULL.
NULL
void (*add_include_dir)(void* compiler, const char* include_dir);
Adds include_dir at the end of the class search directories.
void (*clear_include_dirs)(SPVM_COMPILER* compiler);
Removes all class search directories.
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.
void (*delete_class_file)(void* compiler, const char* class_name);
Removes the class file for the class given by the class name class_name.
void* (*get_class_file)(void* compiler, const char* class_name);
Returns the class file for the class given by the class name class_name.
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.
If the compilation is successful, returns 0, otherwise returns a non-zero value.
This native API can be called repeatedly to compile other classes.
int32_t (*get_error_messages_length)(void* compiler);
Returns the length of the compilation error messages.
const char* (*get_error_message)(void* compiler, int32_t index);
Searches the compiler error message given the index index.
void* (*get_runtime)(void* compiler);
Returns the runtime that is build by the compiler compiler.
void (*prepend_include_dir)(void* compiler, const char* include_dir);
Prepends include_dir to the class search directory.
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 generated anon class name is set to the value referenced by anon_basic_type_name_ptr.
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
SPVM::Document::NativeAPI
SPVM::Document::NativeAPI::ClassFile
SPVM::Document::NativeAPI::Runtime
SPVM::Document::NativeClass
SPVM::Document
Copyright (c) 2023 Yuki Kimoto
MIT License
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.