|
Loom C API
Public Loom compiler C API
|
Opaque in-memory Loom modules. More...
Go to the source code of this file.
Data Structures | |
| struct | loomc_module_function_t |
| Function metadata view written into caller-provided storage. More... | |
| struct | loomc_module_function_export_info_t |
| Export metadata view written into caller-provided storage. More... | |
| struct | loomc_module_function_query_options_t |
| Module function query options. More... | |
| struct | loomc_module_global_t |
| Global metadata view written into caller-provided storage. More... | |
| struct | loomc_module_global_query_options_t |
| Module global query options. More... | |
| struct | loomc_module_serialize_options_t |
| Module serialization options. More... | |
| struct | loomc_module_deserialize_options_t |
| Module deserialization options. More... | |
Typedefs | |
| typedef struct loomc_module_t | loomc_module_t |
| Opaque parsed, linked, optimized, or lowered module. | |
| typedef uint32_t | loomc_module_function_flags_t |
| Bitmask of loomc_module_function_flag_bits_t values. | |
| typedef uint32_t | loomc_module_function_export_flags_t |
| Bitmask of loomc_module_function_export_flag_bits_t values. | |
| typedef uint32_t | loomc_module_global_flags_t |
| Bitmask of loomc_module_global_flag_bits_t values. | |
Functions | |
| void | loomc_module_retain (loomc_module_t *module) |
| Retains an opaque module for another owner. | |
| void | loomc_module_release (loomc_module_t *module) |
| Releases an opaque module from one owner. | |
| loomc_status_t | loomc_module_clone (const loomc_module_t *source_module, loomc_workspace_t *workspace, loomc_allocator_t allocator, loomc_module_t **out_module) |
| Clones a module into workspace-backed mutable storage. | |
| loomc_status_t | loomc_module_query_functions (const loomc_module_t *module, const loomc_module_function_query_options_t *options, loomc_allocator_t allocator, loomc_host_size_t function_capacity, loomc_module_function_t *out_functions, loomc_host_size_t *out_function_count, loomc_result_t **out_result) |
| Queries function metadata from a module. | |
| loomc_status_t | loomc_module_query_globals (const loomc_module_t *module, const loomc_module_global_query_options_t *options, loomc_allocator_t allocator, loomc_host_size_t global_capacity, loomc_module_global_t *out_globals, loomc_host_size_t *out_global_count, loomc_result_t **out_result) |
| Queries global metadata from a module. | |
| bool | loomc_module_try_get_function_at (const loomc_module_t *module, loomc_host_size_t function_ordinal, loomc_module_function_t *out_function) |
| Tries to get function metadata by public function ordinal without allocating a status. | |
| loomc_status_t | loomc_module_get_function_at (const loomc_module_t *module, loomc_host_size_t function_ordinal, loomc_module_function_t *out_function) |
| Gets function metadata by public function ordinal. | |
| bool | loomc_module_try_lookup_function (const loomc_module_t *module, loomc_string_view_t symbol_name, loomc_module_function_t *out_function) |
| Looks up one function by symbol name without allocating a status. | |
| loomc_status_t | loomc_module_lookup_function (const loomc_module_t *module, loomc_string_view_t symbol_name, loomc_module_function_t *out_function) |
| Looks up one function by symbol name. | |
| bool | loomc_module_try_get_global_at (const loomc_module_t *module, loomc_host_size_t global_ordinal, loomc_module_global_t *out_global) |
| Tries to get global metadata by global ordinal without allocating a status. | |
| loomc_status_t | loomc_module_get_global_at (const loomc_module_t *module, loomc_host_size_t global_ordinal, loomc_module_global_t *out_global) |
| Gets global metadata by global ordinal. | |
| bool | loomc_module_try_lookup_global (const loomc_module_t *module, loomc_string_view_t symbol_name, loomc_module_global_t *out_global) |
| Looks up one global by symbol name without allocating a status. | |
| loomc_status_t | loomc_module_lookup_global (const loomc_module_t *module, loomc_string_view_t symbol_name, loomc_module_global_t *out_global) |
| Looks up one global by symbol name. | |
| bool | loomc_module_function_try_get_export_info_at (const loomc_module_t *module, loomc_host_size_t function_ordinal, loomc_module_function_export_info_t *out_info) |
| Tries to get export metadata by public function ordinal without allocating a status. | |
| loomc_status_t | loomc_module_function_get_export_info_at (const loomc_module_t *module, loomc_host_size_t function_ordinal, loomc_module_function_export_info_t *out_info) |
| Gets export metadata by public function ordinal. | |
| bool | loomc_module_function_try_get_export_info (const loomc_module_t *module, const loomc_module_function_t *function, loomc_module_function_export_info_t *out_info) |
| Tries to get export metadata for a function without allocating a status. | |
| loomc_status_t | loomc_module_function_get_export_info (const loomc_module_t *module, const loomc_module_function_t *function, loomc_module_function_export_info_t *out_info) |
| Gets export metadata for a function. | |
| loomc_status_t | loomc_module_serialize_to_source (const loomc_module_t *module, const loomc_module_serialize_options_t *options, loomc_allocator_t allocator, loomc_source_t **out_source) |
| Serializes a module into an immutable source handle. | |
| loomc_status_t | loomc_module_serialize_to_file (const loomc_module_t *module, const loomc_module_serialize_options_t *options, FILE *file) |
| Serializes a module to an open C FILE*. | |
| loomc_status_t | loomc_module_serialize_to_path (const loomc_module_t *module, const loomc_module_serialize_options_t *options, loomc_string_view_t path, loomc_allocator_t allocator) |
| Serializes a module to a filesystem path. | |
| loomc_status_t | loomc_module_deserialize_from_source (loomc_context_t *context, loomc_workspace_t *workspace, const loomc_source_t *source, const loomc_module_deserialize_options_t *options, loomc_allocator_t allocator, loomc_module_t **out_module, loomc_result_t **out_result) |
| Deserializes an immutable source handle into an owned mutable module. | |
| loomc_status_t | loomc_module_deserialize_from_file (loomc_context_t *context, loomc_workspace_t *workspace, FILE *file, const loomc_module_deserialize_options_t *options, loomc_allocator_t allocator, loomc_module_t **out_module, loomc_result_t **out_result) |
| Deserializes bytes from an open C FILE* into a module. | |
| loomc_status_t | loomc_module_deserialize_from_path (loomc_context_t *context, loomc_workspace_t *workspace, loomc_string_view_t path, const loomc_module_deserialize_options_t *options, loomc_allocator_t allocator, loomc_module_t **out_module, loomc_result_t **out_result) |
| Deserializes bytes from a filesystem path into a module. | |
Opaque in-memory Loom modules.
Modules are the typed handoff between parsing, linking, optimization, and compilation. They let embedders compose API operations without printing and reparsing .loom text on the hot path. Serialization is the boundary that turns a module back into text or bytecode bytes for storage, display, cache keys, or handoff to systems that consume sources. Deserialization is the inverse boundary that turns text or bytecode bytes into a mutable module handle allocated from a caller-provided workspace.
| typedef struct loomc_module_t loomc_module_t |
Opaque parsed, linked, optimized, or lowered module.
Modules use arena storage from the workspace that created, linked, cloned, or deserialized them. Releasing a module returns its active arena blocks to that workspace. A module retains the workspace, so release ordering is memory-safe, but keeping modules live across loomc_workspace_trim keeps their storage live too.
Export metadata flag bits.
| Enumerator | |
|---|---|
| LOOMC_MODULE_FUNCTION_EXPORT_FLAG_HAS_SYMBOL | loomc_module_function_export_info_t::export_symbol is present. |
Module function metadata flag bits.
| Enumerator | |
|---|---|
| LOOMC_MODULE_FUNCTION_FLAG_PUBLIC | Function symbol is visible outside the module for linking. |
| LOOMC_MODULE_FUNCTION_FLAG_HAS_EXPORT_INFO | loomc_module_function_try_get_export_info can return export metadata. |
Public function category reported from a module query.
Text presentation policy used when serializing .loom text.
| loomc_status_t loomc_module_clone | ( | const loomc_module_t * | source_module, |
| loomc_workspace_t * | workspace, | ||
| loomc_allocator_t | allocator, | ||
| loomc_module_t ** | out_module ) |
Clones a module into workspace-backed mutable storage.
| source_module | Module to clone. The source is read-only during this operation. |
| workspace | Workspace used to allocate the cloned module's IR storage. |
| allocator | Host allocator used for the returned module handle. |
| out_module | Receives the cloned module on success. |
| loomc_status_t loomc_module_deserialize_from_file | ( | loomc_context_t * | context, |
| loomc_workspace_t * | workspace, | ||
| FILE * | file, | ||
| const loomc_module_deserialize_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_module_t ** | out_module, | ||
| loomc_result_t ** | out_result ) |
Deserializes bytes from an open C FILE* into a module.
| context | Context used to resolve Loom dialect and bytecode metadata. |
| workspace | Workspace used to allocate module IR storage. |
| file | Open readable file handle. Bytes are read from the current file position to EOF. |
| options | Deserialization options. NULL infers format from bytes. |
| allocator | Host allocator used for module handle storage and temporary input bytes. |
| out_module | Receives a retained module when the result succeeds. Receives NULL when the result fails. |
| out_result | Receives a retained result for the operation. |
| loomc_status_t loomc_module_deserialize_from_path | ( | loomc_context_t * | context, |
| loomc_workspace_t * | workspace, | ||
| loomc_string_view_t | path, | ||
| const loomc_module_deserialize_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_module_t ** | out_module, | ||
| loomc_result_t ** | out_result ) |
Deserializes bytes from a filesystem path into a module.
| context | Context used to resolve Loom dialect and bytecode metadata. |
| workspace | Workspace used to allocate module IR storage. |
| path | Input file path. The path is a borrowed byte view and does not need to be NUL-terminated. |
| options | Deserialization options. NULL infers format from bytes. |
| allocator | Host allocator used for module handle storage and temporary input bytes. |
| out_module | Receives a retained module when the result succeeds. Receives NULL when the result fails. |
| out_result | Receives a retained result for the operation. |
| loomc_status_t loomc_module_deserialize_from_source | ( | loomc_context_t * | context, |
| loomc_workspace_t * | workspace, | ||
| const loomc_source_t * | source, | ||
| const loomc_module_deserialize_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_module_t ** | out_module, | ||
| loomc_result_t ** | out_result ) |
Deserializes an immutable source handle into an owned mutable module.
| context | Context used to resolve Loom dialect and bytecode metadata. |
| workspace | Workspace used to allocate module IR storage. |
| source | Source bytes to deserialize. |
| options | Deserialization options. NULL infers format from source. |
| allocator | Host allocator used for module handle storage. |
| out_module | Receives a retained module when the result succeeds. Receives NULL when the result fails. |
| out_result | Receives a retained result for the operation. |
| loomc_status_t loomc_module_function_get_export_info | ( | const loomc_module_t * | module, |
| const loomc_module_function_t * | function, | ||
| loomc_module_function_export_info_t * | out_info ) |
Gets export metadata for a function.
| module | Module that produced function. |
| function | Function metadata from module. |
| out_info | Receives export metadata. |
| loomc_status_t loomc_module_function_get_export_info_at | ( | const loomc_module_t * | module, |
| loomc_host_size_t | function_ordinal, | ||
| loomc_module_function_export_info_t * | out_info ) |
Gets export metadata by public function ordinal.
| module | Module to inspect. |
| function_ordinal | Ordinal in the module's unfiltered function metadata sequence. |
| out_info | Receives export metadata. |
| bool loomc_module_function_try_get_export_info | ( | const loomc_module_t * | module, |
| const loomc_module_function_t * | function, | ||
| loomc_module_function_export_info_t * | out_info ) |
Tries to get export metadata for a function without allocating a status.
| module | Module that produced function. |
| function | Function metadata from module. |
| out_info | Receives export metadata when available. |
| bool loomc_module_function_try_get_export_info_at | ( | const loomc_module_t * | module, |
| loomc_host_size_t | function_ordinal, | ||
| loomc_module_function_export_info_t * | out_info ) |
Tries to get export metadata by public function ordinal without allocating a status.
| module | Module to inspect. |
| function_ordinal | Ordinal in the module's unfiltered function metadata sequence. |
| out_info | Receives export metadata when available. |
| loomc_status_t loomc_module_get_function_at | ( | const loomc_module_t * | module, |
| loomc_host_size_t | function_ordinal, | ||
| loomc_module_function_t * | out_function ) |
Gets function metadata by public function ordinal.
| module | Module to inspect. |
| function_ordinal | Ordinal in the module's unfiltered function metadata sequence. |
| out_function | Receives function metadata. |
| loomc_status_t loomc_module_get_global_at | ( | const loomc_module_t * | module, |
| loomc_host_size_t | global_ordinal, | ||
| loomc_module_global_t * | out_global ) |
Gets global metadata by global ordinal.
| module | Module to inspect. |
| global_ordinal | Ordinal in the module's unfiltered global metadata sequence. |
| out_global | Receives global metadata. |
| loomc_status_t loomc_module_lookup_function | ( | const loomc_module_t * | module, |
| loomc_string_view_t | symbol_name, | ||
| loomc_module_function_t * | out_function ) |
Looks up one function by symbol name.
| module | Module to inspect. |
| symbol_name | Function symbol name, with or without a leading @. |
| out_function | Receives function metadata when the lookup succeeds. |
| loomc_status_t loomc_module_lookup_global | ( | const loomc_module_t * | module, |
| loomc_string_view_t | symbol_name, | ||
| loomc_module_global_t * | out_global ) |
Looks up one global by symbol name.
| module | Module to inspect. |
| symbol_name | Global symbol name, with or without a leading @. |
| out_global | Receives global metadata when the lookup succeeds. |
| loomc_status_t loomc_module_query_functions | ( | const loomc_module_t * | module, |
| const loomc_module_function_query_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_host_size_t | function_capacity, | ||
| loomc_module_function_t * | out_functions, | ||
| loomc_host_size_t * | out_function_count, | ||
| loomc_result_t ** | out_result ) |
Queries function metadata from a module.
| module | Module to inspect. |
| options | Query options. NULL enumerates all supported function kinds. |
| allocator | Host allocator used for the returned result. |
| function_capacity | Number of entries available in out_functions. |
| out_functions | Caller-owned output storage. May be NULL only when function_capacity is zero. |
| out_function_count | Receives the total number of matching functions, which may be larger than function_capacity. |
| out_result | Receives a retained result for the query. |
| loomc_status_t loomc_module_query_globals | ( | const loomc_module_t * | module, |
| const loomc_module_global_query_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_host_size_t | global_capacity, | ||
| loomc_module_global_t * | out_globals, | ||
| loomc_host_size_t * | out_global_count, | ||
| loomc_result_t ** | out_result ) |
Queries global metadata from a module.
| module | Module to inspect. |
| options | Query options. NULL enumerates all supported global kinds. |
| allocator | Host allocator used for the returned result. |
| global_capacity | Number of entries available in out_globals. |
| out_globals | Caller-owned output storage. May be NULL only when global_capacity is zero. |
| out_global_count | Receives the total number of matching globals, which may be larger than global_capacity. |
| out_result | Receives a retained result for the query. |
| void loomc_module_release | ( | loomc_module_t * | module | ) |
Releases an opaque module from one owner.
| module | Module to release. Passing NULL is allowed. |
| void loomc_module_retain | ( | loomc_module_t * | module | ) |
Retains an opaque module for another owner.
| module | Module to retain. |
| loomc_status_t loomc_module_serialize_to_file | ( | const loomc_module_t * | module, |
| const loomc_module_serialize_options_t * | options, | ||
| FILE * | file ) |
Serializes a module to an open C FILE*.
| module | Module to serialize. |
| options | Serialization options. NULL selects textual .loom. |
| file | Open writable file handle, such as stdout. |
| loomc_status_t loomc_module_serialize_to_path | ( | const loomc_module_t * | module, |
| const loomc_module_serialize_options_t * | options, | ||
| loomc_string_view_t | path, | ||
| loomc_allocator_t | allocator ) |
Serializes a module to a filesystem path.
| module | Module to serialize. |
| options | Serialization options. NULL selects textual .loom. |
| path | Output file path. The path is a borrowed byte view and does not need to be NUL-terminated. |
| allocator | Host allocator used for transient file path/stream storage. |
Exact target projection completes before the output path is opened, so a projection failure does not create or truncate the path.
| loomc_status_t loomc_module_serialize_to_source | ( | const loomc_module_t * | module, |
| const loomc_module_serialize_options_t * | options, | ||
| loomc_allocator_t | allocator, | ||
| loomc_source_t ** | out_source ) |
Serializes a module into an immutable source handle.
| module | Module to serialize. |
| options | Serialization options. NULL selects textual .loom. |
| allocator | Host allocator used for source-owned storage. |
| out_source | Receives one retained source on success. |
| bool loomc_module_try_get_function_at | ( | const loomc_module_t * | module, |
| loomc_host_size_t | function_ordinal, | ||
| loomc_module_function_t * | out_function ) |
Tries to get function metadata by public function ordinal without allocating a status.
| module | Module to inspect. |
| function_ordinal | Ordinal in the module's unfiltered function metadata sequence. |
| out_function | Receives function metadata when the ordinal names a supported function. |
| bool loomc_module_try_get_global_at | ( | const loomc_module_t * | module, |
| loomc_host_size_t | global_ordinal, | ||
| loomc_module_global_t * | out_global ) |
Tries to get global metadata by global ordinal without allocating a status.
| module | Module to inspect. |
| global_ordinal | Ordinal in the module's unfiltered global metadata sequence. |
| out_global | Receives global metadata when the ordinal names a supported global. |
| bool loomc_module_try_lookup_function | ( | const loomc_module_t * | module, |
| loomc_string_view_t | symbol_name, | ||
| loomc_module_function_t * | out_function ) |
Looks up one function by symbol name without allocating a status.
| module | Module to inspect. |
| symbol_name | Function symbol name, with or without a leading @. |
| out_function | Receives function metadata when the lookup succeeds. |
| bool loomc_module_try_lookup_global | ( | const loomc_module_t * | module, |
| loomc_string_view_t | symbol_name, | ||
| loomc_module_global_t * | out_global ) |
Looks up one global by symbol name without allocating a status.
| module | Module to inspect. |
| symbol_name | Global symbol name, with or without a leading @. |
| out_global | Receives global metadata when the lookup succeeds. |