MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / create

Method create

crates/c-api/include/wasmtime/global.hh:45–53  ·  view source on GitHub ↗

* \brief Create a new WebAssembly global. * * \param cx the store in which to create the global * \param ty the type that this global will have * \param init the initial value of the global * * This function can fail if `init` does not have a value that matches `ty`. */

Source from the content-addressed store, hash-verified

43 * This function can fail if `init` does not have a value that matches `ty`.
44 */
45 static Result<Global> create(Store::Context cx, const GlobalType &ty,
46 const Val &init) {
47 wasmtime_global_t global;
48 auto *error = wasmtime_global_new(cx.ptr, ty.ptr.get(), &init.val, &global);
49 if (error != nullptr) {
50 return Error(error);
51 }
52 return Global(global);
53 }
54
55 /// Returns the type of this global.
56 GlobalType type(Store::Context cx) const {

Callers

nothing calls this directly

Calls 4

wasmtime_global_newFunction · 0.85
ErrorClass · 0.70
GlobalClass · 0.70
getMethod · 0.45

Tested by

no test coverage detected