Class PanamaLinker<T>
java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaLinker<T>
- Type Parameters:
T- the type of user data associated with stores
- All Implemented Interfaces:
ai.tegmentum.wasmtime4j.Linker<T>,Closeable,AutoCloseable
Panama FFI implementation of WebAssembly Linker.
- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface ai.tegmentum.wasmtime4j.Linker
ai.tegmentum.wasmtime4j.Linker.LinkerDefinition -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidvoidaliasModule(String module, String asModule) ai.tegmentum.wasmtime4j.Linker<T> allowShadowing(boolean allow) ai.tegmentum.wasmtime4j.Linker<T> allowUnknownExports(boolean allow) voidclose()voiddefine(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.Extern extern) voiddefineGlobal(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.WasmGlobal global) voiddefineHostFunction(String moduleName, String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType, ai.tegmentum.wasmtime4j.func.HostFunction implementation) voiddefineInstance(ai.tegmentum.wasmtime4j.Store store, String moduleName, ai.tegmentum.wasmtime4j.Instance instance) voiddefineMemory(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.WasmMemory memory) voiddefineName(ai.tegmentum.wasmtime4j.Store store, String name, ai.tegmentum.wasmtime4j.Extern extern) voiddefineTable(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.WasmTable table) voiddefineUnknownImportsAsDefaultValues(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.Module module) voiddefineUnknownImportsAsTraps(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.Module module) voidvoidfuncNewUnchecked(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType, ai.tegmentum.wasmtime4j.func.HostFunction implementation) ai.tegmentum.wasmtime4j.ExterngetByImport(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name) ai.tegmentum.wasmtime4j.WasmFunctiongetDefault(ai.tegmentum.wasmtime4j.Store store, String moduleName) ai.tegmentum.wasmtime4j.EngineList<ai.tegmentum.wasmtime4j.validation.ImportInfo> Gets the native linker pointer.Gets the WASI context set on this linker.booleanai.tegmentum.wasmtime4j.Instanceinstantiate(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.Module module) ai.tegmentum.wasmtime4j.Instanceinstantiate(ai.tegmentum.wasmtime4j.Store store, String moduleName, ai.tegmentum.wasmtime4j.Module module) ai.tegmentum.wasmtime4j.InstancePreinstantiatePre(ai.tegmentum.wasmtime4j.Module module) static intinvokeHostFunctionCallback(long callbackId, MemorySegment paramsPtr, int paramsLen, MemorySegment resultsPtr, int resultsLen, MemorySegment errorMsgPtr, int errorMsgLen) Callback function invoked from native code when a host function is called.booleanisValid()booleanChecks if WASI has been enabled for this linker.Iterable<ai.tegmentum.wasmtime4j.Linker.LinkerDefinition> iter()Iterable<ai.tegmentum.wasmtime4j.Linker.LinkerDefinition> iter(ai.tegmentum.wasmtime4j.Store store) voidmodule(ai.tegmentum.wasmtime4j.Store store, String moduleName, ai.tegmentum.wasmtime4j.Module module) voidsetWasiContext(PanamaWasiContext wasiCtx) Sets the WASI context for this linker.ai.tegmentum.wasmtime4j.validation.ImportValidationvalidateImports(ai.tegmentum.wasmtime4j.Module... modules) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.tegmentum.wasmtime4j.Linker
defineHostFunctionAsync, defineName, getByImport, getOneByName, instantiateAsync, moduleAsync
-
Constructor Details
-
PanamaLinker
Creates a new Panama linker.- Parameters:
engine- the engine to create the linker for- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException- if linker creation fails
-
-
Method Details
-
defineHostFunction
public void defineHostFunction(String moduleName, String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType, ai.tegmentum.wasmtime4j.func.HostFunction implementation) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
defineHostFunctionin interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
defineMemory
public void defineMemory(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.WasmMemory memory) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
defineMemoryin interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
defineTable
public void defineTable(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.WasmTable table) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
defineTablein interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
defineGlobal
public void defineGlobal(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.WasmGlobal global) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
defineGlobalin interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
defineInstance
public void defineInstance(ai.tegmentum.wasmtime4j.Store store, String moduleName, ai.tegmentum.wasmtime4j.Instance instance) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
defineInstancein interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
alias
-
aliasModule
-
instantiate
public ai.tegmentum.wasmtime4j.Instance instantiate(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.Module module) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
instantiatein interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
instantiate
public ai.tegmentum.wasmtime4j.Instance instantiate(ai.tegmentum.wasmtime4j.Store store, String moduleName, ai.tegmentum.wasmtime4j.Module module) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
instantiatein interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
instantiatePre
public ai.tegmentum.wasmtime4j.InstancePre instantiatePre(ai.tegmentum.wasmtime4j.Module module) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
instantiatePrein interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
enableWasi
public void enableWasi() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
enableWasiin interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
isWasiEnabled
public boolean isWasiEnabled()Checks if WASI has been enabled for this linker.- Returns:
- true if WASI is enabled, false otherwise
-
setWasiContext
Sets the WASI context for this linker.The WASI context will be automatically attached to the store during instantiation.
- Parameters:
wasiCtx- the WASI context to use
-
getWasiContext
Gets the WASI context set on this linker.- Returns:
- the WASI context, or null if not set
-
getEngine
public ai.tegmentum.wasmtime4j.Engine getEngine()- Specified by:
getEnginein interfaceai.tegmentum.wasmtime4j.Linker<T>
-
isValid
public boolean isValid()- Specified by:
isValidin interfaceai.tegmentum.wasmtime4j.Linker<T>
-
hasImport
-
validateImports
public ai.tegmentum.wasmtime4j.validation.ImportValidation validateImports(ai.tegmentum.wasmtime4j.Module... modules) - Specified by:
validateImportsin interfaceai.tegmentum.wasmtime4j.Linker<T>
-
getImportRegistry
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceai.tegmentum.wasmtime4j.Linker<T>
-
getNativeLinker
Gets the native linker pointer.- Returns:
- native linker memory segment
-
invokeHostFunctionCallback
public static int invokeHostFunctionCallback(long callbackId, MemorySegment paramsPtr, int paramsLen, MemorySegment resultsPtr, int resultsLen, MemorySegment errorMsgPtr, int errorMsgLen) Callback function invoked from native code when a host function is called.This method is called via Panama FFI function pointer.
- Parameters:
callbackId- the callback IDparamsPtr- pointer to parameter arrayparamsLen- number of parametersresultsPtr- pointer to results bufferresultsLen- expected number of resultserrorMsgPtr- pointer to error message buffer (for writing on failure)errorMsgLen- size of error message buffer- Returns:
- 0 on success, non-zero on error
-
allowShadowing
-
allowUnknownExports
-
defineUnknownImportsAsTraps
public void defineUnknownImportsAsTraps(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.Module module) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
defineUnknownImportsAsTrapsin interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
defineUnknownImportsAsDefaultValues
public void defineUnknownImportsAsDefaultValues(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.Module module) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
defineUnknownImportsAsDefaultValuesin interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
funcNewUnchecked
public void funcNewUnchecked(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType, ai.tegmentum.wasmtime4j.func.HostFunction implementation) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
funcNewUncheckedin interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
iter
-
iter
-
getByImport
-
defineName
-
define
public void define(ai.tegmentum.wasmtime4j.Store store, String moduleName, String name, ai.tegmentum.wasmtime4j.Extern extern) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
definein interfaceai.tegmentum.wasmtime4j.Linker<T>- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
module
-
getDefault
-