$ npm install binaryen
binaryen.js is a port of Binaryen to the Web, allowing you to generate WebAssembly using a JavaScript API.
$> npm install binaryen
import binaryen from "binaryen";
// Create a module with a single function
var myModule = new binaryen.Module();
myModule.addFunction("add", binaryen.createType([ binaryen.i32, binaryen.i32 ]), binaryen.i32, [ binaryen.i32 ],
myModule.block(null, [
myModule.local.set(2,
myModule.i32.add(
myModule.local.get(0, binaryen.i32),
myModule.local.get(1, binaryen.i32)
)
),
myModule.return(
myModule.local.get(2, binaryen.i32)
)
])
);
myModule.addFunctionExport("add", "add");
// Optimize the module using default passes and levels
myModule.optimize();
// Validate the module
if (!myModule.validate())
throw new Error("validation error");
// Generate text format and binary
var textData = myModule.emitText();
var wasmData = myModule.emitBinary();
// Example usage with the WebAssembly API
var compiled = new WebAssembly.Module(wasmData);
var instance = new WebAssembly.Instance(compiled, {});
console.log(instance.exports.add(41, 1));
The buildbot also publishes nightly versions once a day if there have been changes. The latest nightly can be installed through
$> npm install binaryen@nightly
or you can use one of the previous versions instead if necessary.
https://cdn.jsdelivr.net/gh/AssemblyScript/binaryen.js@VERSION/index.js
https://cdn.jsdelivr.net/npm/binaryen@VERSION/index.js
https://unpkg.com/binaryen@VERSION/index.js
Replace VERSION
with a specific version or omit it (not recommended in production) to use main/latest.
The package includes Node.js builds of wasm-opt and wasm2js.
Please note that the Binaryen API is evolving fast and that definitions and documentation provided by the package tend to get out of sync despite our best efforts. It's a bot after all. If you rely on binaryen.js and spot an issue, please consider sending a PR our way by updating index.d.ts and README.md to reflect the current API.
Future features 🦄 might not be supported by all runtimes.
none: Type
The none type, e.g., void
.
i32: Type
32-bit integer type.
i64: Type
64-bit integer type.
f32: Type
32-bit float type.
f64: Type
64-bit float (double) type.
v128: Type
128-bit vector type. 🦄
funcref: Type
A function reference. 🦄
externref: Type
An external (host) reference. 🦄
anyref: Type
Any (top type) reference. 🦄
eqref: Type
Equal reference. 🦄
i31ref: Type
i31 reference. 🦄
structref: Type
Structure reference. 🦄
stringref: Type
String reference. 🦄
stringview_wtf8: Type
View of a string reference in WTF-8 encoding. 🦄
stringview_wtf16: Type
View of a string reference in WTF-16 encoding. 🦄
stringview_iter: Type
Iterator over the code points of a string reference. 🦄
unreachable: Type
Special type indicating unreachable code when obtaining information about an expression.
auto: Type
Special type used in Module#block exclusively. Lets the API figure out a block's result type automatically.
createType(types: Type[]
): Type
Creates a multi-value type from an array of types.
expandType(type: Type
): Type[]
Expands a multi-value type to an array of types.
new Module()
Constructs a new module.
parseText(text: string
): Module
Creates a module from Binaryen's s-expression text format (not official stack-style text format).
readBinary(data: Uint8Array
): Module
Creates a module from binary data.
Module#addFunction(name: string
, params: Type
, results: Type
, vars: Type[]
, body: ExpressionRef
): FunctionRef
Adds a function. vars
indicate additional locals, in the given order.
Module#getFunction(name: string
): FunctionRef
Gets a function, by name,
Module#removeFunction(name: string
): void
Removes a function, by name.
Module#getNumFunctions(): number
Gets the number of functions within the module.
Module#getFunctionByIndex(index: number
): FunctionRef
Gets the function at the specified index.
Module#addFunctionImport(internalName: string
, externalModuleName: string
, externalBaseName: string
, params: Type
, results: Type
): void
Adds a function import.
Module#addTableImport(internalName: string
, externalModuleName: string
, externalBaseName: string
): void
Adds a table import. There's just one table for now, using name "0"
.
Module#addMemoryImport(internalName: string
, externalModuleName: string
, externalBaseName: string
): void
Adds a memory import. There's just one memory for now, using name "0"
.
Module#addGlobalImport(internalName: string
, externalModuleName: string
, externalBaseName: string
, globalType: Type
): void
Adds a global variable import. Imported globals must be immutable.
Module#addFunctionExport(internalName: string
, externalName: string
): ExportRef
Adds a function export.
Module#addTableExport(internalName: string
, externalName: string
): ExportRef
Adds a table export. There's just one table for now, using name "0"
.
Module#addMemoryExport(internalName: string
, externalName: string
): ExportRef
Adds a memory export. There's just one memory for now, using name "0"
.
Module#addGlobalExport(internalName: string
, externalName: string
): ExportRef
Adds a global variable export. Exported globals must be immutable.
Module#getNumExports(): number
Gets the number of exports witin the module.
Module#getExportByIndex(index: number
): ExportRef
Gets the export at the specified index.
Module#removeExport(externalName: string
): void
Removes an export, by external name.
Module#addGlobal(name: string
, type: Type
, mutable: number
, value: ExpressionRef
): GlobalRef
Adds a global instance variable.
Module#getGlobal(name: string
): GlobalRef
Gets a global, by name,
Module#removeGlobal(name: string
): void
Removes a global, by name.
Module#setMemory(initial: number
, maximum: number
, exportName: string | null
, segments: MemorySegment[]
, shared?: boolean
): void
Sets the memory. There's just one memory for now, using name "0"
. Providing exportName
also creates a memory export.
ExpressionRef
Uint8Array
boolean
Module#getNumMemorySegments(): number
Gets the number of memory segments within the module.
Module#getMemorySegmentInfoByIndex(index: number
): MemorySegmentInfo
Gets information about the memory segment at the specified index.
number
Uint8Array
boolean
Module#setStart(start: FunctionRef
): void
Sets the start function.
Module#getFeatures(): Features
Gets the WebAssembly features enabled for this module.
Note that the return value may be a bitmask indicating multiple features. Possible feature flags are:
Features
Features
Features
Features
Features
Features
Features
Features
Features
Features
Features
Features
Module#setFeatures(features: Features
): void
Sets the WebAssembly features enabled for this module.
Module#addCustomSection(name: string
, contents: Uint8Array
): void
Adds a custom section to the binary.
Module#autoDrop(): void
Enables automatic insertion of drop
operations where needed. Lets you not worry about dropping when creating your code.
getFunctionInfo(ftype: FunctionRef
: FunctionInfo
Obtains information about a function.
string
string | null
(if imported)string | null
(if imported)Type
Type
Type
ExpressionRef
getGlobalInfo(global: GlobalRef
): GlobalInfo
Obtains information about a global.
string
string | null
(if imported)string | null
(if imported)Type
boolean
ExpressionRef
getTableInfo(table: TableRef
): TableInfo
Obtains information about a table.
string
string | null
(if imported)string | null
(if imported)number
;number
;getExportInfo(export_: ExportRef
): ExportInfo
Obtains information about an export.
ExternalKind
string
string
Possible ExternalKind
values are:
ExternalKind
ExternalKind
ExternalKind
ExternalKind
ExternalKind
getTagInfo(tag: TagRef
): TagInfo
Obtains information about a tag.
string
string | null
(if imported)string | null
(if imported)Type
Type
getSideEffects(expr: ExpressionRef
, features: FeatureFlags
): SideEffects
Gets the side effects of the specified expression.
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
SideEffects
boolean
true
if valid, otherwise prints validation errors and returns false
.Module#optimize(): void
Optimizes the module using the default optimization passes.
Module#optimizeFunction(func: FunctionRef | 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: FunctionRef | string
, passes: string[]
): void
Runs the specified passes on a single function.
getOptimizeLevel(): number
Gets the currently set optimize level. 0
, 1
, 2
correspond to -O0
, -O1
, -O2
(default), etc.
setOptimizeLevel(level: number
): void
Sets the optimization level to use. 0
, 1
, 2
correspond to -O0
, -O1
, -O2
(default), etc.
getShrinkLevel(): number
Gets the currently set shrink level. 0
, 1
, 2
correspond to -O0
, -Os
(default), -Oz
.
setShrinkLevel(level: number
): void
Sets the shrink level to use. 0
, 1
, 2
correspond to -O0
, -Os
(default), -Oz
.
getDebugInfo(): boolean
Gets whether generating debug information is currently enabled or not.
setDebugInfo(on: boolean
): void
Enables or disables debug information in emitted binaries.
getLowMemoryUnused(): boolean
Gets whether the low 1K of memory can be considered unused when optimizing.
setLowMemoryUnused(on: boolean
): void
Enables or disables whether the low 1K of memory can be considered unused when optimizing.
getPassArgument(key: string
): string | null
Gets the value of the specified arbitrary pass argument.
setPassArgument(key: string
, value: string | null
): void
Sets the value of the specified arbitrary pass argument. Removes the respective argument if value
is null
.
clearPassArguments(): void
Clears all arbitrary pass arguments.
getAlwaysInlineMaxSize(): number
Gets the function size at which we always inline.
setAlwaysInlineMaxSize(size: number
): void
Sets the function size at which we always inline.
getFlexibleInlineMaxSize(): number
Gets the function size which we inline when functions are lightweight.
setFlexibleInlineMaxSize(size: number
): void
Sets the function size which we inline when functions are lightweight.
getOneCallerInlineMaxSize(): number
Gets the function size which we inline when there is only one caller.
setOneCallerInlineMaxSize(size: number
): void
Sets the function size which we inline when there is only one caller.
Module#emitBinary(): Uint8Array
Returns the module in binary format.
Module#emitBinary(sourceMapUrl: string | null
): BinaryWithSourceMap
Returns the module in binary format with its source map. If sourceMapUrl
is null
, source map generation is skipped.
Uint8Array
string | null
Module#emitText(): string
Returns the module in Binaryen's s-expression text format (not official stack-style text format).
Module#emitStackIR(optimize?: boolean
): string
Returns the module in official stack-style text format.
Module#emitAsmjs(): string
Returns the asm.js representation of the module.
Module#dispose(): void
Releases the resources held by the module once it isn't needed anymore.
Module#block(label: string | null
, children: ExpressionRef[]
, resultType?: Type
): ExpressionRef
Creates a block. resultType
defaults to none
.
Module#if(condition: ExpressionRef
, ifTrue: ExpressionRef
, ifFalse?: ExpressionRef
): ExpressionRef
Creates an if or if/else combination.
Module#loop(label: string | null
, body: ExpressionRef
): ExpressionRef
Creates a loop.
Module#br(label: string
, condition?: ExpressionRef
, value?: ExpressionRef
): ExpressionRef
Creates a branch (br) to a label.
Module#switch(labels: string[]
, defaultLabel: string
, condition: ExpressionRef
, value?: ExpressionRef
): ExpressionRef
Creates a switch (br_table).
Module#nop(): ExpressionRef
Creates a no-operation (nop) instruction.
Module#return(value?: ExpressionRef
): ExpressionRef
Creates a return.
Module#unreachable(): ExpressionRef
Creates an unreachable instruction that will always trap.
Module#drop(value: ExpressionRef
): ExpressionRef
Creates a drop of a value.
Module#select(condition: ExpressionRef
, ifTrue: ExpressionRef
, ifFalse: ExpressionRef
, type?: Type
): ExpressionRef
Creates a select of one of two values.
Module#local.get(index: number
, type: Type
): ExpressionRef
Creates a local.get for the local at the specified index. Note that we must specify the type here as we may not have created the local being accessed yet.
Module#local.set(index: number
, value: ExpressionRef
): ExpressionRef
Creates a local.set for the local at the specified index.
Module#local.tee(index: number
, value: ExpressionRef
, type: Type
): ExpressionRef
Creates a local.tee for the local at the specified index. A tee differs from a set in that the value remains on the stack. Note that we must specify the type here as we may not have created the local being accessed yet.
Module#global.get(name: string
, type: Type
): ExpressionRef
Creates a global.get for the global with the specified name. Note that we must specify the type here as we may not have created the global being accessed yet.
Module#global.set(name: string
, value: ExpressionRef
): ExpressionRef
Creates a global.set for the global with the specified name.
number
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
number
, high: number
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
number
): ExpressionRef
number
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
number
): ExpressionRef
number
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
Module#call(name: string
, operands: ExpressionRef[]
, returnType: Type
): ExpressionRef
Creates a call to a function. Note that we must specify the return type here as we may not have created the function being called yet.
Module#return_call(name: string
, operands: ExpressionRef[]
, returnType: Type
): ExpressionRef
Like call, but creates a tail-call. 🦄
Module#call_indirect(target: ExpressionRef
, operands: ExpressionRef[]
, params: Type
, results: Type
): ExpressionRef
Similar to call, but calls indirectly, i.e., via a function pointer, so an expression replaces the name as the called value.
Module#return_call_indirect(target: ExpressionRef
, operands: ExpressionRef[]
, params: Type
, results: Type
): ExpressionRef
Like call_indirect, but creates a tail-call. 🦄
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
ExpressionRef
number
): ExpressionRef
Uint8Array
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
, cond: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
, value: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
, value: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
, value: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
, value: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, shift: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
, value: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, b: ExpressionRef
, c: ExpressionRef
): ExpressionRef
ExpressionRef
, b: ExpressionRef
, c: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
ExpressionRef
, index: number
, value: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, b: ExpressionRef
, c: ExpressionRef
): ExpressionRef
ExpressionRef
, b: ExpressionRef
, c: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
, right: ExpressionRef
, mask: Uint8Array
): ExpressionRef
ExpressionRef
, right: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, align: number
, ptr: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, expected: ExpressionRef
, replacement: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, expected: ExpressionRef
, replacement: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, expected: ExpressionRef
, replacement: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, expected: ExpressionRef
, replacement: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, expected: ExpressionRef
, replacement: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, expected: ExpressionRef
, replacement: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, value: ExpressionRef
): ExpressionRef
number
, ptr: ExpressionRef
, expected: ExpressionRef
, replacement: ExpressionRef
): ExpressionRef
ExpressionRef
, expected: ExpressionRef
, timeout: ExpressionRef
): ExpressionRef
ExpressionRef
, expected: ExpressionRef
, timeout: ExpressionRef
): ExpressionRef
ExpressionRef
, notifyCount: ExpressionRef
): ExpressionRef
ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
ExpressionRef
): ExpressionRef
Note that these are pseudo instructions enabling Binaryen to reason about multiple values on the stack.
ExpressionRef
): ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef[]
): ExpressionRef
ExpressionRef
, index: number
): ExpressionRef
string
, body: ExpressionRef
, catchTags: string[]
, catchBodies: ExpressionRef[]
, delegateTarget?: string
): ExpressionRef
string
, operands: ExpressionRef[]
): ExpressionRef
string
): ExpressionRef
string
, params: Type
, results: Type
): TagRef
string
): TagRef
stirng
): void
string
, externalModuleName: string
, externalBaseName: string
, params: Type
, results: Type
): void
string
, externalName: string
): ExportRef
ExpressionRef
ExpressionRef
): ExpressionRef
string
): ExpressionRef
string
, dest: ExpressionRef
, offset: ExpressionRef
, size: ExpressionRef
): ExpressionRef
ExpressionRef
, source: ExpressionRef
, size: ExpressionRef
): ExpressionRef
ExpressionRef
, value: ExpressionRef
, size: ExpressionRef
): ExpressionRef
string
): ExpressionRef
getExpressionId(expr: ExpressionRef
): ExpressionId
Gets the id (kind) of the specified expression. Possible values are:
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
ExpressionId
getExpressionType(expr: ExpressionRef
): Type
Gets the type of the specified expression.
getExpressionInfo(expr: ExpressionRef
): ExpressionInfo
Obtains information about an expression, always including:
ExpressionId
Type
Additional properties depend on the expression's id
and are usually equivalent to the respective parameters when creating such an expression:
string
ExpressionRef[]
ExpressionRef
ExpressionRef
ExpressionRef | null
string
ExpressionRef
string
ExpressionRef | null
ExpressionRef | null
string[]
string | null
ExpressionRef
ExpressionRef | null
string
ExpressionRef[]
string
ExpressionRef[]
ExpressionRef
ExpressionRef[]
number
boolean
number
ExpressionRef
string
string
ExpressionRef
boolean
boolean
number
number
number
ExpressionRef
boolean
number
number
number
ExpressionRef
ExpressionRef
number | { low: number, high: number }
number
ExpressionRef
number
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef | null
ExpressionRef
number
number
number
ExpressionRef
ExpressionRef
number
number
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
Type
ExpressionRef
ExpressionRef
Op
ExpressionRef
ExpressionRef
Op
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
Uint8Array
Op
ExpressionRef
ExpressionRef
ExpressionRef
Op
ExpressionRef
ExpressionRef
Op
number
number
ExpressionRef
number
ExpressionRef
ExpressionRef
ExpressionRef
number
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
ExpressionRef
Operations
ExpressionRef
Operations
ExpressionRef
string
ExpressionRef
ExpressionRef
string
ExpressionRef
ExpressionRef[]
ExpressionRef[]
;boolean
;string
;boolean
;string
ExpressionRef[]
string
ExpressionRef[]
ExpressionRef
number
ExpressionRef
ExpressionRef
boolean
ExpressionRef
emitText(expression: ExpressionRef
): string
Emits the expression in Binaryen's s-expression text format (not official stack-style text format).
copyExpression(expression: ExpressionRef
): ExpressionRef
Creates a deep copy of an expression.
new Relooper()
Constructs a relooper instance. This lets you provide an arbitrary CFG, and the relooper will structure it for WebAssembly.
Relooper#addBlock(code: ExpressionRef
): RelooperBlockRef
Adds a new block to the CFG, containing the provided code as its body.
Relooper#addBranch(from: RelooperBlockRef
, to: RelooperBlockRef
, condition: ExpressionRef
, code: ExpressionRef
): 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: ExpressionRef
, condition: ExpressionRef
): RelooperBlockRef
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: RelooperBlockRef
, to: RelooperBlockRef
, indexes: number[]
, code: ExpressionRef
): 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: RelooperBlockRef
, labelHelper: number
, module: Module
): ExpressionRef
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.
Module#addDebugInfoFileName(filename: string
): number
Adds a debug info file name to the module and returns its index.
Module#getDebugInfoFileName(index: number
): string | null
Gets the name of the debug info file at the specified index.
Module#setDebugLocation(func: FunctionRef
, expr: ExpressionRef
, fileIndex: number
, lineNumber: number
, columnNumber: number
): void
Sets the debug location of the specified ExpressionRef
within the specified FunctionRef
.
void
© 2010 - cnpmjs.org x YWFE | Home | YWFE