You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
2.1 KiB

4 years ago
  1. 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); }
  2. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  3. 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; }
  4. 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; }
  5. import { decode } from "@webassemblyjs/wasm-parser";
  6. import { shrinkPaddedLEB128 as makeShrinkPaddedLEB128 } from "./leb128.js";
  7. var OptimizerError =
  8. /*#__PURE__*/
  9. function (_Error) {
  10. _inherits(OptimizerError, _Error);
  11. function OptimizerError(name, initalError) {
  12. var _this;
  13. _classCallCheck(this, OptimizerError);
  14. _this = _possibleConstructorReturn(this, (OptimizerError.__proto__ || Object.getPrototypeOf(OptimizerError)).call(this, "Error while optimizing: " + name + ": " + initalError.message));
  15. _this.stack = initalError.stack;
  16. return _this;
  17. }
  18. return OptimizerError;
  19. }(Error);
  20. var decoderOpts = {
  21. ignoreCodeSection: true,
  22. ignoreDataSection: true
  23. };
  24. export function shrinkPaddedLEB128(uint8Buffer) {
  25. try {
  26. var ast = decode(uint8Buffer.buffer, decoderOpts);
  27. return makeShrinkPaddedLEB128(ast, uint8Buffer);
  28. } catch (e) {
  29. throw new OptimizerError("shrinkPaddedLEB128", e);
  30. }
  31. }