Loom C API
Public Loom compiler C API
Loading...
Searching...
No Matches
context.h File Reference

Reusable Loom API context. More...

Go to the source code of this file.

Data Structures

struct  loomc_context_options_t
 Context creation options. More...

Typedefs

typedef struct loomc_context_t loomc_context_t
 Immutable Loom API context.

Functions

loomc_status_t loomc_context_create (const loomc_context_options_t *options, loomc_allocator_t allocator, loomc_context_t **out_context)
 Creates a reusable Loom API context.
void loomc_context_retain (loomc_context_t *context)
 Retains context for another owner.
void loomc_context_release (loomc_context_t *context)
 Releases context from one owner.

Detailed Description

Reusable Loom API context.

A context owns process-local Loom language registration state used by parsing, bytecode indexing, linking, and compilation. Embedders normally create one context for a process or toolchain instance and share it with prepared linkers, compilers, and link-index builders.

Example
Create a context once, then reuse it while building persistent indexes:
loomc_context_t* context = NULL;
if (!loomc_status_is_ok(status)) {
return status;
}
// Use context to create link-index builders, linkers, and compilers.
loomc_allocator_t loomc_allocator_system(void)
Returns a process-global system allocator.
struct iree_status_handle_t * loomc_status_t
Opaque status handle.
Definition base.h:55
struct loomc_context_t loomc_context_t
Immutable Loom API context.
Definition context.h:47
loomc_status_t loomc_context_create(const loomc_context_options_t *options, loomc_allocator_t allocator, loomc_context_t **out_context)
Creates a reusable Loom API context.
void loomc_context_release(loomc_context_t *context)
Releases context from one owner.

Typedef Documentation

◆ loomc_context_t

Immutable Loom API context.

Thread safety
Contexts are immutable after creation and may be shared across threads. Operations that need mutable source-location tables serialize that mutation through their owning builder or invocation object rather than exposing it on the context API.

Function Documentation

◆ loomc_context_create()

loomc_status_t loomc_context_create ( const loomc_context_options_t * options,
loomc_allocator_t allocator,
loomc_context_t ** out_context )

Creates a reusable Loom API context.

Parameters
optionsContext options, or NULL for defaults.
allocatorHost allocator used for context-owned storage.
out_contextReceives one retained context on success.
Returns
OK when the context was created.
Ownership
The caller owns the returned reference and releases it with loomc_context_release.
Thread safety
The returned context is immutable and may be shared across prepared tools and worker threads.

◆ loomc_context_release()

void loomc_context_release ( loomc_context_t * context)

Releases context from one owner.

Parameters
contextContext to release. Passing NULL is allowed.
Thread safety
Retain/release operations are safe to perform from multiple threads. The context is destroyed when the final reference is released.

◆ loomc_context_retain()

void loomc_context_retain ( loomc_context_t * context)

Retains context for another owner.

Parameters
contextContext to retain.
Thread safety
Retain/release operations are safe to perform from multiple threads.