Class PanamaModule

java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaModule
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.Module, Closeable, AutoCloseable

public final class PanamaModule extends Object implements ai.tegmentum.wasmtime4j.Module
Panama FFI implementation of WebAssembly Module.
Since:
1.0.0
  • Constructor Details

    • PanamaModule

      public PanamaModule(PanamaEngine engine, byte[] wasmBytes) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Creates a new Panama module from compiled bytecode.
      Parameters:
      engine - the engine used for compilation
      wasmBytes - the WebAssembly bytecode
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException - if module creation fails
  • Method Details

    • instantiate

      public ai.tegmentum.wasmtime4j.Instance instantiate(ai.tegmentum.wasmtime4j.Store store) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      instantiate in interface ai.tegmentum.wasmtime4j.Module
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • instantiate

      public ai.tegmentum.wasmtime4j.Instance instantiate(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.validation.ImportMap imports) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      instantiate in interface ai.tegmentum.wasmtime4j.Module
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getExports

      public List<ai.tegmentum.wasmtime4j.type.ExportType> getExports()
      Specified by:
      getExports in interface ai.tegmentum.wasmtime4j.Module
    • getImports

      public List<ai.tegmentum.wasmtime4j.type.ImportType> getImports()
      Specified by:
      getImports in interface ai.tegmentum.wasmtime4j.Module
    • hasExport

      public boolean hasExport(String name)
      Specified by:
      hasExport in interface ai.tegmentum.wasmtime4j.Module
    • hasImport

      public boolean hasImport(String moduleName, String fieldName)
      Specified by:
      hasImport in interface ai.tegmentum.wasmtime4j.Module
    • same

      public boolean same(ai.tegmentum.wasmtime4j.Module other)
      Specified by:
      same in interface ai.tegmentum.wasmtime4j.Module
    • getExportIndex

      public int getExportIndex(String name)
      Specified by:
      getExportIndex in interface ai.tegmentum.wasmtime4j.Module
    • getModuleExport

      public Optional<ai.tegmentum.wasmtime4j.ModuleExport> getModuleExport(String name)
      Specified by:
      getModuleExport in interface ai.tegmentum.wasmtime4j.Module
    • getEngine

      public ai.tegmentum.wasmtime4j.Engine getEngine()
      Specified by:
      getEngine in interface ai.tegmentum.wasmtime4j.Module
    • validateImports

      public boolean validateImports(ai.tegmentum.wasmtime4j.validation.ImportMap imports)
      Specified by:
      validateImports in interface ai.tegmentum.wasmtime4j.Module
    • validateImportsDetailed

      public ai.tegmentum.wasmtime4j.validation.ImportValidation validateImportsDetailed(ai.tegmentum.wasmtime4j.validation.ImportMap imports)
      Specified by:
      validateImportsDetailed in interface ai.tegmentum.wasmtime4j.Module
    • getName

      public String getName()
      Specified by:
      getName in interface ai.tegmentum.wasmtime4j.Module
    • initializeCopyOnWriteImage

      public void initializeCopyOnWriteImage() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      initializeCopyOnWriteImage in interface ai.tegmentum.wasmtime4j.Module
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • imageRange

      public ai.tegmentum.wasmtime4j.ImageRange imageRange() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      imageRange in interface ai.tegmentum.wasmtime4j.Module
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • resourcesRequired

      public ai.tegmentum.wasmtime4j.ResourcesRequired resourcesRequired()
      Specified by:
      resourcesRequired in interface ai.tegmentum.wasmtime4j.Module
    • text

      public byte[] text() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      text in interface ai.tegmentum.wasmtime4j.Module
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • addressMap

      public List<ai.tegmentum.wasmtime4j.Module.AddressMapping> addressMap() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      addressMap in interface ai.tegmentum.wasmtime4j.Module
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface ai.tegmentum.wasmtime4j.Module
    • serialize

      public byte[] serialize() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      serialize in interface ai.tegmentum.wasmtime4j.Module
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ai.tegmentum.wasmtime4j.Module
    • getNativeModule

      public MemorySegment getNativeModule()
      Gets the native module pointer.
      Returns:
      native module memory segment
    • getWasmBytes

      public byte[] getWasmBytes()
      Gets the original WebAssembly bytecode.
      Returns:
      a copy of the WebAssembly bytecode
    • functions

      public Iterable<ai.tegmentum.wasmtime4j.func.FunctionInfo> functions()
      Specified by:
      functions in interface ai.tegmentum.wasmtime4j.Module