* \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`. */
| 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 { |
nothing calls this directly
no test coverage detected