[79a0317] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | function _typeof(obj) { "@babel/helpers - typeof"; 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); }
|
---|
| 4 |
|
---|
| 5 | Object.defineProperty(exports, "__esModule", {
|
---|
| 6 | value: true
|
---|
| 7 | });
|
---|
| 8 | exports.encodeNode = encodeNode;
|
---|
| 9 | exports.encodeU32 = void 0;
|
---|
| 10 |
|
---|
| 11 | var encoder = _interopRequireWildcard(require("./encoder"));
|
---|
| 12 |
|
---|
| 13 | function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
---|
| 14 |
|
---|
| 15 | function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
---|
| 16 |
|
---|
| 17 | function encodeNode(n) {
|
---|
| 18 | switch (n.type) {
|
---|
| 19 | case "ModuleImport":
|
---|
| 20 | // $FlowIgnore: ModuleImport ensure that the node is well formated
|
---|
| 21 | return encoder.encodeModuleImport(n);
|
---|
| 22 |
|
---|
| 23 | case "SectionMetadata":
|
---|
| 24 | // $FlowIgnore: SectionMetadata ensure that the node is well formated
|
---|
| 25 | return encoder.encodeSectionMetadata(n);
|
---|
| 26 |
|
---|
| 27 | case "CallInstruction":
|
---|
| 28 | // $FlowIgnore: SectionMetadata ensure that the node is well formated
|
---|
| 29 | return encoder.encodeCallInstruction(n);
|
---|
| 30 |
|
---|
| 31 | case "CallIndirectInstruction":
|
---|
| 32 | // $FlowIgnore: SectionMetadata ensure that the node is well formated
|
---|
| 33 | return encoder.encodeCallIndirectInstruction(n);
|
---|
| 34 |
|
---|
| 35 | case "TypeInstruction":
|
---|
| 36 | return encoder.encodeTypeInstruction(n);
|
---|
| 37 |
|
---|
| 38 | case "Instr":
|
---|
| 39 | // $FlowIgnore
|
---|
| 40 | return encoder.encodeInstr(n);
|
---|
| 41 |
|
---|
| 42 | case "ModuleExport":
|
---|
| 43 | // $FlowIgnore: SectionMetadata ensure that the node is well formated
|
---|
| 44 | return encoder.encodeModuleExport(n);
|
---|
| 45 |
|
---|
| 46 | case "Global":
|
---|
| 47 | // $FlowIgnore
|
---|
| 48 | return encoder.encodeGlobal(n);
|
---|
| 49 |
|
---|
| 50 | case "Func":
|
---|
| 51 | return encoder.encodeFuncBody(n);
|
---|
| 52 |
|
---|
| 53 | case "IndexInFuncSection":
|
---|
| 54 | return encoder.encodeIndexInFuncSection(n);
|
---|
| 55 |
|
---|
| 56 | case "StringLiteral":
|
---|
| 57 | return encoder.encodeStringLiteral(n);
|
---|
| 58 |
|
---|
| 59 | case "Elem":
|
---|
| 60 | return encoder.encodeElem(n);
|
---|
| 61 |
|
---|
| 62 | default:
|
---|
| 63 | throw new Error("Unsupported encoding for node of type: " + JSON.stringify(n.type));
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | var encodeU32 = encoder.encodeU32;
|
---|
| 68 | exports.encodeU32 = encodeU32; |
---|