Name

SPVM::Document::NativeAPI::Compiler - Compiler Native APIs

Usage

void* compiler = env->api->compiler->new_instance();

env->api->compiler->add_include_dir(compiler, "lib");

env->api->compiler->set_start_file(compiler, __FILE__);
env->api->compiler->get_start_line(compiler, __LINE__ + 1);
int32_t status = env->api->compiler->compile(compiler, "MyClass");

env->api->compiler->free_instance(compiler);

Description

The compiler native APIs of SPVM are the APIs to compile SPVM modules.

Compiler Native APIs

new_instance

void* (*new_instance)(void);

Creates a compiler object.

free_instance

void (*free_instance)(void* compiler);

Frees a compiler.

get_start_line

int32_t (*get_start_line)(void* compiler);

Gets the start line.

set_start_line

void (*set_start_line)(void* compiler, int32_t start_line);

Sets a start line.

get_start_file

const char* (*get_start_file)(void* compiler);

Gets the start file.

set_start_file

void (*set_start_file)(void* compiler, const char* start_file);

Set a start file.

get_include_dirs_length

int32_t (*get_include_dirs_length)(void* compiler);

Gets the length of the directories for searching modules.

get_include_dir

const char* (*get_include_dir)(void* compiler, int32_t index);

Gets a directory for searching modules by an index.

add_include_dir

void (*add_include_dir)(void* compiler, const char* include_dir);

Adds a directory for searching modules.

clear_include_dirs

void (*clear_include_dirs)(SPVM_COMPILER* compiler);

Clears the directories for searching modules.

add_class_file

void (*add_class_file)(void* compiler, const char* class_name);

Adds a class file object for a module.

If the class file already exists, nothing is performed.

delete_class_file

void (*delete_class_file)(void* compiler, const char* class_name);

Deletes a class file object for a module.

get_class_file

void* (*get_class_file)(void* compiler, const char* class_name);

Gets the class file object for a module.

compile

int32_t (*compile)(void* compiler, const char* class_name);

Compiles SPVM modules.

get_error_messages_length

int32_t (*get_error_messages_length)(void* compiler);

Gets the length of the compilation error messages.

get_error_message

const char* (*get_error_message)(void* compiler, int32_t index);

Gets a compiler error message by an index.

get_runtime

void* (*get_runtime)(void* compiler);

Gets the runtime.

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

Copyright & License

Copyright (c) 2023 Yuki Kimoto

MIT License