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