Class SpiderModule

An abstract representation of a WASM module and all of its contents.

Create using the createModule or readModule functions.

Write its contents to a WASM binary using writeModule.

Compile its contents to a WebAssembly.Module using compileModule.

Hierarchy

  • SpiderModule

Properties

customSections: (undefined | SpiderCustomSectionDefinition[])[]

An ordered list of ordered lists of custom sections in this module. The top-level list acts as a map from SpiderCustomSectionPosition to an ordered list of custom sections stored at that position. Use createCustomSection to add custom sections to this module and getCustomSections or getCustomSectionsAt to get sections from this list.

data: SpiderData[]

An ordered list of all the data in this module. Use createDataActive or createDataPassive to append to this list.

elements: SpiderElement[]

An ordered list of all the elements in this module. Use createElementFuncIdxActive, createElementFuncIdxInactive, createElementExprActive or createElementFuncIdxActive to append to this list.

exports: SpiderExport[]

An ordered list of all the exports in this module. Use exportFunction, exportGlobal, exportTable or exportMemory to append to this list.

An ordered list of all the functions in this module. Use createFunction to append to this list.

An ordered list of all the globals in this module. Use createGlobal to append to this list.

imports: SpiderImport[]

An ordered list of all the imports in this module. Use importFunction, importGlobal, importTable or importMemory to append to this list.

An ordered list of all the memories in this module. Use createMemory to append to this list.

start: null | SpiderFunction

A function to execute when this module is initialized, or null if no function is to be executed.

An ordered list of all the tables in this module. Use createTable to append to this list.

An ordered list of types in this module. Use createType to append to this list.

Methods

  • Creates a new custom section and adds it to this module.

    Parameters

    • name: string

      The name of the new custom section.

    • buffer: ArrayLike<number>

      The buffer of bytes contained in the new section.

    • position: SpiderCustomSectionPosition = SpiderCustomSectionPosition.AFTER_HEADER

      The location within the module to store the custom data. Defaults to the beginning.

    Returns SpiderCustomSectionDefinition

    The created custom data.

  • Creates a new active data element and adds it to this module.

    Parameters

    • memory: SpiderMemory

      The memory to copy the contents of the new data into.

    • offset: SpiderExpression | SpiderExprConstNumber

      An offset within the memory to copy the contents of the new data into. Either the value itself or an expression which returns the value.

    • buffer: ArrayLike<number>

      The buffer of bytes contained in the new data.

    Returns SpiderDataActive

    The created data.

  • Creates a new memory and adds it to this module.

    Parameters

    • minSize: number = 0

      The minimum number of pages the new memory can have. 0 by default

    • Optional maxSize: number

      The optional maximum number of pages the new memory can be grown to.

    Returns SpiderMemoryDefinition

    The created memory.

  • Creates a new table and adds it to this module.

    Parameters

    • type: SpiderReferenceType

      The type of reference contained in the new table.

    • minSize: number

      The minimum number of entries in the imported table.

    • Optional maxSize: number

      The optional maximum number of entries the new table can be grown to.

    Returns SpiderTableDefinition

    The created table.

  • Import a global from an external module.

    Parameters

    • module: string

      The name of the module to import the global from.

    • name: string

      The name of the global within the module to import.

    • type: SpiderValueType

      The type of the value held by the imported global.

    • mutable: boolean

      True if the imported global is mutable.

    Returns SpiderImportGlobal

    The created import entry.

  • Import a memory from an external module.

    Parameters

    • module: string

      The name of the module to import the memory from.

    • name: string

      The name of the memoery within the module to import.

    • minSize: number = 0

      The minimum number of pages the imported memory can have. 0 by default.

    • Optional maxSize: number

      The optional maximum number of pages the imported memory can be grown to.

    Returns SpiderImportMemory

    The created import entry.

  • Import a table from an external module.

    Parameters

    • module: string

      The name of the module to import the table from.

    • name: string

      The name of the table within the module to import.

    • type: SpiderReferenceType

      The type of reference contained in the imported table.

    • minSize: number

      The minimum number of entries in the imported table.

    • Optional maxSize: number

      The optional maximum number of entries the imported table can be grown to.

    Returns SpiderImportTable

    The created import entry.

Generated using TypeDoc