5#ifndef WASMTIME_INSTANCE_HH
6#define WASMTIME_INSTANCE_HH
58 const std::vector<Extern> &imports) {
59 std::vector<wasmtime_extern_t> raw_imports;
60 for (
const auto &item : imports) {
62 auto &last = raw_imports.back();
63 detail::cvt_extern(item, last);
68 raw_imports.size(), &instance, &trap);
69 if (error !=
nullptr) {
72 if (trap !=
nullptr) {
90 return detail::cvt_extern(e);
105 char *name =
nullptr;
111 std::string_view n(name, len);
112 return std::pair(n, detail::cvt_extern(e));
Structure provided to host functions to lookup caller information or acquire a Store::Context.
Definition: func.hh:28
Errors coming from Wasmtime.
Definition: error.hh:25
A WebAssembly instance.
Definition: instance.hh:31
Instance(wasmtime_instance_t instance)
Creates a new instance from the raw underlying C API representation.
Definition: instance.hh:39
std::optional< std::pair< std::string_view, Extern > > get(Store::Context cx, size_t idx)
Load an instance's export by index.
Definition: instance.hh:99
std::optional< Extern > get(Store::Context cx, std::string_view name)
Load an instance's export by name.
Definition: instance.hh:84
static TrapResult< Instance > create(Store::Context cx, const Module &m, const std::vector< Extern > &imports)
Instantiates the module m with the provided imports
Definition: instance.hh:57
Helper class for linking modules together with name-based resolution.
Definition: linker.hh:25
Representation of a compiled WebAssembly module.
Definition: module.hh:27
Fallible result type used for Wasmtime.
Definition: error.hh:82
An interior pointer into a Store.
Definition: store.hh:60
Information about a WebAssembly trap.
Definition: trap.hh:113
bool wasmtime_instance_export_get(wasmtime_context_t *store, const wasmtime_instance_t *instance, const char *name, size_t name_len, wasmtime_extern_t *item)
Get an export by name from an instance.
bool wasmtime_instance_export_nth(wasmtime_context_t *store, const wasmtime_instance_t *instance, size_t index, char **name, size_t *name_len, wasmtime_extern_t *item)
Get an export by index from an instance.
wasmtime_error_t * wasmtime_instance_new(wasmtime_context_t *store, const wasmtime_module_t *module, const wasmtime_extern_t *imports, size_t nimports, wasmtime_instance_t *instance, wasm_trap_t **trap)
Instantiate a wasm module.
Opaque struct representing a wasm trap.
Structure used to represent either a Trap or an Error.
Definition: trap.hh:165
Container for different kinds of extern items.
Definition: extern.h:145
Representation of a instance in Wasmtime.
Definition: instance.h:26