The buildbot also publishes nightly versions once a day if there have been changes. The latest nightly can be installed through
-
Module#addFunctionType(name: string
, resultType: Type
, paramTypes: Type[]
): Signature
Adds a new function type.
-
Module#getFunctionTypeBySignature(resultType: Type
, paramTypes: Type[]
): Signature
Gets an existing function type by its parametric signature. Returns 0
if there is no such function type.
-
Module#addFunction(name: string
, functionType: Signature
, varTypes: Type[]
, body: Expression
): Function
Adds a function. varTypes
indicate additional locals, in the given order.
-
Module#getFunction(name: string
): Function
Gets a function, by name,
-
Module#removeFunction(name: string
): void
Removes a function, by name.
-
Module#addFunctionImport(internalName: string
, externalModuleName: string
, externalBaseName: string
, functionType: Signature
): Import
Adds a function import.
-
Module#addTableImport(internalName: string
, externalModuleName: string
, externalBaseName: string
): Import
Adds a table import. There's just one table for now, using name "0"
.
-
Module#addMemoryImport(internalName: string
, externalModuleName: string
, externalBaseName: string
): Import
Adds a memory import. There's just one memory for now, using name "0"
.
-
Module#addGlobalImport(internalName: string
, externalModuleName: string
, externalBaseName: string
, globalType: Type
): Import
Adds a global variable import. Imported globals must be immutable.
-
Module#removeImport(internalName: string
): void
Removes an import, by internal name.
-
Module#addFunctionExport(internalName: string
, externalName: string
): Export
Adds a function export.
-
Module#addTableExport(internalName: string
, externalName: string
): Export
Adds a table export. There's just one table for now, using name "0"
.
-
Module#addMemoryExport(internalName: string
, externalName: string
): Export
Adds a memory export. There's just one memory for now, using name "0"
.
-
Module#addGlobalExport(internalName: string
, externalName: string
): Export
Adds a global variable export. Exported globals must be immutable.
-
Module#removeExport(externalName: string
): void
Removes an export, by external name.
-
Module#setFunctionTable(funcs: Function[]
): void
Sets the contents of the function table. There's just one table for now, using name "0"
.
-
Module#setMemory(initial: number
, maximum: number
, exportName: string | null
, segments: MemorySegment[]
): void
Sets the memory. There's just one memory for now, using name "0"
. Providing exportName
also creates a memory export.
-
Module#setStart(start: Function
): void
Sets the start function.
-
Module#optimize(): void
Optimizes the module using the default optimization passes.
-
Module#optimizeFunction(func: Function | string
): void
Optimizes a single function using the default optimization passes.
-
Module#runPasses(passes: string[]
): void
Runs the specified passes on the module.
-
Module#runPassesOnFunction(func: Function | string
, passes: string[]
): void
Runs the specified passes on a single function.
-
Module#autoDrop(): void
Enables automatic insertion of drop
operations where needed. Lets you not worry about dropping when creating your code.
-
Module#block(label: string | null
, children: Expression[]
, type?: Type
): Expression
Creates a block. type
defaults to the undefined
type explained above.
-
Module#if(condition: Expression
, ifTrue: Expression
, ifFalse?: Expression
): Expression
Creates an if or if/else combination.
-
Module#loop(label: string | null
, body: Expression
): Expression
Creates a loop.
-
Module#break(label: string
, condition?: Expression
, value?: Expression
): Expression
Creates a break (br) to a label.
-
Module#switch(labels: string[]
, defaultLabel: string
, condition: Expression
, value?: Expression
): Expression
Creates a switch (br_table).
-
Module#nop(): Expression
Creates a no-operation (nop) instruction.
-
Module#return(value?: Expression
): Expression
Creates a return.
-
Module#unreachable(): Expression
Creates an unreachable instruction that will always trap.
-
Module#drop(value: Expression
): Expression
Creates a drop of a value.
-
Module#select(condition: Expression
, ifTrue: Expression
, ifFalse: Expression
): Expression
Creates a select, i.e., ternary if.
-
new Relooper(): Relooper
Constructs a relooper instance. This lets you provide an arbitrary CFG, and the relooper will structure it for WebAssembly.
-
Relooper#addBlock(code: Expression
): RelooperBlock
Adds a new block to the CFG, containing the provided code as its body.
-
Relooper#addBranch(from: RelooperBlock
, to: RelooperBlock
, condition: Expression
, code: Expression
): void
Adds a branch from a block to another block, with a condition (or nothing, if this is the default branch to take from the origin - each block must have one such branch), and optional code to execute on the branch (useful for phis).
-
Relooper#addBlockWithSwitch(code: Expression
, condition: Expression
): RelooperBlock
Adds a new block, which ends with a switch/br_table, with provided code and condition (that determines where we go in the switch).
-
Relooper#addBranchForSwitch(from: RelooperBlock
, to: RelooperBlock
, indexes: number[]
, code: Expression
): void
Adds a branch from a block ending in a switch, to another block, using an array of indexes that determine where to go, and optional code to execute on the branch.
-
Relooper#renderAndDispose(entry: RelooperBlock
, labelHelper: number
, module: Module
): Expression
Renders and cleans up the Relooper instance. Call this after you have created all the blocks and branches, giving it the entry block (where control flow begins), a label helper variable (an index of a local we can use, necessary for irreducible control flow), and the module. This returns an expression - normal WebAssembly code - that you can use normally anywhere.
Clone the GitHub repository including submodules and install the development dependencies: