The modules keep track of which file an item originates from for error reporting, or tracks resources such as open shared libraries.
|
| REDUCT_API void | reduct_module_global_init (reduct_module_global_t *global) |
| | Initialize the global module state.
|
| |
| REDUCT_API void | reduct_module_global_deinit (reduct_module_global_t *global) |
| | Deinitialize the global module state.
|
| |
| REDUCT_API reduct_module_t * | reduct_module_new (struct reduct *reduct, const char *buffer, size_t length, const char *path, reduct_module_flags_t flags) |
| | Create a new module to track a buffer.
|
| |
| REDUCT_API reduct_module_t * | reduct_module_lookup (struct reduct *reduct, reduct_module_id_t id) |
| | Lookup a module structure by its ID.
|
| |
| REDUCT_API void | reduct_module_add_path (struct reduct *reduct, const char *path) |
| | Add a path to search when importing modules.
|
| |
| REDUCT_API void | reduct_module_resolve_path (struct reduct *reduct, const char *path, size_t pathLen, char *outPath, size_t maxLen, bool checkExistence) |
| | Resolve a path relative to the current execution frame or import paths.
|
| |
| REDUCT_API reduct_handle_t | reduct_module_import (struct reduct *reduct, reduct_handle_t path, reduct_handle_t compiler, reduct_handle_t compilerArgs) |
| | Import a module from a given path.
|
| |
◆ REDUCT_MODULE_ENTRY
| #define REDUCT_MODULE_ENTRY "reduct_module_init" |
The name of the entry symbol for a Reduct module.
Definition at line 26 of file module.h.
◆ REDUCT_MODULE_PATHS_INITIAL
| #define REDUCT_MODULE_PATHS_INITIAL 4 |
Initial size of the module path array.
Definition at line 28 of file module.h.
◆ REDUCT_MODULE_PATHS_GROWTH
| #define REDUCT_MODULE_PATHS_GROWTH 2 |
Growth factor of the module path array.
Definition at line 29 of file module.h.
◆ REDUCT_MODULE_ID_NONE
Invalid handle value.
Definition at line 41 of file module.h.
◆ reduct_module_init_fn
Module initialization function type.
Definition at line 24 of file module.h.
◆ reduct_module_id_t
◆ reduct_module_flags_t
| Enumerator |
|---|
| REDUCT_MODULE_FLAG_NONE | |
| REDUCT_MODULE_FLAG_BUFFER_OWNED | The buffer is owned by the module structure and should be freed.
|
| REDUCT_MODULE_FLAG_IS_LIBRARY | The module is a loaded shared library.
|
Definition at line 47 of file module.h.
◆ reduct_module_global_init()
Initialize the global module state.
- Parameters
-
| global | Pointer to the global module state structure. |
◆ reduct_module_global_deinit()
Deinitialize the global module state.
- Parameters
-
| global | Pointer to the global module state structure. |
◆ reduct_module_new()
Create a new module to track a buffer.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| buffer | The input buffer containing source code. |
| length | The length of the input buffer. |
| path | The path to the input file (for error reporting and relative imports). |
| flags | Input flags (e.g., REDUCT_MODULE_FLAG_BUFFER_OWNED). |
- Returns
- A pointer to the newly created module structure.
◆ reduct_module_lookup()
Lookup a module structure by its ID.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| id | The ID of the module structure. |
- Returns
- A pointer to the module structure, or NULL if not found.
◆ reduct_module_add_path()
| REDUCT_API void reduct_module_add_path |
( |
struct reduct * |
reduct, |
|
|
const char * |
path |
|
) |
| |
Add a path to search when importing modules.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| path | The directory path, will be copied. |
◆ reduct_module_resolve_path()
| REDUCT_API void reduct_module_resolve_path |
( |
struct reduct * |
reduct, |
|
|
const char * |
path, |
|
|
size_t |
pathLen, |
|
|
char * |
outPath, |
|
|
size_t |
maxLen, |
|
|
bool |
checkExistence |
|
) |
| |
Resolve a path relative to the current execution frame or import paths.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| path | The path string to resolve. |
| pathLen | The length of the path string. |
| outPath | Pointer to the buffer where the resolved path will be stored. |
| maxLen | The maximum length of the output buffer. |
| checkExistence | Whether to check if the file exists when resolving relative paths. |
◆ reduct_module_import()
Import a module from a given path.
- Parameters
-
| reduct | Pointer to the Reduct structure. |
| path | The path to the module file. |
| compiler | Handle to an atom storing the name of the compiler to use. |
| compilerArgs | Handle to an atom storing the compiler arguments. |
- Returns
- A handle to the root of the parsed module AST.