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

Method create

crates/c-api/include/wasmtime/instance.hh:58–77  ·  view source on GitHub ↗

* \brief Instantiates the module `m` with the provided `imports` * * \param cx the store in which to instantiate the provided module * \param m the module to instantiate * \param imports the list of imports to use to instantiate the module * * This `imports` parameter is expected to line up 1:1 with the imports * required by the `m`. The type of `m` can be inspected to determi

Source from the content-addressed store, hash-verified

56 * type, or if the wrong number of `imports` is provided.
57 */
58 static TrapResult<Instance> create(Store::Context cx, const Module &m,
59 const std::vector<Extern> &imports) {
60 std::vector<wasmtime_extern_t> raw_imports;
61 for (const auto &item : imports) {
62 raw_imports.push_back(wasmtime_extern_t{});
63 auto &last = raw_imports.back();
64 detail::cvt_extern(item, last);
65 }
66 wasmtime_instance_t instance;
67 wasm_trap_t *trap = nullptr;
68 auto *error = wasmtime_instance_new(cx.ptr, m.capi(), raw_imports.data(),
69 raw_imports.size(), &instance, &trap);
70 if (error != nullptr) {
71 return TrapError(Error(error));
72 }
73 if (trap != nullptr) {
74 return TrapError(Trap(trap));
75 }
76 return Instance(instance);
77 }
78
79 /**
80 * \brief Load an instance's export by name.

Callers

nothing calls this directly

Calls 9

cvt_externFunction · 0.85
wasmtime_instance_newFunction · 0.85
TrapErrorClass · 0.85
ErrorClass · 0.70
TrapClass · 0.70
InstanceClass · 0.70
capiMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected