Wasmtime
store.hh
Go to the documentation of this file.
1
5#ifndef WASMTIME_STORE_HH
6#define WASMTIME_STORE_HH
7
8#include <wasmtime/_exnref_class.hh>
9#include <wasmtime/_func_class.hh>
10#include <wasmtime/_store_class.hh>
11#include <wasmtime/trap.hh>
12
13namespace wasmtime {
14
16 : Context(wasmtime_caller_context(caller.ptr)) {}
17inline Store::Context::Context(Caller *caller) : Context(*caller) {}
18
19#ifdef WASMTIME_FEATURE_GC
21 return Trap(wasmtime_context_set_exception(capi(), exn.capi()));
22}
23
24inline std::optional<ExnRef> Store::Context::take_exception() {
26 if (wasmtime_context_take_exception(capi(), &exn)) {
27 return ExnRef(exn);
28 }
29 return std::nullopt;
30}
31
33 return wasmtime_context_has_exception(capi());
34}
35#endif
36
37} // namespace wasmtime
38
39#endif // WASMTIME_STORE_HH
Structure provided to host functions to lookup caller information or acquire a Store::Context.
Definition: _func_class.hh:25
A WebAssembly exception object.
Definition: _exnref_class.hh:29
An interior pointer into a Store.
Definition: _store_class.hh:65
std::optional< ExnRef > take_exception()
Takes the pending exception from the store, if any.
Trap throw_exception(ExnRef exn)
Sets the pending exception on the store and returns a Trap.
Context(wasmtime_context_t *ptr)
Creates a context from the raw C API pointer.
Definition: _store_class.hh:79
bool has_exception()
Tests whether there is a pending exception on the store.
Information about a WebAssembly trap.
Definition: trap.hh:113
WASM_API_EXTERN wasm_trap_t * wasmtime_context_set_exception(wasmtime_context_t *store, const wasmtime_exnref_t *exn)
Sets the pending exception on the store and returns a trap.
WASM_API_EXTERN bool wasmtime_context_has_exception(wasmtime_context_t *store)
Tests whether there is a pending exception on the store.
WASM_API_EXTERN bool wasmtime_context_take_exception(wasmtime_context_t *store, wasmtime_exnref_t *exn_ret)
Takes the pending exception from the store, if any.
WASM_API_EXTERN wasmtime_context_t * wasmtime_caller_context(wasmtime_caller_t *caller)
Returns the store context of the caller object.
A WebAssembly exception reference value.
Definition: val.h:103