How to use the @webassemblyjs/helper-wasm-section.resizeSectionByteSize function in @webassemblyjs/helper-wasm-section

To help you get started, we’ve selected a few @webassemblyjs/helper-wasm-section 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 flaviuse / mern-authentication / client / node_modules / @webassemblyjs / wasm-edit / esm / apply.js View on Github external
var oldBufferLength = state.uint8Buffer.length;
      state.uint8Buffer = resizeSectionVecSize(ast, state.uint8Buffer, sectionName, state.deltaElements); // Infer bytes added/removed by comparing buffer lengths

      state.deltaBytes += state.uint8Buffer.length - oldBufferLength;
    }
    /**
     * Resize section byte size.
     * If the length of the LEB-encoded size changes, this can change
     * the offset for nodes in the section. So we do this before
     * shifting following operations' nodes.
     */


    if (state.deltaBytes !== 0 && sectionName !== "start") {
      var _oldBufferLength = state.uint8Buffer.length;
      state.uint8Buffer = resizeSectionByteSize(ast, state.uint8Buffer, sectionName, state.deltaBytes); // Infer bytes added/removed by comparing buffer lengths

      state.deltaBytes += state.uint8Buffer.length - _oldBufferLength;
    }
    /**
     * Shift following operation's nodes
     */


    if (state.deltaBytes !== 0) {
      ops.forEach(function (op) {
        // We don't need to handle add ops, they are positioning independent
        switch (op.kind) {
          case "update":
            shiftLocNodeByDelta(op.oldNode, state.deltaBytes);
            break;
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
var oldBufferLength = state.uint8Buffer.length;
      state.uint8Buffer = resizeSectionVecSize(ast, state.uint8Buffer, sectionName, state.deltaElements); // Infer bytes added/removed by comparing buffer lengths

      state.deltaBytes += state.uint8Buffer.length - oldBufferLength;
    }
    /**
     * Resize section byte size.
     * If the length of the LEB-encoded size changes, this can change
     * the offset for nodes in the section. So we do this before
     * shifting following operations' nodes.
     */


    if (state.deltaBytes !== 0 && sectionName !== "start") {
      var _oldBufferLength = state.uint8Buffer.length;
      state.uint8Buffer = resizeSectionByteSize(ast, state.uint8Buffer, sectionName, state.deltaBytes); // Infer bytes added/removed by comparing buffer lengths

      state.deltaBytes += state.uint8Buffer.length - _oldBufferLength;
    }
    /**
     * Shift following operation's nodes
     */


    if (state.deltaBytes !== 0) {
      ops.forEach(function (op) {
        // We don't need to handle add ops, they are positioning independent
        switch (op.kind) {
          case "update":
            shiftLocNodeByDelta(op.oldNode, state.deltaBytes);
            break;
github xtuc / webassemblyjs / packages / wasm-edit / src / apply.js View on Github external
sectionName,
        state.deltaElements
      );
      // Infer bytes added/removed by comparing buffer lengths
      state.deltaBytes += state.uint8Buffer.length - oldBufferLength;
    }

    /**
     * Resize section byte size.
     * If the length of the LEB-encoded size changes, this can change
     * the offset for nodes in the section. So we do this before
     * shifting following operations' nodes.
     */
    if (state.deltaBytes !== 0 && sectionName !== "start") {
      const oldBufferLength = state.uint8Buffer.length;
      state.uint8Buffer = resizeSectionByteSize(
        ast,
        state.uint8Buffer,
        sectionName,
        state.deltaBytes
      );
      // Infer bytes added/removed by comparing buffer lengths
      state.deltaBytes += state.uint8Buffer.length - oldBufferLength;
    }

    /**
     * Shift following operation's nodes
     */
    if (state.deltaBytes !== 0) {
      ops.forEach(op => {
        // We don't need to handle add ops, they are positioning independent
        switch (op.kind) {
github xtuc / webassemblyjs / packages / wasm-edit / src / apply.js View on Github external
*/
    if (state.deltaBytes !== 0) {
      ops.forEach(op => {
        switch (op.kind) {
          case "update":
            shiftLocNodeByDelta(op.oldNode, state.deltaBytes);
            break;

          case "delete":
            shiftLocNodeByDelta(op.node, state.deltaBytes);
            break;
        }
      });

      if (sectionName !== "start") {
        state.uint8Buffer = resizeSectionByteSize(
          ast,
          state.uint8Buffer,
          sectionName,
          state.deltaBytes
        );
      }
    }

    if (state.deltaElements !== 0 && sectionName !== "start") {
      state.uint8Buffer = resizeSectionVecSize(
        ast,
        state.uint8Buffer,
        sectionName,
        state.deltaElements
      );
    }