diff options
Diffstat (limited to 'node_modules/@webassemblyjs/wasm-opt/esm/index.js')
-rw-r--r-- | node_modules/@webassemblyjs/wasm-opt/esm/index.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/node_modules/@webassemblyjs/wasm-opt/esm/index.js b/node_modules/@webassemblyjs/wasm-opt/esm/index.js new file mode 100644 index 0000000..f9d9232 --- /dev/null +++ b/node_modules/@webassemblyjs/wasm-opt/esm/index.js @@ -0,0 +1,41 @@ +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); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +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; } + +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; } + +import { decode } from "@webassemblyjs/wasm-parser"; +import { shrinkPaddedLEB128 as makeShrinkPaddedLEB128 } from "./leb128.js"; + +var OptimizerError = +/*#__PURE__*/ +function (_Error) { + _inherits(OptimizerError, _Error); + + function OptimizerError(name, initalError) { + var _this; + + _classCallCheck(this, OptimizerError); + + _this = _possibleConstructorReturn(this, (OptimizerError.__proto__ || Object.getPrototypeOf(OptimizerError)).call(this, "Error while optimizing: " + name + ": " + initalError.message)); + _this.stack = initalError.stack; + return _this; + } + + return OptimizerError; +}(Error); + +var decoderOpts = { + ignoreCodeSection: true, + ignoreDataSection: true +}; +export function shrinkPaddedLEB128(uint8Buffer) { + try { + var ast = decode(uint8Buffer.buffer, decoderOpts); + return makeShrinkPaddedLEB128(ast, uint8Buffer); + } catch (e) { + throw new OptimizerError("shrinkPaddedLEB128", e); + } +}
\ No newline at end of file |