Package Exports
- @webassemblyjs/ast
- @webassemblyjs/ast/lib/clone
- @webassemblyjs/ast/lib/signatures
- @webassemblyjs/ast/lib/transform/wast-identifier-to-index
- @webassemblyjs/ast/lib/traverse
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@webassemblyjs/ast) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@webassemblyjs/ast
AST utils for webassemblyjs
Installation
npm install @webassemblyjs/ast
Usage
Traverse
import { traverse } from "@webassemblyjs/ast";
traverse(ast, {
Module(path) {
console.log(path.node);
}
});
Traverse and partial evaluation
import { traverse } from "@webassemblyjs/ast";
traverse(ast, {
Func(path) {
const res = path.evaluate();
}
});
// Or by specified an array of node
traverse(ast, {
Global(path) {
const res = path.evaluate(path.node.init);
}
});
Instruction signatures
import { signatures } from "@webassemblyjs/ast";
console.log(signatures);
AST Nodes
- function
signature(object, name)
- function
identifier(value)
- function
valtype(name)
- function
stringLiteral(value)
- function
program(body)
- function
module(id, fields)
- function
binaryModule(id, blob)
- function
quoteModule(id, string)
- function
moduleExport(name, type, id)
- function
func(name, params, result, body)
- function
objectInstruction(id, object, args, namedArgs)
- function
instruction(id, args, namedArgs)
- function
loopInstruction(label, resulttype, instr)
- function
blockInstruction(label, instr, result)
- function
numberLiteral(rawValue, instructionType)
- function
callInstruction(index, instrArgs)
- function
ifInstruction(testLabel, result, test, consequent, alternate)
- function
withLoc(n, end, start)
- function
moduleImport(module, name, descr)
- function
globalImportDescr(valtype, mutability)
- function
funcParam(valtype, id)
- function
funcImportDescr(id, params, results)
- function
table(elementType, limits, name, elements)
- function
limits(min, max)
- function
memory(limits, id)
- function
data(memoryIndex, offset, init)
- function
global(globalType, init, name)
- function
globalType(valtype, mutability)
- function
byteArray(values)
- function
leadingComment(value)
- function
blockComment(value)
- function
indexLiteral(value)
- function
memIndexLiteral(value)
- function
typeInstructionFunc(params, result, id)
- function
callIndirectInstruction(params, results, intrs)
- function
start(index)
- function
elem(table, offset, funcs)