5#ifndef WASMTIME_INSTANCE_HH
6#define WASMTIME_INSTANCE_HH
59 const std::vector<Extern> &imports) {
60 std::vector<wasmtime_extern_t> raw_imports;
61 for (
const auto &item : imports) {
63 auto &last = raw_imports.back();
64 detail::cvt_extern(item, last);
69 raw_imports.size(), &instance, &trap);
70 if (error !=
nullptr) {
73 if (trap !=
nullptr) {
91 return detail::cvt_extern(e);
106 char *name =
nullptr;
112 std::string_view n(name, len);
113 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:26
A WebAssembly instance.
Definition: instance.hh:32
Instance(wasmtime_instance_t instance)
Creates a new instance from the raw underlying C API representation.
Definition: instance.hh:40
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:100
std::optional< Extern > get(Store::Context cx, std::string_view name)
Load an instance's export by name.
Definition: instance.hh:85
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:58
Helper class for linking modules together with name-based resolution.
Definition: linker.hh:26
Representation of a compiled WebAssembly module.
Definition: module.hh:28
Fallible result type used for Wasmtime.
Definition: error.hh:70
An interior pointer into a Store.
Definition: store.hh:69
Information about a WebAssembly trap.
Definition: trap.hh:113
WASM_API_EXTERN 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.
WASM_API_EXTERN 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.
WASM_API_EXTERN 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.
Opaque struct representing a wasm trap.
Structure used to represent either a Trap or an Error.
Definition: trap.hh:153
Container for different kinds of extern items.
Definition: extern.h:151
Representation of a instance in Wasmtime.
Definition: instance.h:26