Class MarshalContext
java.lang.Object
ai.tegmentum.webassembly4j.runtime.marshal.MarshalContext
Bundles memory, allocator, writer and reader for marshalling complex types
to and from WebAssembly linear memory.
-
Constructor Summary
ConstructorsConstructorDescriptionMarshalContext(ai.tegmentum.webassembly4j.api.Memory memory, MemoryAllocator allocator) Creates a new MarshalContext. -
Method Summary
Modifier and TypeMethodDescriptionReturns the memory allocator.static MarshalContextfromInstance(ai.tegmentum.webassembly4j.api.Instance instance) Creates a MarshalContext from a WASM instance by resolving the default memory export and building an appropriate allocator.ai.tegmentum.webassembly4j.api.Memorymemory()Returns the linear memory.reader()Returns the memory reader.writer()Returns the memory writer.
-
Constructor Details
-
MarshalContext
Creates a new MarshalContext.- Parameters:
memory- the linear memoryallocator- the memory allocator
-
-
Method Details
-
fromInstance
Creates a MarshalContext from a WASM instance by resolving the default memory export and building an appropriate allocator.- Parameters:
instance- the WASM instance- Returns:
- a new MarshalContext
- Throws:
IllegalStateException- if the instance does not export memory
-
memory
public ai.tegmentum.webassembly4j.api.Memory memory()Returns the linear memory.- Returns:
- the memory
-
allocator
Returns the memory allocator.- Returns:
- the allocator
-
writer
Returns the memory writer.- Returns:
- the writer
-
reader
Returns the memory reader.- Returns:
- the reader
-