|
Wasmtime
|
A WebAssembly global. More...
#include <global.hh>
Public Member Functions | |
| Global (wasmtime_global_t global) | |
| Creates as global from the raw underlying C API representation. | |
| GlobalType | type (Store::Context cx) const |
| Returns the type of this global. | |
| Val | get (Store::Context cx) const |
| Returns the current value of this global. | |
| Result< std::monostate > | set (Store::Context cx, const Val &val) const |
| const wasmtime_global_t & | capi () const |
| Returns the raw underlying C API global this is using. | |
Static Public Member Functions | |
| static Result< Global > | create (Store::Context cx, const GlobalType &ty, const Val &init) |
| Create a new WebAssembly global. More... | |
Friends | |
| class | Instance |
A WebAssembly global.
This class represents a WebAssembly global, either created through instantiating a module or a host global. Globals contain a WebAssembly value and can be read and optionally written to.
Note that this type does not itself own any resources. It points to resources owned within a Store and the Store must be passed in as the first argument to the functions defined on Global. Note that if the wrong Store is passed in then the process will be aborted.
|
inlinestatic |
Create a new WebAssembly global.
| cx | the store in which to create the global |
| ty | the type that this global will have |
| init | the initial value of the global |
This function can fail if init does not have a value that matches ty.
|
inline |
Sets this global to a new value.
This can fail if val has the wrong type or if this global isn't mutable.