module.h
Include dependency graph for module.h:
This graph shows which files directly or indirectly include module.h:
Module loading functions.
This header defines all the module loading functions and the Module struct.
Defines
-
SMP_MODULE_LOCK(mod) smp_mutex_lock(mod->mutex)
-
SMP_MODULE_UNLOCK(mod) smp_mutex_unlock(mod->mutex)
Enums
Functions
-
size_t module_get_exported_functions_count(Module *this_module)
Count exported functions of a given module.
Get the number of exported functions. This function is used to compute the required heap size of the list of exported functions.
- Parameters:
this_module – the module to count exported functions of
- Returns:
the number of exported functions
-
uint32_t module_search_exported_function(Module *this_module, AtomString func_name, int func_arity, GlobalContext *glb)
Gets exported function index by searching it by function name and arity.
Gets exported function index by searching it by function name and arity
- Parameters:
this_module – the module on which the function will be searched.
func_name – function name atom string.
func_arity – function arity.
glb – the global context
-
static inline size_t module_get_exported_functions_list_size(Module *this_module)
Determine heap size of exported functions list.
- Parameters:
this_module – the module to count exported functions of
- Returns:
the size, in terms, of the exported function list
-
term module_get_exported_functions(Module *this_module, Heap *heap, GlobalContext *global)
Get the list of exported functions.
Create a list of exported functions of the form
{FunctionName, Arity}
To create this list, the heap must be grown bymodule_get_exported_functions_list_size
terms.- Parameters:
this_module – the module to count exported functions of
heap – heap to allocate tuples
global – global context to fetch atoms
- Returns:
a list of exported functions
-
Module *module_new_from_iff_binary(GlobalContext *global, const void *iff_binary, unsigned long size)
Parse a BEAM file and returns a Module.
Parse a BEAM file a returns a newly allocated and initialized Module struct.
- Parameters:
global – the global context.
iff_binary – the IFF file data.
size – the size of the buffer containing the IFF data.
-
term module_load_literal(Module *mod, int index, Context *ctx)
Gets a literal stored on the literal table of the specified module.
Loads and deserialize a term stored in the literal table and returns a term.
- Parameters:
mod – The module that owns that is going to be loaded.
index – a valid literal index.
ctx – the target context.
-
static inline AtomString module_get_atom_string_by_id(const Module *mod, int local_atom_id, GlobalContext *glb)
Gets the AtomString for the given local atom id.
Gets an AtomString for the given local atom id from the global table.
- Parameters:
mod – the module that owns the atom.
local_atom_id – module atom table index.
glb – the global context.
- Returns:
the AtomString for the given module atom index.
-
static inline term module_get_atom_term_by_id(const Module *mod, int local_atom_id)
Gets a term for the given local atom id.
Gets the global atom id for the the given local atom id and casts it to a term.
- Parameters:
mod – the module that owns the atom.
local_atom_id – module atom table index.
- Returns:
a term for the given module atom index.
-
const struct ExportedFunction *module_resolve_function0(Module *mod, int import_table_index, struct UnresolvedFunctionCall *unresolved, GlobalContext *glb)
-
static inline term module_get_name(const Module *mod)
Get the module name, as an atom term.
- Parameters:
mod – the module to get the name of
- Returns:
a term for the given module atom index.
-
static inline const struct ExportedFunction *module_resolve_function(Module *mod, int import_table_index, GlobalContext *glb)
Resolves an unresolved function reference.
Resolves an unresolved function reference and it replaces the unresolved reference with a ModuleFunction struct, also it loads the referenced module if it hasn’t been loaded yet.
- Parameters:
mod – the module containing the function to resolve.
import_table_index – the unresolved function index.
glb – the global context
-
static inline void module_get_fun(const Module *this_module, int fun_index, uint32_t *label, uint32_t *arity, uint32_t *n_freeze)
-
bool module_get_function_from_label(Module *this_module, int label, AtomString *function_name, int *arity, GlobalContext *glb)
-
void module_insert_line_ref_offset(Module *mod, int line_ref, int offset)
-
int module_find_line(Module *mod, unsigned int offset)
-
struct __attribute__
- #include <module.h>
-
struct LiteralEntry
- #include <module.h>
-
struct ModuleFilename
- #include <module.h>
-
struct LineRefOffset
- #include <module.h>
Collaboration diagram for LineRefOffset:
-
struct Module
- #include <module.h>
Collaboration diagram for Module:
Public Members
-
CodeChunk *code
-
void *export_table
-
void *local_table
-
void *atom_table
-
void *fun_table
-
void *str_table
-
size_t str_table_len
-
uint16_t *line_refs
-
struct ModuleFilename *filenames
-
const struct ExportedFunction **imported_funcs
-
const uint8_t **labels
-
void *literals_data
-
struct LiteralEntry *literals_table
-
int *local_atoms_to_global_table
-
void *module_platform_data
-
int module_index
-
int end_instruction_ii
-
unsigned int free_literals_data
-
CodeChunk *code