Skip to main content

WasmEdge_ExecutorRegister

Function WasmEdge_ExecutorRegister 

Source
pub unsafe extern "C" fn WasmEdge_ExecutorRegister(
    Cxt: *mut WasmEdge_ExecutorContext,
    ModuleCxt: *mut *mut WasmEdge_ModuleInstanceContext,
    StoreCxt: *mut WasmEdge_StoreContext,
    ASTCxt: *const WasmEdge_ASTModuleContext,
    ModuleName: WasmEdge_String,
) -> WasmEdge_Result
Expand description

Instantiate an AST Module as a named module instance and link it to the store.

Instantiate an AST Module with the module name, return the instantiated module instance context as the result, and also register the module instance to the store. The caller owns the object and should call WasmEdge_ModuleInstanceDelete to destroy it. Developers can use the WasmEdge_ModuleInstanceListFunction, WasmEdge_ModuleInstanceFindFunction, etc. APIs to retrieve the exported instances from the result module instance. After calling this function, the output module instance will also be registered in the store, and the other modules can import the exported instances for linking during instantiation. Developers SHOULD guarantee the lifetime of this output module instance, or an error will occur during execution after the module instance is destroyed if it has been imported by other modules. That is, developers are responsible for deleting the output module instance even if the store is destroyed. When the module instance is deleted, it will be unregistered from the store automatically.

\param Cxt the WasmEdge_ExecutorContext to instantiate the module. \param [out] ModuleCxt the output WasmEdge_ModuleInstanceContext if succeeded. \param StoreCxt the WasmEdge_StoreContext to link the imports. \param ASTCxt the WasmEdge AST Module context generated by loader or compiler. \param ModuleName the module name WasmEdge_String for all exported instances.

\returns WasmEdge_Result. Call WasmEdge_ResultGetMessage for the error message.