How to use @webassemblyjs/wast-printer - 4 common examples

To help you get started, we’ve selected a few @webassemblyjs/wast-printer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github xtuc / webassemblyjs / packages / cli / src / wast-to-wasm-semantics.js View on Github external
const { print } = require("@webassemblyjs/wast-printer");
const { readFileSync } = require("fs");

const filename = process.argv[2];

if (typeof filename === "undefined") {
  throw new Error("Missing file");
}

const content = readFileSync(filename, "utf8");
const ast = parse(content);

denormalizeTypeReferences.transform(ast);
wastIdentifierToIndex.transform(ast);

console.log(print(ast));
github zc910704 / Vue.js-personal-note / www / day6.1.webpack的url-loader与babel / node_modules / @webassemblyjs / helper-code-frame / esm / index.js View on Github external
export function codeFrameFromAst(ast, loc) {
  return codeFrameFromSource(print(ast), loc);
}
export function codeFrameFromSource(source, loc) {
github xtuc / webassemblyjs / packages / helper-code-frame / src / index.js View on Github external
export function codeFrameFromAst(ast: Program, loc: SourceLocation): string {
  return codeFrameFromSource(print(ast), loc);
}
github xtuc / webassemblyjs / packages / cli / src / wasm2wast.js View on Github external
#!/usr/bin/env node
const { readFileSync } = require("fs");
const { decode } = require("@webassemblyjs/wasm-parser");
const { print } = require("@webassemblyjs/wast-printer");

function toArrayBuffer(buf) {
  return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
}

const filename = process.argv[2];

const buff = toArrayBuffer(readFileSync(filename, null));
const ast = decode(buff);

const wast = print(ast);

process.stdout.write(wast);

@webassemblyjs/wast-printer

WebAssembly text format printer

MIT
Latest version published 2 months ago

Package Health Score

88 / 100
Full package analysis

Popular @webassemblyjs/wast-printer functions