Projekt

Obecné

Profil

Stáhnout (2.23 KB) Statistiky
| Větev: | Revize:
1
"use strict";
2

    
3
Object.defineProperty(exports, "__esModule", {
4
  value: true
5
});
6
exports.shrinkPaddedLEB128 = shrinkPaddedLEB128;
7

    
8
var _wasmParser = require("@webassemblyjs/wasm-parser");
9

    
10
var _leb = require("./leb128.js");
11

    
12
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
13

    
14
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15

    
16
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
17

    
18
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
19

    
20
var OptimizerError =
21
/*#__PURE__*/
22
function (_Error) {
23
  _inherits(OptimizerError, _Error);
24

    
25
  function OptimizerError(name, initalError) {
26
    var _this;
27

    
28
    _classCallCheck(this, OptimizerError);
29

    
30
    _this = _possibleConstructorReturn(this, (OptimizerError.__proto__ || Object.getPrototypeOf(OptimizerError)).call(this, "Error while optimizing: " + name + ": " + initalError.message));
31
    _this.stack = initalError.stack;
32
    return _this;
33
  }
34

    
35
  return OptimizerError;
36
}(Error);
37

    
38
var decoderOpts = {
39
  ignoreCodeSection: true,
40
  ignoreDataSection: true
41
};
42

    
43
function shrinkPaddedLEB128(uint8Buffer) {
44
  try {
45
    var ast = (0, _wasmParser.decode)(uint8Buffer.buffer, decoderOpts);
46
    return (0, _leb.shrinkPaddedLEB128)(ast, uint8Buffer);
47
  } catch (e) {
48
    throw new OptimizerError("shrinkPaddedLEB128", e);
49
  }
50
}
(1-1/2)