module.c
Include dependency graph for module.c:
Defines
-
LITT_UNCOMPRESSED_SIZE_OFFSET 8
-
LITT_HEADER_SIZE 12
-
CHECK_FREE_SPACE(space, error)
if ((size_t) ((pos + space) - data) > len) { \
fprintf(stderr, error); \
return; \
}
-
IMPL_CODE_LOADER 1
Functions
-
static bool module_are_literals_compressed(const uint8_t *litT)
-
static struct LiteralEntry *module_build_literals_table(const void *literalsBuf)
-
static enum ModuleLoadResult module_build_imported_functions_table(Module *this_module, uint8_t *table_data, GlobalContext *glb)
-
static enum ModuleLoadResult module_populate_atoms_table(Module *this_module, uint8_t *table_data, GlobalContext *glb)
-
void module_get_imported_function_module_and_name(const Module *this_module, int index, AtomString *module_atom, AtomString *function_atom, GlobalContext *glb)
Gets imported function module and name.
Gets imported function module and name given its import table index.
- Parameters:
this_module – the module on which the function will be searched.
index – the modules import table offset to begin searching.
module_atom – module name atom string.
function_atom – function name atom string.
-
bool module_get_function_from_label(Module *this_module, int label, AtomString *function_name, int *arity, GlobalContext *glb)
-
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
-
term module_get_exported_functions(Module *this_module, Heap *heap, GlobalContext *glb)
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.
-
const struct ExportedFunction *module_resolve_function0(Module *mod, int import_table_index, struct UnresolvedFunctionCall *unresolved, GlobalContext *glb)
-
static bool module_get_line_ref(Module *mod, uint16_t line_ref, uint32_t *out_line, uint16_t *out_location)
-
static bool module_get_location(Module *mod, uint16_t location_ix, size_t *filename_len, const uint8_t **filename)