Class WebAssembly
Clients do not need to use this class, and are free to directly invoke the more convenient and granular methods and constructors of the relevant classes themselves.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfuncAlloc(@Nullable Store store, ExternType.Func type, MethodHandle handle) Construct a new function extern.Object[]funcInvoke(@Nullable Store store, Func func, Object... args) Invoke a function extern.Get the type of a function extern.globalAlloc(@Nullable Store store, ExternType.Global type) Create a new global with the given type.globalRead(@Nullable Store store, Global global) Read the value of a global.globalType(@Nullable Store store, Global global) Get the type of a global.voidglobalWrite(@Nullable Store store, Global global, Object value) Write the value of a global.instanceExport(Instance inst, String name) Get a named export of the module instance.memAlloc(@Nullable Store store, ExternType.Mem type) Create a new memory with the given type.intGrow the memory by a number of pages, filling new pages with 0.byteRead a single byte from a memory.intGet the size of the memory, in pages.Get the type of a memory.voidWrite a single byte to a memory.moduleDecode(byte[] bytes) Decode a binary module from a byte array.moduleExports(Module module) Get the exports that this module supplies.moduleFromNode(ModuleNode node) Create a module from a JWasm module node.moduleImports(Module module) Get the imports that the module requires.moduleInstantiate(Store store, Module module, ExternVal[] imports) Instantiate the module in the given store with the provided values for imports.moduleParse(String source) Parse a text module from a string.voidmoduleValidate(Module module) Validate the module, throwing an exception if the module is invalid.voidsetDebugOutputDirectory(File file) Set the debug output of stores created by this embedding instance.Returns a new empty store.tableAlloc(@Nullable Store store, ExternType.Table type) Construct a new table with the given type.intGrow the table by a number of elements, filling it with the given value.Get an element of the table.intGet the size of a table.Get the type of a table extern.voidtableWrite(@Nullable Store store, Table table, int i, Object value) Set an element of the table.
- 
Constructor Details- 
WebAssemblypublic WebAssembly()
 
- 
- 
Method Details- 
setDebugOutputDirectorySet the debug output of stores created by this embedding instance.- Parameters:
- file- The debug directory.
- See Also:
 
- 
storeInitReturns a new empty store.- Returns:
- The new store.
- See Also:
 
- 
moduleDecodeDecode a binary module from a byte array.- Parameters:
- bytes- The byte array.
- Returns:
- The decoded module
- See Also:
 
- 
moduleParseParse a text module from a string.- Parameters:
- source- The source string.
- Returns:
- The parsed module.
- See Also:
 
- 
moduleFromNodeCreate a module from a JWasm module node.The module node will be copied, to prevent exterior mutation. - Parameters:
- node- The module node.
- Returns:
- The new module.
- See Also:
 
- 
moduleValidateValidate the module, throwing an exception if the module is invalid.This is idempotent, and will not run validation again if the module has already been validated. - Parameters:
- module- The module to validate.
- See Also:
 
- 
moduleInstantiateInstantiate the module in the given store with the provided values for imports.The imports must be in the same order as those returned for Module.imports().- Parameters:
- store- The store.
- module- The module to instantiate.
- imports- The supplied imports.
- Returns:
- The instantiated module.
- See Also:
 
- 
moduleImportsGet the imports that the module requires.- Parameters:
- module- The module.
- Returns:
- The list of imports.
- See Also:
 
- 
moduleExportsGet the exports that this module supplies.- Parameters:
- module- The module.
- Returns:
- The list of exports.
- See Also:
 
- 
instanceExportGet a named export of the module instance.- Parameters:
- inst- The module instance.
- name- The name of the export.
- Returns:
- The export.
- See Also:
 
- 
funcAllocConstruct a new function extern.- Parameters:
- store- The store. Ignored.
- type- The function type.
- handle- The method handle.
- Returns:
- The allocated function.
- See Also:
 
- 
funcTypeGet the type of a function extern.- Parameters:
- store- The store. Ignored.
- func- The function.
- Returns:
- The type of the function.
- See Also:
 
- 
funcInvokeInvoke a function extern.- Parameters:
- store- The store. Ignored.
- func- The function.
- args- The function arguments.
- Returns:
- The type of the function.
- See Also:
 
- 
tableAllocConstruct a new table with the given type.- Parameters:
- store- The store. Ignored.
- type- The table type.
- Returns:
- A new table.
- See Also:
 
- 
tableTypeGet the type of a table extern.- Parameters:
- store- The store. Ignored.
- table- The table.
- Returns:
- The table's type.
- See Also:
 
- 
tableReadGet an element of the table.- Parameters:
- store- The store. Ignored.
- table- The table.
- i- The element index.
- Returns:
- The element.
- See Also:
 
- 
tableWriteSet an element of the table.- Parameters:
- store- The store. Ignored.
- table- The table.
- i- The element index.
- value- The element.
- See Also:
 
- 
tableSizeGet the size of a table.- Parameters:
- store- The store. Ignored.
- table- The table.
- Returns:
- The size of the table.
- See Also:
 
- 
tableGrowGrow the table by a number of elements, filling it with the given value.This operation is allowed to fail (and must fail if the upper limit is exceeded), in which case -1 should be returned. - Parameters:
- store- The store. Ignored.
- table- The table.
- growBy- The number of elements to grow by.
- fillWith- The value to fill new elements with.
- Returns:
- The old size of the table.
- See Also:
 
- 
memAllocCreate a new memory with the given type.- Parameters:
- store- The store. Ignored.
- type- The type.
- Returns:
- The new memory.
- See Also:
 
- 
memTypeGet the type of a memory.- Parameters:
- store- The store. Ignored.
- memory- The memory.
- Returns:
- The memory type.
- See Also:
 
- 
memReadRead a single byte from a memory.Using this is discouraged, see Memory.read(int).- Parameters:
- store- The store. Ignored.
- memory- The memory.
- addr- The memory address.
- Returns:
- The byte.
- See Also:
 
- 
memWriteWrite a single byte to a memory.Using this is discouraged, see Memory.write(int, byte).- Parameters:
- store- The store. Ignored.
- memory- The memory.
- addr- The memory address.
- value- The byte.
- See Also:
 
- 
memSizeGet the size of the memory, in pages.- Parameters:
- store- The store. Ignored.
- memory- The memory.
- Returns:
- The size of the memory, in pages.
- See Also:
 
- 
memGrowGrow the memory by a number of pages, filling new pages with 0.This operation is allowed to fail (and must fail if the upper limit is exceeded), in which case -1 should be returned. - Parameters:
- store- The store. Ignored.
- memory- The memory.
- growByPages- The number of pages to grow by, interpreted as an unsigned integer.
- Returns:
- The old size, or -1 if the memory was not grown.
- See Also:
 
- 
globalAllocCreate a new global with the given type.- Parameters:
- store- The store. Ignored.
- type- The type.
- Returns:
- The global.
- See Also:
 
- 
globalTypeGet the type of a global.- Parameters:
- store- The store. Ignored.
- global- The global.
- Returns:
- The global type.
- See Also:
 
- 
globalReadRead the value of a global.- Parameters:
- store- The store. Ignored.
- global- The global.
- Returns:
- The value of the global.
- See Also:
 
- 
globalWriteWrite the value of a global.Should fail if the global is immutable. - Parameters:
- store- The store. Ignored.
- global- The global.
- value- The new value of the global.
- See Also:
 
 
-