source: trip-planner-front/node_modules/@webassemblyjs/wasm-opt/lib/leb128.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[6a3a178]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.shrinkPaddedLEB128 = shrinkPaddedLEB128;
7
8var _ast = require("@webassemblyjs/ast");
9
10var _encoder = require("@webassemblyjs/wasm-gen/lib/encoder");
11
12var _helperBuffer = require("@webassemblyjs/helper-buffer");
13
14function shiftFollowingSections(ast, _ref, deltaInSizeEncoding) {
15 var section = _ref.section;
16 // Once we hit our section every that is after needs to be shifted by the delta
17 var encounteredSection = false;
18 (0, _ast.traverse)(ast, {
19 SectionMetadata: function SectionMetadata(path) {
20 if (path.node.section === section) {
21 encounteredSection = true;
22 return;
23 }
24
25 if (encounteredSection === true) {
26 (0, _ast.shiftSection)(ast, path.node, deltaInSizeEncoding);
27 }
28 }
29 });
30}
31
32function shrinkPaddedLEB128(ast, uint8Buffer) {
33 (0, _ast.traverse)(ast, {
34 SectionMetadata: function SectionMetadata(_ref2) {
35 var node = _ref2.node;
36
37 /**
38 * Section size
39 */
40 {
41 var newu32Encoded = (0, _encoder.encodeU32)(node.size.value);
42 var newu32EncodedLen = newu32Encoded.length;
43 var start = node.size.loc.start.column;
44 var end = node.size.loc.end.column;
45 var oldu32EncodedLen = end - start;
46
47 if (newu32EncodedLen !== oldu32EncodedLen) {
48 var deltaInSizeEncoding = oldu32EncodedLen - newu32EncodedLen;
49 uint8Buffer = (0, _helperBuffer.overrideBytesInBuffer)(uint8Buffer, start, end, newu32Encoded);
50 shiftFollowingSections(ast, node, -deltaInSizeEncoding);
51 }
52 }
53 }
54 });
55 return uint8Buffer;
56}
Note: See TracBrowser for help on using the repository browser.