How to use the @webassemblyjs/ast.assertHasLoc function in @webassemblyjs/ast

To help you get started, we’ve selected a few @webassemblyjs/ast 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 / wasm-edit / src / apply.js View on Github external
function shiftLocNodeByDelta(node: Node, delta: number) {
  assertHasLoc(node);

  // $FlowIgnore: assertHasLoc ensures that
  node.loc.start.column += delta;
  // $FlowIgnore: assertHasLoc ensures that
  node.loc.end.column += delta;
}
github xtuc / webassemblyjs / packages / wasm-edit / src / apply.js View on Github external
function applyDelete(ast: Program, uint8Buffer: Uint8Array, node: Node): State {
  const deltaElements = -1; // since we removed an element

  assertHasLoc(node);

  const sectionName = getSectionForNode(node);

  if (sectionName === "start") {
    const sectionMetadata = getSectionMetadata(ast, "start");

    /**
     * The start section only contains one element,
     * we need to remove the whole section
     */
    uint8Buffer = removeSections(ast, uint8Buffer, "start");

    const deltaBytes = -(sectionMetadata.size.value + 1); /* section id */

    return { uint8Buffer, deltaBytes, deltaElements };
  }
github zc910704 / Vue.js-personal-note / www / day6.1.webpack的url-loader与babel / node_modules / @webassemblyjs / wasm-edit / esm / apply.js View on Github external
function applyUpdate(ast, uint8Buffer, _ref) {
  var _ref2 = _slicedToArray(_ref, 2),
      oldNode = _ref2[0],
      newNode = _ref2[1];

  var deltaElements = 0;
  assertHasLoc(oldNode);
  var sectionName = getSectionForNode(newNode);
  var replacementByteArray = encodeNode(newNode);
  /**
   * Replace new node as bytes
   */

  uint8Buffer = overrideBytesInBuffer(uint8Buffer, // $FlowIgnore: assertHasLoc ensures that
  oldNode.loc.start.column, // $FlowIgnore: assertHasLoc ensures that
  oldNode.loc.end.column, replacementByteArray);
  /**
   * Update function body size if needed
   */

  if (sectionName === "code") {
    // Find the parent func
    traverse(ast, {
github xtuc / webassemblyjs / packages / wasm-edit / src / apply.js View on Github external
function shiftLocNodeByDelta(node: Node, delta: number) {
  assertHasLoc(node);

  // $FlowIgnore: assertHasLoc ensures that
  node.loc.start.column += delta;
  // $FlowIgnore: assertHasLoc ensures that
  node.loc.end.column += delta;
}
github zc910704 / Vue.js-personal-note / www / day6.1.webpack的url-loader与babel / node_modules / @webassemblyjs / wasm-edit / esm / apply.js View on Github external
function applyDelete(ast, uint8Buffer, node) {
  var deltaElements = -1; // since we removed an element

  assertHasLoc(node);
  var sectionName = getSectionForNode(node);

  if (sectionName === "start") {
    var sectionMetadata = getSectionMetadata(ast, "start");
    /**
     * The start section only contains one element,
     * we need to remove the whole section
     */

    uint8Buffer = removeSections(ast, uint8Buffer, "start");

    var _deltaBytes = -(sectionMetadata.size.value + 1)
    /* section id */
    ;

    return {
github xtuc / webassemblyjs / packages / wasm-edit / src / apply.js View on Github external
Func({ node }) {
        const funcHasThisIntr =
          node.body.find(n => n === newNode) !== undefined;

        // Update func's body size if needed
        if (funcHasThisIntr === true) {
          // These are the old functions locations informations
          assertHasLoc(node);

          const oldNodeSize = encodeNode(oldNode).length;
          const bodySizeDeltaBytes = replacementByteArray.length - oldNodeSize;

          if (bodySizeDeltaBytes !== 0) {
            const newValue = node.metadata.bodySize + bodySizeDeltaBytes;
            const newByteArray = encodeU32(newValue);

            debug("resize func body newValue=%d", newValue);

            // function body size byte
            // FIXME(sven): only handles one byte u32
            const start = node.loc.start.column;
            const end = start + 1;

            uint8Buffer = overrideBytesInBuffer(
github flaviuse / mern-authentication / client / node_modules / @webassemblyjs / wasm-edit / esm / apply.js View on Github external
function applyUpdate(ast, uint8Buffer, _ref) {
  var _ref2 = _slicedToArray(_ref, 2),
      oldNode = _ref2[0],
      newNode = _ref2[1];

  var deltaElements = 0;
  assertHasLoc(oldNode);
  var sectionName = getSectionForNode(newNode);
  var replacementByteArray = encodeNode(newNode);
  /**
   * Replace new node as bytes
   */

  uint8Buffer = overrideBytesInBuffer(uint8Buffer, // $FlowIgnore: assertHasLoc ensures that
  oldNode.loc.start.column, // $FlowIgnore: assertHasLoc ensures that
  oldNode.loc.end.column, replacementByteArray);
  /**
   * Update function body size if needed
   */

  if (sectionName === "code") {
    // Find the parent func
    traverse(ast, {
github xtuc / webassemblyjs / packages / wasm-edit / src / apply.js View on Github external
function applyUpdate(
  ast: Program,
  uint8Buffer: Uint8Array,
  [oldNode, newNode]: [Node, Node]
): State {
  const deltaElements = 0;

  assertHasLoc(oldNode);

  const sectionName = getSectionForNode(newNode);
  const replacementByteArray = encodeNode(newNode);

  /**
   * Replace new node as bytes
   */
  uint8Buffer = overrideBytesInBuffer(
    uint8Buffer,
    // $FlowIgnore: assertHasLoc ensures that
    oldNode.loc.start.column,
    // $FlowIgnore: assertHasLoc ensures that
    oldNode.loc.end.column,
    replacementByteArray
  );
github zc910704 / Vue.js-personal-note / www / day6.1.webpack的url-loader与babel / node_modules / @webassemblyjs / wasm-edit / esm / apply.js View on Github external
function shiftLocNodeByDelta(node, delta) {
  assertHasLoc(node); // $FlowIgnore: assertHasLoc ensures that

  node.loc.start.column += delta; // $FlowIgnore: assertHasLoc ensures that

  node.loc.end.column += delta;
}