Instantiate instantiates a module with all imports defined in this linker. Returns an error if the instance's imports couldn't be satisfied, had the wrong types, or if a trap happened executing the start function.
(store Storelike, module *Module)
| 240 | // Returns an error if the instance's imports couldn't be satisfied, had the |
| 241 | // wrong types, or if a trap happened executing the start function. |
| 242 | func (l *Linker) Instantiate(store Storelike, module *Module) (*Instance, error) { |
| 243 | var ret C.wasmtime_instance_t |
| 244 | err := enterWasm(store, func(trap **C.wasm_trap_t) *C.wasmtime_error_t { |
| 245 | return C.wasmtime_linker_instantiate(l.ptr(), store.Context(), module.ptr(), &ret, trap) |
| 246 | }) |
| 247 | runtime.KeepAlive(l) |
| 248 | runtime.KeepAlive(module) |
| 249 | runtime.KeepAlive(store) |
| 250 | if err != nil { |
| 251 | return nil, err |
| 252 | } |
| 253 | return mkInstance(ret), nil |
| 254 | } |
| 255 | |
| 256 | // GetDefault acquires the "default export" of the named module in this linker. |
| 257 | // |