Sha256: bea2e81b181d5b8a7ed453ce80c81510ab5b3652b18e59f2960f511633ec7947

Contents?: true

Size: 1.61 KB

Versions: 27

Compression:

Stored size: 1.61 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.shrinkPaddedLEB128 = shrinkPaddedLEB128;

var _ast = require("@webassemblyjs/ast");

var _encoder = require("@webassemblyjs/wasm-gen/lib/encoder");

var _helperBuffer = require("@webassemblyjs/helper-buffer");

function shiftFollowingSections(ast, _ref, deltaInSizeEncoding) {
  var section = _ref.section;
  // Once we hit our section every that is after needs to be shifted by the delta
  var encounteredSection = false;
  (0, _ast.traverse)(ast, {
    SectionMetadata: function SectionMetadata(path) {
      if (path.node.section === section) {
        encounteredSection = true;
        return;
      }

      if (encounteredSection === true) {
        (0, _ast.shiftSection)(ast, path.node, deltaInSizeEncoding);
      }
    }
  });
}

function shrinkPaddedLEB128(ast, uint8Buffer) {
  (0, _ast.traverse)(ast, {
    SectionMetadata: function SectionMetadata(_ref2) {
      var node = _ref2.node;

      /**
       * Section size
       */
      {
        var newu32Encoded = (0, _encoder.encodeU32)(node.size.value);
        var newu32EncodedLen = newu32Encoded.length;
        var start = node.size.loc.start.column;
        var end = node.size.loc.end.column;
        var oldu32EncodedLen = end - start;

        if (newu32EncodedLen !== oldu32EncodedLen) {
          var deltaInSizeEncoding = oldu32EncodedLen - newu32EncodedLen;
          uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start, end, newu32Encoded);
          shiftFollowingSections(ast, node, -deltaInSizeEncoding);
        }
      }
    }
  });
  return uint8Buffer;
}

Version data entries

27 entries across 26 versions & 9 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
disco_app-0.18.0 test/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
disco_app-0.18.2 test/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
disco_app-0.16.1 test/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
disco_app-0.15.2 test/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
disco_app-0.18.4 test/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
disco_app-0.18.1 test/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
disco_app-0.14.0 test/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
tang-0.2.1 spec/tang_app/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
tang-0.2.0 spec/tang_app/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
tang-0.1.0 spec/tang_app/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
tang-0.0.9 spec/tang_app/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
enju_library-0.3.8 spec/dummy/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js
jester-data-8.0.0 node_modules/@webassemblyjs/wasm-opt/lib/leb128.js