| Copyright | (c) 2026 Tushar Adhatrao |
|---|---|
| License | MIT |
| Stability | stable |
| Safe Haskell | None |
| Language | GHC2021 |
WasmEdge.Executor
Description
Synopsis
- data Executor
- createExecutor :: Maybe Configure -> Maybe Statistics -> IO Executor
- deleteExecutor :: Executor -> IO ()
- withExecutor :: Maybe Configure -> Maybe Statistics -> (Executor -> IO a) -> IO a
- newtype ASTModule = ASTModule (OwnedCtx ASTModuleTag)
- loadASTFromFile :: FilePath -> IO (WasmResult ASTModule)
- loadASTFromBytes :: ByteString -> IO (WasmResult ASTModule)
- deleteASTModule :: ASTModule -> IO ()
- withASTModule :: ASTModule -> (ASTModule -> IO a) -> IO a
- validateAST :: ASTModule -> IO (WasmResult ())
- instantiateModule :: Executor -> Store -> ASTModule -> IO (WasmResult ModuleInstance)
- registerModule :: Executor -> Store -> ASTModule -> Text -> IO (WasmResult ModuleInstance)
- registerImportModule :: Executor -> Store -> ModuleInstance -> IO (WasmResult ())
- registerImportModuleWithAlias :: Executor -> Store -> ModuleInstance -> Text -> IO (WasmResult ())
- invokeFunction :: Executor -> FunctionInstance -> [WasmVal] -> IO (WasmResult [WasmVal])
- asyncInvokeFunction :: Executor -> FunctionInstance -> [WasmVal] -> IO Async
- unsafeExecutorPtr :: Executor -> IO (Ptr ExecutorTag)
- borrowExecutor :: Ptr ExecutorTag -> IO Executor
- unsafeASTModulePtr :: ASTModule -> IO (Ptr ASTModuleTag)
- borrowASTModule :: Ptr ASTModuleTag -> IO ASTModule
Executor context
createExecutor :: Maybe Configure -> Maybe Statistics -> IO Executor #
Create an Executor with optional configuration and statistics contexts.
deleteExecutor :: Executor -> IO () #
Delete an Executor.
withExecutor :: Maybe Configure -> Maybe Statistics -> (Executor -> IO a) -> IO a #
Scoped Executor.
AST module context
Parsed WebAssembly Abstract Syntax Tree module.
Constructors
| ASTModule (OwnedCtx ASTModuleTag) |
loadASTFromFile :: FilePath -> IO (WasmResult ASTModule) #
Load and parse an ASTModule from a WASM file on disk.
loadASTFromBytes :: ByteString -> IO (WasmResult ASTModule) #
Load and parse an ASTModule from an in-memory WASM binary.
deleteASTModule :: ASTModule -> IO () #
Delete an ASTModule.
validateAST :: ASTModule -> IO (WasmResult ()) #
Validate an ASTModule.
Instantiation and registration
instantiateModule :: Executor -> Store -> ASTModule -> IO (WasmResult ModuleInstance) #
Instantiate an ASTModule into a Store, returning the new ModuleInstance.
registerModule :: Executor -> Store -> ASTModule -> Text -> IO (WasmResult ModuleInstance) #
registerImportModule :: Executor -> Store -> ModuleInstance -> IO (WasmResult ()) #
Register a pre-created ModuleInstance (e.g. host module or WASI) into a Store.
registerImportModuleWithAlias :: Executor -> Store -> ModuleInstance -> Text -> IO (WasmResult ()) #
Register a pre-created ModuleInstance under a custom alias name into a Store.
Function invocation
invokeFunction :: Executor -> FunctionInstance -> [WasmVal] -> IO (WasmResult [WasmVal]) #
Synchronously invoke a FunctionInstance with arguments, returning results.
asyncInvokeFunction :: Executor -> FunctionInstance -> [WasmVal] -> IO Async #
Asynchronously invoke a FunctionInstance, returning an Async handle.
Internal / borrowed pointers
unsafeExecutorPtr :: Executor -> IO (Ptr ExecutorTag) #
Extract the raw pointer of an Executor.
borrowExecutor :: Ptr ExecutorTag -> IO Executor #
Create a borrowed Executor from a raw pointer (does not finalize).
unsafeASTModulePtr :: ASTModule -> IO (Ptr ASTModuleTag) #
Extract the raw pointer of an ASTModule.
borrowASTModule :: Ptr ASTModuleTag -> IO ASTModule #
Create a borrowed ASTModule from a raw pointer (does not finalize).