1 |
9bb1e829
|
cagy
|
"use strict";
|
2 |
|
|
|
3 |
|
|
Object.defineProperty(exports, "__esModule", {
|
4 |
|
|
value: true
|
5 |
|
|
});
|
6 |
|
|
exports.module = _module;
|
7 |
|
|
exports.moduleMetadata = moduleMetadata;
|
8 |
|
|
exports.moduleNameMetadata = moduleNameMetadata;
|
9 |
|
|
exports.functionNameMetadata = functionNameMetadata;
|
10 |
|
|
exports.localNameMetadata = localNameMetadata;
|
11 |
|
|
exports.binaryModule = binaryModule;
|
12 |
|
|
exports.quoteModule = quoteModule;
|
13 |
|
|
exports.sectionMetadata = sectionMetadata;
|
14 |
|
|
exports.producersSectionMetadata = producersSectionMetadata;
|
15 |
|
|
exports.producerMetadata = producerMetadata;
|
16 |
|
|
exports.producerMetadataVersionedName = producerMetadataVersionedName;
|
17 |
|
|
exports.loopInstruction = loopInstruction;
|
18 |
|
|
exports.instr = instr;
|
19 |
|
|
exports.ifInstruction = ifInstruction;
|
20 |
|
|
exports.stringLiteral = stringLiteral;
|
21 |
|
|
exports.numberLiteral = numberLiteral;
|
22 |
|
|
exports.longNumberLiteral = longNumberLiteral;
|
23 |
|
|
exports.floatLiteral = floatLiteral;
|
24 |
|
|
exports.elem = elem;
|
25 |
|
|
exports.indexInFuncSection = indexInFuncSection;
|
26 |
|
|
exports.valtypeLiteral = valtypeLiteral;
|
27 |
|
|
exports.typeInstruction = typeInstruction;
|
28 |
|
|
exports.start = start;
|
29 |
|
|
exports.globalType = globalType;
|
30 |
|
|
exports.leadingComment = leadingComment;
|
31 |
|
|
exports.blockComment = blockComment;
|
32 |
|
|
exports.data = data;
|
33 |
|
|
exports.global = global;
|
34 |
|
|
exports.table = table;
|
35 |
|
|
exports.memory = memory;
|
36 |
|
|
exports.funcImportDescr = funcImportDescr;
|
37 |
|
|
exports.moduleImport = moduleImport;
|
38 |
|
|
exports.moduleExportDescr = moduleExportDescr;
|
39 |
|
|
exports.moduleExport = moduleExport;
|
40 |
|
|
exports.limit = limit;
|
41 |
|
|
exports.signature = signature;
|
42 |
|
|
exports.program = program;
|
43 |
|
|
exports.identifier = identifier;
|
44 |
|
|
exports.blockInstruction = blockInstruction;
|
45 |
|
|
exports.callInstruction = callInstruction;
|
46 |
|
|
exports.callIndirectInstruction = callIndirectInstruction;
|
47 |
|
|
exports.byteArray = byteArray;
|
48 |
|
|
exports.func = func;
|
49 |
|
|
exports.internalBrUnless = internalBrUnless;
|
50 |
|
|
exports.internalGoto = internalGoto;
|
51 |
|
|
exports.internalCallExtern = internalCallExtern;
|
52 |
|
|
exports.internalEndAndReturn = internalEndAndReturn;
|
53 |
|
|
exports.assertInternalCallExtern = exports.assertInternalGoto = exports.assertInternalBrUnless = exports.assertFunc = exports.assertByteArray = exports.assertCallIndirectInstruction = exports.assertCallInstruction = exports.assertBlockInstruction = exports.assertIdentifier = exports.assertProgram = exports.assertSignature = exports.assertLimit = exports.assertModuleExport = exports.assertModuleExportDescr = exports.assertModuleImport = exports.assertFuncImportDescr = exports.assertMemory = exports.assertTable = exports.assertGlobal = exports.assertData = exports.assertBlockComment = exports.assertLeadingComment = exports.assertGlobalType = exports.assertStart = exports.assertTypeInstruction = exports.assertValtypeLiteral = exports.assertIndexInFuncSection = exports.assertElem = exports.assertFloatLiteral = exports.assertLongNumberLiteral = exports.assertNumberLiteral = exports.assertStringLiteral = exports.assertIfInstruction = exports.assertInstr = exports.assertLoopInstruction = exports.assertProducerMetadataVersionedName = exports.assertProducerMetadata = exports.assertProducersSectionMetadata = exports.assertSectionMetadata = exports.assertQuoteModule = exports.assertBinaryModule = exports.assertLocalNameMetadata = exports.assertFunctionNameMetadata = exports.assertModuleNameMetadata = exports.assertModuleMetadata = exports.assertModule = exports.isIntrinsic = exports.isImportDescr = exports.isNumericLiteral = exports.isExpression = exports.isInstruction = exports.isBlock = exports.isNode = exports.isInternalEndAndReturn = exports.isInternalCallExtern = exports.isInternalGoto = exports.isInternalBrUnless = exports.isFunc = exports.isByteArray = exports.isCallIndirectInstruction = exports.isCallInstruction = exports.isBlockInstruction = exports.isIdentifier = exports.isProgram = exports.isSignature = exports.isLimit = exports.isModuleExport = exports.isModuleExportDescr = exports.isModuleImport = exports.isFuncImportDescr = exports.isMemory = exports.isTable = exports.isGlobal = exports.isData = exports.isBlockComment = exports.isLeadingComment = exports.isGlobalType = exports.isStart = exports.isTypeInstruction = exports.isValtypeLiteral = exports.isIndexInFuncSection = exports.isElem = exports.isFloatLiteral = exports.isLongNumberLiteral = exports.isNumberLiteral = exports.isStringLiteral = exports.isIfInstruction = exports.isInstr = exports.isLoopInstruction = exports.isProducerMetadataVersionedName = exports.isProducerMetadata = exports.isProducersSectionMetadata = exports.isSectionMetadata = exports.isQuoteModule = exports.isBinaryModule = exports.isLocalNameMetadata = exports.isFunctionNameMetadata = exports.isModuleNameMetadata = exports.isModuleMetadata = exports.isModule = void 0;
|
54 |
|
|
exports.nodeAndUnionTypes = exports.unionTypesMap = exports.assertInternalEndAndReturn = void 0;
|
55 |
|
|
|
56 |
|
|
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); }
|
57 |
|
|
|
58 |
|
|
// THIS FILE IS AUTOGENERATED
|
59 |
|
|
// see scripts/generateNodeUtils.js
|
60 |
|
|
function isTypeOf(t) {
|
61 |
|
|
return function (n) {
|
62 |
|
|
return n.type === t;
|
63 |
|
|
};
|
64 |
|
|
}
|
65 |
|
|
|
66 |
|
|
function assertTypeOf(t) {
|
67 |
|
|
return function (n) {
|
68 |
|
|
return function () {
|
69 |
|
|
if (!(n.type === t)) {
|
70 |
|
|
throw new Error('n.type === t' + " error: " + (undefined || "unknown"));
|
71 |
|
|
}
|
72 |
|
|
}();
|
73 |
|
|
};
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
function _module(id, fields, metadata) {
|
77 |
|
|
if (id !== null && id !== undefined) {
|
78 |
|
|
if (!(typeof id === "string")) {
|
79 |
|
|
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
80 |
|
|
}
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
if (!(_typeof(fields) === "object" && typeof fields.length !== "undefined")) {
|
84 |
|
|
throw new Error('typeof fields === "object" && typeof fields.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
var node = {
|
88 |
|
|
type: "Module",
|
89 |
|
|
id: id,
|
90 |
|
|
fields: fields
|
91 |
|
|
};
|
92 |
|
|
|
93 |
|
|
if (typeof metadata !== "undefined") {
|
94 |
|
|
node.metadata = metadata;
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
return node;
|
98 |
|
|
}
|
99 |
|
|
|
100 |
|
|
function moduleMetadata(sections, functionNames, localNames, producers) {
|
101 |
|
|
if (!(_typeof(sections) === "object" && typeof sections.length !== "undefined")) {
|
102 |
|
|
throw new Error('typeof sections === "object" && typeof sections.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
if (functionNames !== null && functionNames !== undefined) {
|
106 |
|
|
if (!(_typeof(functionNames) === "object" && typeof functionNames.length !== "undefined")) {
|
107 |
|
|
throw new Error('typeof functionNames === "object" && typeof functionNames.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
108 |
|
|
}
|
109 |
|
|
}
|
110 |
|
|
|
111 |
|
|
if (localNames !== null && localNames !== undefined) {
|
112 |
|
|
if (!(_typeof(localNames) === "object" && typeof localNames.length !== "undefined")) {
|
113 |
|
|
throw new Error('typeof localNames === "object" && typeof localNames.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
114 |
|
|
}
|
115 |
|
|
}
|
116 |
|
|
|
117 |
|
|
if (producers !== null && producers !== undefined) {
|
118 |
|
|
if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) {
|
119 |
|
|
throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
120 |
|
|
}
|
121 |
|
|
}
|
122 |
|
|
|
123 |
|
|
var node = {
|
124 |
|
|
type: "ModuleMetadata",
|
125 |
|
|
sections: sections
|
126 |
|
|
};
|
127 |
|
|
|
128 |
|
|
if (typeof functionNames !== "undefined" && functionNames.length > 0) {
|
129 |
|
|
node.functionNames = functionNames;
|
130 |
|
|
}
|
131 |
|
|
|
132 |
|
|
if (typeof localNames !== "undefined" && localNames.length > 0) {
|
133 |
|
|
node.localNames = localNames;
|
134 |
|
|
}
|
135 |
|
|
|
136 |
|
|
if (typeof producers !== "undefined" && producers.length > 0) {
|
137 |
|
|
node.producers = producers;
|
138 |
|
|
}
|
139 |
|
|
|
140 |
|
|
return node;
|
141 |
|
|
}
|
142 |
|
|
|
143 |
|
|
function moduleNameMetadata(value) {
|
144 |
|
|
if (!(typeof value === "string")) {
|
145 |
|
|
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
var node = {
|
149 |
|
|
type: "ModuleNameMetadata",
|
150 |
|
|
value: value
|
151 |
|
|
};
|
152 |
|
|
return node;
|
153 |
|
|
}
|
154 |
|
|
|
155 |
|
|
function functionNameMetadata(value, index) {
|
156 |
|
|
if (!(typeof value === "string")) {
|
157 |
|
|
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
158 |
|
|
}
|
159 |
|
|
|
160 |
|
|
if (!(typeof index === "number")) {
|
161 |
|
|
throw new Error('typeof index === "number"' + " error: " + ("Argument index must be of type number, given: " + _typeof(index) || "unknown"));
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
var node = {
|
165 |
|
|
type: "FunctionNameMetadata",
|
166 |
|
|
value: value,
|
167 |
|
|
index: index
|
168 |
|
|
};
|
169 |
|
|
return node;
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
function localNameMetadata(value, localIndex, functionIndex) {
|
173 |
|
|
if (!(typeof value === "string")) {
|
174 |
|
|
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
175 |
|
|
}
|
176 |
|
|
|
177 |
|
|
if (!(typeof localIndex === "number")) {
|
178 |
|
|
throw new Error('typeof localIndex === "number"' + " error: " + ("Argument localIndex must be of type number, given: " + _typeof(localIndex) || "unknown"));
|
179 |
|
|
}
|
180 |
|
|
|
181 |
|
|
if (!(typeof functionIndex === "number")) {
|
182 |
|
|
throw new Error('typeof functionIndex === "number"' + " error: " + ("Argument functionIndex must be of type number, given: " + _typeof(functionIndex) || "unknown"));
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
var node = {
|
186 |
|
|
type: "LocalNameMetadata",
|
187 |
|
|
value: value,
|
188 |
|
|
localIndex: localIndex,
|
189 |
|
|
functionIndex: functionIndex
|
190 |
|
|
};
|
191 |
|
|
return node;
|
192 |
|
|
}
|
193 |
|
|
|
194 |
|
|
function binaryModule(id, blob) {
|
195 |
|
|
if (id !== null && id !== undefined) {
|
196 |
|
|
if (!(typeof id === "string")) {
|
197 |
|
|
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
198 |
|
|
}
|
199 |
|
|
}
|
200 |
|
|
|
201 |
|
|
if (!(_typeof(blob) === "object" && typeof blob.length !== "undefined")) {
|
202 |
|
|
throw new Error('typeof blob === "object" && typeof blob.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
203 |
|
|
}
|
204 |
|
|
|
205 |
|
|
var node = {
|
206 |
|
|
type: "BinaryModule",
|
207 |
|
|
id: id,
|
208 |
|
|
blob: blob
|
209 |
|
|
};
|
210 |
|
|
return node;
|
211 |
|
|
}
|
212 |
|
|
|
213 |
|
|
function quoteModule(id, string) {
|
214 |
|
|
if (id !== null && id !== undefined) {
|
215 |
|
|
if (!(typeof id === "string")) {
|
216 |
|
|
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
217 |
|
|
}
|
218 |
|
|
}
|
219 |
|
|
|
220 |
|
|
if (!(_typeof(string) === "object" && typeof string.length !== "undefined")) {
|
221 |
|
|
throw new Error('typeof string === "object" && typeof string.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
var node = {
|
225 |
|
|
type: "QuoteModule",
|
226 |
|
|
id: id,
|
227 |
|
|
string: string
|
228 |
|
|
};
|
229 |
|
|
return node;
|
230 |
|
|
}
|
231 |
|
|
|
232 |
|
|
function sectionMetadata(section, startOffset, size, vectorOfSize) {
|
233 |
|
|
if (!(typeof startOffset === "number")) {
|
234 |
|
|
throw new Error('typeof startOffset === "number"' + " error: " + ("Argument startOffset must be of type number, given: " + _typeof(startOffset) || "unknown"));
|
235 |
|
|
}
|
236 |
|
|
|
237 |
|
|
var node = {
|
238 |
|
|
type: "SectionMetadata",
|
239 |
|
|
section: section,
|
240 |
|
|
startOffset: startOffset,
|
241 |
|
|
size: size,
|
242 |
|
|
vectorOfSize: vectorOfSize
|
243 |
|
|
};
|
244 |
|
|
return node;
|
245 |
|
|
}
|
246 |
|
|
|
247 |
|
|
function producersSectionMetadata(producers) {
|
248 |
|
|
if (!(_typeof(producers) === "object" && typeof producers.length !== "undefined")) {
|
249 |
|
|
throw new Error('typeof producers === "object" && typeof producers.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
250 |
|
|
}
|
251 |
|
|
|
252 |
|
|
var node = {
|
253 |
|
|
type: "ProducersSectionMetadata",
|
254 |
|
|
producers: producers
|
255 |
|
|
};
|
256 |
|
|
return node;
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
function producerMetadata(language, processedBy, sdk) {
|
260 |
|
|
if (!(_typeof(language) === "object" && typeof language.length !== "undefined")) {
|
261 |
|
|
throw new Error('typeof language === "object" && typeof language.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
262 |
|
|
}
|
263 |
|
|
|
264 |
|
|
if (!(_typeof(processedBy) === "object" && typeof processedBy.length !== "undefined")) {
|
265 |
|
|
throw new Error('typeof processedBy === "object" && typeof processedBy.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
266 |
|
|
}
|
267 |
|
|
|
268 |
|
|
if (!(_typeof(sdk) === "object" && typeof sdk.length !== "undefined")) {
|
269 |
|
|
throw new Error('typeof sdk === "object" && typeof sdk.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
270 |
|
|
}
|
271 |
|
|
|
272 |
|
|
var node = {
|
273 |
|
|
type: "ProducerMetadata",
|
274 |
|
|
language: language,
|
275 |
|
|
processedBy: processedBy,
|
276 |
|
|
sdk: sdk
|
277 |
|
|
};
|
278 |
|
|
return node;
|
279 |
|
|
}
|
280 |
|
|
|
281 |
|
|
function producerMetadataVersionedName(name, version) {
|
282 |
|
|
if (!(typeof name === "string")) {
|
283 |
|
|
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
284 |
|
|
}
|
285 |
|
|
|
286 |
|
|
if (!(typeof version === "string")) {
|
287 |
|
|
throw new Error('typeof version === "string"' + " error: " + ("Argument version must be of type string, given: " + _typeof(version) || "unknown"));
|
288 |
|
|
}
|
289 |
|
|
|
290 |
|
|
var node = {
|
291 |
|
|
type: "ProducerMetadataVersionedName",
|
292 |
|
|
name: name,
|
293 |
|
|
version: version
|
294 |
|
|
};
|
295 |
|
|
return node;
|
296 |
|
|
}
|
297 |
|
|
|
298 |
|
|
function loopInstruction(label, resulttype, instr) {
|
299 |
|
|
if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) {
|
300 |
|
|
throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
301 |
|
|
}
|
302 |
|
|
|
303 |
|
|
var node = {
|
304 |
|
|
type: "LoopInstruction",
|
305 |
|
|
id: "loop",
|
306 |
|
|
label: label,
|
307 |
|
|
resulttype: resulttype,
|
308 |
|
|
instr: instr
|
309 |
|
|
};
|
310 |
|
|
return node;
|
311 |
|
|
}
|
312 |
|
|
|
313 |
|
|
function instr(id, object, args, namedArgs) {
|
314 |
|
|
if (!(typeof id === "string")) {
|
315 |
|
|
throw new Error('typeof id === "string"' + " error: " + ("Argument id must be of type string, given: " + _typeof(id) || "unknown"));
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
if (!(_typeof(args) === "object" && typeof args.length !== "undefined")) {
|
319 |
|
|
throw new Error('typeof args === "object" && typeof args.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
320 |
|
|
}
|
321 |
|
|
|
322 |
|
|
var node = {
|
323 |
|
|
type: "Instr",
|
324 |
|
|
id: id,
|
325 |
|
|
args: args
|
326 |
|
|
};
|
327 |
|
|
|
328 |
|
|
if (typeof object !== "undefined") {
|
329 |
|
|
node.object = object;
|
330 |
|
|
}
|
331 |
|
|
|
332 |
|
|
if (typeof namedArgs !== "undefined" && Object.keys(namedArgs).length !== 0) {
|
333 |
|
|
node.namedArgs = namedArgs;
|
334 |
|
|
}
|
335 |
|
|
|
336 |
|
|
return node;
|
337 |
|
|
}
|
338 |
|
|
|
339 |
|
|
function ifInstruction(testLabel, test, result, consequent, alternate) {
|
340 |
|
|
if (!(_typeof(test) === "object" && typeof test.length !== "undefined")) {
|
341 |
|
|
throw new Error('typeof test === "object" && typeof test.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
342 |
|
|
}
|
343 |
|
|
|
344 |
|
|
if (!(_typeof(consequent) === "object" && typeof consequent.length !== "undefined")) {
|
345 |
|
|
throw new Error('typeof consequent === "object" && typeof consequent.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
346 |
|
|
}
|
347 |
|
|
|
348 |
|
|
if (!(_typeof(alternate) === "object" && typeof alternate.length !== "undefined")) {
|
349 |
|
|
throw new Error('typeof alternate === "object" && typeof alternate.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
350 |
|
|
}
|
351 |
|
|
|
352 |
|
|
var node = {
|
353 |
|
|
type: "IfInstruction",
|
354 |
|
|
id: "if",
|
355 |
|
|
testLabel: testLabel,
|
356 |
|
|
test: test,
|
357 |
|
|
result: result,
|
358 |
|
|
consequent: consequent,
|
359 |
|
|
alternate: alternate
|
360 |
|
|
};
|
361 |
|
|
return node;
|
362 |
|
|
}
|
363 |
|
|
|
364 |
|
|
function stringLiteral(value) {
|
365 |
|
|
if (!(typeof value === "string")) {
|
366 |
|
|
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
367 |
|
|
}
|
368 |
|
|
|
369 |
|
|
var node = {
|
370 |
|
|
type: "StringLiteral",
|
371 |
|
|
value: value
|
372 |
|
|
};
|
373 |
|
|
return node;
|
374 |
|
|
}
|
375 |
|
|
|
376 |
|
|
function numberLiteral(value, raw) {
|
377 |
|
|
if (!(typeof value === "number")) {
|
378 |
|
|
throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown"));
|
379 |
|
|
}
|
380 |
|
|
|
381 |
|
|
if (!(typeof raw === "string")) {
|
382 |
|
|
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
383 |
|
|
}
|
384 |
|
|
|
385 |
|
|
var node = {
|
386 |
|
|
type: "NumberLiteral",
|
387 |
|
|
value: value,
|
388 |
|
|
raw: raw
|
389 |
|
|
};
|
390 |
|
|
return node;
|
391 |
|
|
}
|
392 |
|
|
|
393 |
|
|
function longNumberLiteral(value, raw) {
|
394 |
|
|
if (!(typeof raw === "string")) {
|
395 |
|
|
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
396 |
|
|
}
|
397 |
|
|
|
398 |
|
|
var node = {
|
399 |
|
|
type: "LongNumberLiteral",
|
400 |
|
|
value: value,
|
401 |
|
|
raw: raw
|
402 |
|
|
};
|
403 |
|
|
return node;
|
404 |
|
|
}
|
405 |
|
|
|
406 |
|
|
function floatLiteral(value, nan, inf, raw) {
|
407 |
|
|
if (!(typeof value === "number")) {
|
408 |
|
|
throw new Error('typeof value === "number"' + " error: " + ("Argument value must be of type number, given: " + _typeof(value) || "unknown"));
|
409 |
|
|
}
|
410 |
|
|
|
411 |
|
|
if (nan !== null && nan !== undefined) {
|
412 |
|
|
if (!(typeof nan === "boolean")) {
|
413 |
|
|
throw new Error('typeof nan === "boolean"' + " error: " + ("Argument nan must be of type boolean, given: " + _typeof(nan) || "unknown"));
|
414 |
|
|
}
|
415 |
|
|
}
|
416 |
|
|
|
417 |
|
|
if (inf !== null && inf !== undefined) {
|
418 |
|
|
if (!(typeof inf === "boolean")) {
|
419 |
|
|
throw new Error('typeof inf === "boolean"' + " error: " + ("Argument inf must be of type boolean, given: " + _typeof(inf) || "unknown"));
|
420 |
|
|
}
|
421 |
|
|
}
|
422 |
|
|
|
423 |
|
|
if (!(typeof raw === "string")) {
|
424 |
|
|
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
425 |
|
|
}
|
426 |
|
|
|
427 |
|
|
var node = {
|
428 |
|
|
type: "FloatLiteral",
|
429 |
|
|
value: value,
|
430 |
|
|
raw: raw
|
431 |
|
|
};
|
432 |
|
|
|
433 |
|
|
if (nan === true) {
|
434 |
|
|
node.nan = true;
|
435 |
|
|
}
|
436 |
|
|
|
437 |
|
|
if (inf === true) {
|
438 |
|
|
node.inf = true;
|
439 |
|
|
}
|
440 |
|
|
|
441 |
|
|
return node;
|
442 |
|
|
}
|
443 |
|
|
|
444 |
|
|
function elem(table, offset, funcs) {
|
445 |
|
|
if (!(_typeof(offset) === "object" && typeof offset.length !== "undefined")) {
|
446 |
|
|
throw new Error('typeof offset === "object" && typeof offset.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
447 |
|
|
}
|
448 |
|
|
|
449 |
|
|
if (!(_typeof(funcs) === "object" && typeof funcs.length !== "undefined")) {
|
450 |
|
|
throw new Error('typeof funcs === "object" && typeof funcs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
451 |
|
|
}
|
452 |
|
|
|
453 |
|
|
var node = {
|
454 |
|
|
type: "Elem",
|
455 |
|
|
table: table,
|
456 |
|
|
offset: offset,
|
457 |
|
|
funcs: funcs
|
458 |
|
|
};
|
459 |
|
|
return node;
|
460 |
|
|
}
|
461 |
|
|
|
462 |
|
|
function indexInFuncSection(index) {
|
463 |
|
|
var node = {
|
464 |
|
|
type: "IndexInFuncSection",
|
465 |
|
|
index: index
|
466 |
|
|
};
|
467 |
|
|
return node;
|
468 |
|
|
}
|
469 |
|
|
|
470 |
|
|
function valtypeLiteral(name) {
|
471 |
|
|
var node = {
|
472 |
|
|
type: "ValtypeLiteral",
|
473 |
|
|
name: name
|
474 |
|
|
};
|
475 |
|
|
return node;
|
476 |
|
|
}
|
477 |
|
|
|
478 |
|
|
function typeInstruction(id, functype) {
|
479 |
|
|
var node = {
|
480 |
|
|
type: "TypeInstruction",
|
481 |
|
|
id: id,
|
482 |
|
|
functype: functype
|
483 |
|
|
};
|
484 |
|
|
return node;
|
485 |
|
|
}
|
486 |
|
|
|
487 |
|
|
function start(index) {
|
488 |
|
|
var node = {
|
489 |
|
|
type: "Start",
|
490 |
|
|
index: index
|
491 |
|
|
};
|
492 |
|
|
return node;
|
493 |
|
|
}
|
494 |
|
|
|
495 |
|
|
function globalType(valtype, mutability) {
|
496 |
|
|
var node = {
|
497 |
|
|
type: "GlobalType",
|
498 |
|
|
valtype: valtype,
|
499 |
|
|
mutability: mutability
|
500 |
|
|
};
|
501 |
|
|
return node;
|
502 |
|
|
}
|
503 |
|
|
|
504 |
|
|
function leadingComment(value) {
|
505 |
|
|
if (!(typeof value === "string")) {
|
506 |
|
|
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
507 |
|
|
}
|
508 |
|
|
|
509 |
|
|
var node = {
|
510 |
|
|
type: "LeadingComment",
|
511 |
|
|
value: value
|
512 |
|
|
};
|
513 |
|
|
return node;
|
514 |
|
|
}
|
515 |
|
|
|
516 |
|
|
function blockComment(value) {
|
517 |
|
|
if (!(typeof value === "string")) {
|
518 |
|
|
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
519 |
|
|
}
|
520 |
|
|
|
521 |
|
|
var node = {
|
522 |
|
|
type: "BlockComment",
|
523 |
|
|
value: value
|
524 |
|
|
};
|
525 |
|
|
return node;
|
526 |
|
|
}
|
527 |
|
|
|
528 |
|
|
function data(memoryIndex, offset, init) {
|
529 |
|
|
var node = {
|
530 |
|
|
type: "Data",
|
531 |
|
|
memoryIndex: memoryIndex,
|
532 |
|
|
offset: offset,
|
533 |
|
|
init: init
|
534 |
|
|
};
|
535 |
|
|
return node;
|
536 |
|
|
}
|
537 |
|
|
|
538 |
|
|
function global(globalType, init, name) {
|
539 |
|
|
if (!(_typeof(init) === "object" && typeof init.length !== "undefined")) {
|
540 |
|
|
throw new Error('typeof init === "object" && typeof init.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
541 |
|
|
}
|
542 |
|
|
|
543 |
|
|
var node = {
|
544 |
|
|
type: "Global",
|
545 |
|
|
globalType: globalType,
|
546 |
|
|
init: init,
|
547 |
|
|
name: name
|
548 |
|
|
};
|
549 |
|
|
return node;
|
550 |
|
|
}
|
551 |
|
|
|
552 |
|
|
function table(elementType, limits, name, elements) {
|
553 |
|
|
if (!(limits.type === "Limit")) {
|
554 |
|
|
throw new Error('limits.type === "Limit"' + " error: " + ("Argument limits must be of type Limit, given: " + limits.type || "unknown"));
|
555 |
|
|
}
|
556 |
|
|
|
557 |
|
|
if (elements !== null && elements !== undefined) {
|
558 |
|
|
if (!(_typeof(elements) === "object" && typeof elements.length !== "undefined")) {
|
559 |
|
|
throw new Error('typeof elements === "object" && typeof elements.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
560 |
|
|
}
|
561 |
|
|
}
|
562 |
|
|
|
563 |
|
|
var node = {
|
564 |
|
|
type: "Table",
|
565 |
|
|
elementType: elementType,
|
566 |
|
|
limits: limits,
|
567 |
|
|
name: name
|
568 |
|
|
};
|
569 |
|
|
|
570 |
|
|
if (typeof elements !== "undefined" && elements.length > 0) {
|
571 |
|
|
node.elements = elements;
|
572 |
|
|
}
|
573 |
|
|
|
574 |
|
|
return node;
|
575 |
|
|
}
|
576 |
|
|
|
577 |
|
|
function memory(limits, id) {
|
578 |
|
|
var node = {
|
579 |
|
|
type: "Memory",
|
580 |
|
|
limits: limits,
|
581 |
|
|
id: id
|
582 |
|
|
};
|
583 |
|
|
return node;
|
584 |
|
|
}
|
585 |
|
|
|
586 |
|
|
function funcImportDescr(id, signature) {
|
587 |
|
|
var node = {
|
588 |
|
|
type: "FuncImportDescr",
|
589 |
|
|
id: id,
|
590 |
|
|
signature: signature
|
591 |
|
|
};
|
592 |
|
|
return node;
|
593 |
|
|
}
|
594 |
|
|
|
595 |
|
|
function moduleImport(module, name, descr) {
|
596 |
|
|
if (!(typeof module === "string")) {
|
597 |
|
|
throw new Error('typeof module === "string"' + " error: " + ("Argument module must be of type string, given: " + _typeof(module) || "unknown"));
|
598 |
|
|
}
|
599 |
|
|
|
600 |
|
|
if (!(typeof name === "string")) {
|
601 |
|
|
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
602 |
|
|
}
|
603 |
|
|
|
604 |
|
|
var node = {
|
605 |
|
|
type: "ModuleImport",
|
606 |
|
|
module: module,
|
607 |
|
|
name: name,
|
608 |
|
|
descr: descr
|
609 |
|
|
};
|
610 |
|
|
return node;
|
611 |
|
|
}
|
612 |
|
|
|
613 |
|
|
function moduleExportDescr(exportType, id) {
|
614 |
|
|
var node = {
|
615 |
|
|
type: "ModuleExportDescr",
|
616 |
|
|
exportType: exportType,
|
617 |
|
|
id: id
|
618 |
|
|
};
|
619 |
|
|
return node;
|
620 |
|
|
}
|
621 |
|
|
|
622 |
|
|
function moduleExport(name, descr) {
|
623 |
|
|
if (!(typeof name === "string")) {
|
624 |
|
|
throw new Error('typeof name === "string"' + " error: " + ("Argument name must be of type string, given: " + _typeof(name) || "unknown"));
|
625 |
|
|
}
|
626 |
|
|
|
627 |
|
|
var node = {
|
628 |
|
|
type: "ModuleExport",
|
629 |
|
|
name: name,
|
630 |
|
|
descr: descr
|
631 |
|
|
};
|
632 |
|
|
return node;
|
633 |
|
|
}
|
634 |
|
|
|
635 |
|
|
function limit(min, max) {
|
636 |
|
|
if (!(typeof min === "number")) {
|
637 |
|
|
throw new Error('typeof min === "number"' + " error: " + ("Argument min must be of type number, given: " + _typeof(min) || "unknown"));
|
638 |
|
|
}
|
639 |
|
|
|
640 |
|
|
if (max !== null && max !== undefined) {
|
641 |
|
|
if (!(typeof max === "number")) {
|
642 |
|
|
throw new Error('typeof max === "number"' + " error: " + ("Argument max must be of type number, given: " + _typeof(max) || "unknown"));
|
643 |
|
|
}
|
644 |
|
|
}
|
645 |
|
|
|
646 |
|
|
var node = {
|
647 |
|
|
type: "Limit",
|
648 |
|
|
min: min
|
649 |
|
|
};
|
650 |
|
|
|
651 |
|
|
if (typeof max !== "undefined") {
|
652 |
|
|
node.max = max;
|
653 |
|
|
}
|
654 |
|
|
|
655 |
|
|
return node;
|
656 |
|
|
}
|
657 |
|
|
|
658 |
|
|
function signature(params, results) {
|
659 |
|
|
if (!(_typeof(params) === "object" && typeof params.length !== "undefined")) {
|
660 |
|
|
throw new Error('typeof params === "object" && typeof params.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
661 |
|
|
}
|
662 |
|
|
|
663 |
|
|
if (!(_typeof(results) === "object" && typeof results.length !== "undefined")) {
|
664 |
|
|
throw new Error('typeof results === "object" && typeof results.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
665 |
|
|
}
|
666 |
|
|
|
667 |
|
|
var node = {
|
668 |
|
|
type: "Signature",
|
669 |
|
|
params: params,
|
670 |
|
|
results: results
|
671 |
|
|
};
|
672 |
|
|
return node;
|
673 |
|
|
}
|
674 |
|
|
|
675 |
|
|
function program(body) {
|
676 |
|
|
if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
|
677 |
|
|
throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
678 |
|
|
}
|
679 |
|
|
|
680 |
|
|
var node = {
|
681 |
|
|
type: "Program",
|
682 |
|
|
body: body
|
683 |
|
|
};
|
684 |
|
|
return node;
|
685 |
|
|
}
|
686 |
|
|
|
687 |
|
|
function identifier(value, raw) {
|
688 |
|
|
if (!(typeof value === "string")) {
|
689 |
|
|
throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
|
690 |
|
|
}
|
691 |
|
|
|
692 |
|
|
if (raw !== null && raw !== undefined) {
|
693 |
|
|
if (!(typeof raw === "string")) {
|
694 |
|
|
throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
|
695 |
|
|
}
|
696 |
|
|
}
|
697 |
|
|
|
698 |
|
|
var node = {
|
699 |
|
|
type: "Identifier",
|
700 |
|
|
value: value
|
701 |
|
|
};
|
702 |
|
|
|
703 |
|
|
if (typeof raw !== "undefined") {
|
704 |
|
|
node.raw = raw;
|
705 |
|
|
}
|
706 |
|
|
|
707 |
|
|
return node;
|
708 |
|
|
}
|
709 |
|
|
|
710 |
|
|
function blockInstruction(label, instr, result) {
|
711 |
|
|
if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) {
|
712 |
|
|
throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
713 |
|
|
}
|
714 |
|
|
|
715 |
|
|
var node = {
|
716 |
|
|
type: "BlockInstruction",
|
717 |
|
|
id: "block",
|
718 |
|
|
label: label,
|
719 |
|
|
instr: instr,
|
720 |
|
|
result: result
|
721 |
|
|
};
|
722 |
|
|
return node;
|
723 |
|
|
}
|
724 |
|
|
|
725 |
|
|
function callInstruction(index, instrArgs, numeric) {
|
726 |
|
|
if (instrArgs !== null && instrArgs !== undefined) {
|
727 |
|
|
if (!(_typeof(instrArgs) === "object" && typeof instrArgs.length !== "undefined")) {
|
728 |
|
|
throw new Error('typeof instrArgs === "object" && typeof instrArgs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
729 |
|
|
}
|
730 |
|
|
}
|
731 |
|
|
|
732 |
|
|
var node = {
|
733 |
|
|
type: "CallInstruction",
|
734 |
|
|
id: "call",
|
735 |
|
|
index: index
|
736 |
|
|
};
|
737 |
|
|
|
738 |
|
|
if (typeof instrArgs !== "undefined" && instrArgs.length > 0) {
|
739 |
|
|
node.instrArgs = instrArgs;
|
740 |
|
|
}
|
741 |
|
|
|
742 |
|
|
if (typeof numeric !== "undefined") {
|
743 |
|
|
node.numeric = numeric;
|
744 |
|
|
}
|
745 |
|
|
|
746 |
|
|
return node;
|
747 |
|
|
}
|
748 |
|
|
|
749 |
|
|
function callIndirectInstruction(signature, intrs) {
|
750 |
|
|
if (intrs !== null && intrs !== undefined) {
|
751 |
|
|
if (!(_typeof(intrs) === "object" && typeof intrs.length !== "undefined")) {
|
752 |
|
|
throw new Error('typeof intrs === "object" && typeof intrs.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
753 |
|
|
}
|
754 |
|
|
}
|
755 |
|
|
|
756 |
|
|
var node = {
|
757 |
|
|
type: "CallIndirectInstruction",
|
758 |
|
|
id: "call_indirect",
|
759 |
|
|
signature: signature
|
760 |
|
|
};
|
761 |
|
|
|
762 |
|
|
if (typeof intrs !== "undefined" && intrs.length > 0) {
|
763 |
|
|
node.intrs = intrs;
|
764 |
|
|
}
|
765 |
|
|
|
766 |
|
|
return node;
|
767 |
|
|
}
|
768 |
|
|
|
769 |
|
|
function byteArray(values) {
|
770 |
|
|
if (!(_typeof(values) === "object" && typeof values.length !== "undefined")) {
|
771 |
|
|
throw new Error('typeof values === "object" && typeof values.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
772 |
|
|
}
|
773 |
|
|
|
774 |
|
|
var node = {
|
775 |
|
|
type: "ByteArray",
|
776 |
|
|
values: values
|
777 |
|
|
};
|
778 |
|
|
return node;
|
779 |
|
|
}
|
780 |
|
|
|
781 |
|
|
function func(name, signature, body, isExternal, metadata) {
|
782 |
|
|
if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
|
783 |
|
|
throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
|
784 |
|
|
}
|
785 |
|
|
|
786 |
|
|
if (isExternal !== null && isExternal !== undefined) {
|
787 |
|
|
if (!(typeof isExternal === "boolean")) {
|
788 |
|
|
throw new Error('typeof isExternal === "boolean"' + " error: " + ("Argument isExternal must be of type boolean, given: " + _typeof(isExternal) || "unknown"));
|
789 |
|
|
}
|
790 |
|
|
}
|
791 |
|
|
|
792 |
|
|
var node = {
|
793 |
|
|
type: "Func",
|
794 |
|
|
name: name,
|
795 |
|
|
signature: signature,
|
796 |
|
|
body: body
|
797 |
|
|
};
|
798 |
|
|
|
799 |
|
|
if (isExternal === true) {
|
800 |
|
|
node.isExternal = true;
|
801 |
|
|
}
|
802 |
|
|
|
803 |
|
|
if (typeof metadata !== "undefined") {
|
804 |
|
|
node.metadata = metadata;
|
805 |
|
|
}
|
806 |
|
|
|
807 |
|
|
return node;
|
808 |
|
|
}
|
809 |
|
|
|
810 |
|
|
function internalBrUnless(target) {
|
811 |
|
|
if (!(typeof target === "number")) {
|
812 |
|
|
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
813 |
|
|
}
|
814 |
|
|
|
815 |
|
|
var node = {
|
816 |
|
|
type: "InternalBrUnless",
|
817 |
|
|
target: target
|
818 |
|
|
};
|
819 |
|
|
return node;
|
820 |
|
|
}
|
821 |
|
|
|
822 |
|
|
function internalGoto(target) {
|
823 |
|
|
if (!(typeof target === "number")) {
|
824 |
|
|
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
825 |
|
|
}
|
826 |
|
|
|
827 |
|
|
var node = {
|
828 |
|
|
type: "InternalGoto",
|
829 |
|
|
target: target
|
830 |
|
|
};
|
831 |
|
|
return node;
|
832 |
|
|
}
|
833 |
|
|
|
834 |
|
|
function internalCallExtern(target) {
|
835 |
|
|
if (!(typeof target === "number")) {
|
836 |
|
|
throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
|
837 |
|
|
}
|
838 |
|
|
|
839 |
|
|
var node = {
|
840 |
|
|
type: "InternalCallExtern",
|
841 |
|
|
target: target
|
842 |
|
|
};
|
843 |
|
|
return node;
|
844 |
|
|
}
|
845 |
|
|
|
846 |
|
|
function internalEndAndReturn() {
|
847 |
|
|
var node = {
|
848 |
|
|
type: "InternalEndAndReturn"
|
849 |
|
|
};
|
850 |
|
|
return node;
|
851 |
|
|
}
|
852 |
|
|
|
853 |
|
|
var isModule = isTypeOf("Module");
|
854 |
|
|
exports.isModule = isModule;
|
855 |
|
|
var isModuleMetadata = isTypeOf("ModuleMetadata");
|
856 |
|
|
exports.isModuleMetadata = isModuleMetadata;
|
857 |
|
|
var isModuleNameMetadata = isTypeOf("ModuleNameMetadata");
|
858 |
|
|
exports.isModuleNameMetadata = isModuleNameMetadata;
|
859 |
|
|
var isFunctionNameMetadata = isTypeOf("FunctionNameMetadata");
|
860 |
|
|
exports.isFunctionNameMetadata = isFunctionNameMetadata;
|
861 |
|
|
var isLocalNameMetadata = isTypeOf("LocalNameMetadata");
|
862 |
|
|
exports.isLocalNameMetadata = isLocalNameMetadata;
|
863 |
|
|
var isBinaryModule = isTypeOf("BinaryModule");
|
864 |
|
|
exports.isBinaryModule = isBinaryModule;
|
865 |
|
|
var isQuoteModule = isTypeOf("QuoteModule");
|
866 |
|
|
exports.isQuoteModule = isQuoteModule;
|
867 |
|
|
var isSectionMetadata = isTypeOf("SectionMetadata");
|
868 |
|
|
exports.isSectionMetadata = isSectionMetadata;
|
869 |
|
|
var isProducersSectionMetadata = isTypeOf("ProducersSectionMetadata");
|
870 |
|
|
exports.isProducersSectionMetadata = isProducersSectionMetadata;
|
871 |
|
|
var isProducerMetadata = isTypeOf("ProducerMetadata");
|
872 |
|
|
exports.isProducerMetadata = isProducerMetadata;
|
873 |
|
|
var isProducerMetadataVersionedName = isTypeOf("ProducerMetadataVersionedName");
|
874 |
|
|
exports.isProducerMetadataVersionedName = isProducerMetadataVersionedName;
|
875 |
|
|
var isLoopInstruction = isTypeOf("LoopInstruction");
|
876 |
|
|
exports.isLoopInstruction = isLoopInstruction;
|
877 |
|
|
var isInstr = isTypeOf("Instr");
|
878 |
|
|
exports.isInstr = isInstr;
|
879 |
|
|
var isIfInstruction = isTypeOf("IfInstruction");
|
880 |
|
|
exports.isIfInstruction = isIfInstruction;
|
881 |
|
|
var isStringLiteral = isTypeOf("StringLiteral");
|
882 |
|
|
exports.isStringLiteral = isStringLiteral;
|
883 |
|
|
var isNumberLiteral = isTypeOf("NumberLiteral");
|
884 |
|
|
exports.isNumberLiteral = isNumberLiteral;
|
885 |
|
|
var isLongNumberLiteral = isTypeOf("LongNumberLiteral");
|
886 |
|
|
exports.isLongNumberLiteral = isLongNumberLiteral;
|
887 |
|
|
var isFloatLiteral = isTypeOf("FloatLiteral");
|
888 |
|
|
exports.isFloatLiteral = isFloatLiteral;
|
889 |
|
|
var isElem = isTypeOf("Elem");
|
890 |
|
|
exports.isElem = isElem;
|
891 |
|
|
var isIndexInFuncSection = isTypeOf("IndexInFuncSection");
|
892 |
|
|
exports.isIndexInFuncSection = isIndexInFuncSection;
|
893 |
|
|
var isValtypeLiteral = isTypeOf("ValtypeLiteral");
|
894 |
|
|
exports.isValtypeLiteral = isValtypeLiteral;
|
895 |
|
|
var isTypeInstruction = isTypeOf("TypeInstruction");
|
896 |
|
|
exports.isTypeInstruction = isTypeInstruction;
|
897 |
|
|
var isStart = isTypeOf("Start");
|
898 |
|
|
exports.isStart = isStart;
|
899 |
|
|
var isGlobalType = isTypeOf("GlobalType");
|
900 |
|
|
exports.isGlobalType = isGlobalType;
|
901 |
|
|
var isLeadingComment = isTypeOf("LeadingComment");
|
902 |
|
|
exports.isLeadingComment = isLeadingComment;
|
903 |
|
|
var isBlockComment = isTypeOf("BlockComment");
|
904 |
|
|
exports.isBlockComment = isBlockComment;
|
905 |
|
|
var isData = isTypeOf("Data");
|
906 |
|
|
exports.isData = isData;
|
907 |
|
|
var isGlobal = isTypeOf("Global");
|
908 |
|
|
exports.isGlobal = isGlobal;
|
909 |
|
|
var isTable = isTypeOf("Table");
|
910 |
|
|
exports.isTable = isTable;
|
911 |
|
|
var isMemory = isTypeOf("Memory");
|
912 |
|
|
exports.isMemory = isMemory;
|
913 |
|
|
var isFuncImportDescr = isTypeOf("FuncImportDescr");
|
914 |
|
|
exports.isFuncImportDescr = isFuncImportDescr;
|
915 |
|
|
var isModuleImport = isTypeOf("ModuleImport");
|
916 |
|
|
exports.isModuleImport = isModuleImport;
|
917 |
|
|
var isModuleExportDescr = isTypeOf("ModuleExportDescr");
|
918 |
|
|
exports.isModuleExportDescr = isModuleExportDescr;
|
919 |
|
|
var isModuleExport = isTypeOf("ModuleExport");
|
920 |
|
|
exports.isModuleExport = isModuleExport;
|
921 |
|
|
var isLimit = isTypeOf("Limit");
|
922 |
|
|
exports.isLimit = isLimit;
|
923 |
|
|
var isSignature = isTypeOf("Signature");
|
924 |
|
|
exports.isSignature = isSignature;
|
925 |
|
|
var isProgram = isTypeOf("Program");
|
926 |
|
|
exports.isProgram = isProgram;
|
927 |
|
|
var isIdentifier = isTypeOf("Identifier");
|
928 |
|
|
exports.isIdentifier = isIdentifier;
|
929 |
|
|
var isBlockInstruction = isTypeOf("BlockInstruction");
|
930 |
|
|
exports.isBlockInstruction = isBlockInstruction;
|
931 |
|
|
var isCallInstruction = isTypeOf("CallInstruction");
|
932 |
|
|
exports.isCallInstruction = isCallInstruction;
|
933 |
|
|
var isCallIndirectInstruction = isTypeOf("CallIndirectInstruction");
|
934 |
|
|
exports.isCallIndirectInstruction = isCallIndirectInstruction;
|
935 |
|
|
var isByteArray = isTypeOf("ByteArray");
|
936 |
|
|
exports.isByteArray = isByteArray;
|
937 |
|
|
var isFunc = isTypeOf("Func");
|
938 |
|
|
exports.isFunc = isFunc;
|
939 |
|
|
var isInternalBrUnless = isTypeOf("InternalBrUnless");
|
940 |
|
|
exports.isInternalBrUnless = isInternalBrUnless;
|
941 |
|
|
var isInternalGoto = isTypeOf("InternalGoto");
|
942 |
|
|
exports.isInternalGoto = isInternalGoto;
|
943 |
|
|
var isInternalCallExtern = isTypeOf("InternalCallExtern");
|
944 |
|
|
exports.isInternalCallExtern = isInternalCallExtern;
|
945 |
|
|
var isInternalEndAndReturn = isTypeOf("InternalEndAndReturn");
|
946 |
|
|
exports.isInternalEndAndReturn = isInternalEndAndReturn;
|
947 |
|
|
|
948 |
|
|
var isNode = function isNode(node) {
|
949 |
|
|
return isModule(node) || isModuleMetadata(node) || isModuleNameMetadata(node) || isFunctionNameMetadata(node) || isLocalNameMetadata(node) || isBinaryModule(node) || isQuoteModule(node) || isSectionMetadata(node) || isProducersSectionMetadata(node) || isProducerMetadata(node) || isProducerMetadataVersionedName(node) || isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isElem(node) || isIndexInFuncSection(node) || isValtypeLiteral(node) || isTypeInstruction(node) || isStart(node) || isGlobalType(node) || isLeadingComment(node) || isBlockComment(node) || isData(node) || isGlobal(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node) || isModuleImport(node) || isModuleExportDescr(node) || isModuleExport(node) || isLimit(node) || isSignature(node) || isProgram(node) || isIdentifier(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node) || isByteArray(node) || isFunc(node) || isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node);
|
950 |
|
|
};
|
951 |
|
|
|
952 |
|
|
exports.isNode = isNode;
|
953 |
|
|
|
954 |
|
|
var isBlock = function isBlock(node) {
|
955 |
|
|
return isLoopInstruction(node) || isBlockInstruction(node) || isFunc(node);
|
956 |
|
|
};
|
957 |
|
|
|
958 |
|
|
exports.isBlock = isBlock;
|
959 |
|
|
|
960 |
|
|
var isInstruction = function isInstruction(node) {
|
961 |
|
|
return isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isTypeInstruction(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node);
|
962 |
|
|
};
|
963 |
|
|
|
964 |
|
|
exports.isInstruction = isInstruction;
|
965 |
|
|
|
966 |
|
|
var isExpression = function isExpression(node) {
|
967 |
|
|
return isInstr(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isValtypeLiteral(node) || isIdentifier(node);
|
968 |
|
|
};
|
969 |
|
|
|
970 |
|
|
exports.isExpression = isExpression;
|
971 |
|
|
|
972 |
|
|
var isNumericLiteral = function isNumericLiteral(node) {
|
973 |
|
|
return isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node);
|
974 |
|
|
};
|
975 |
|
|
|
976 |
|
|
exports.isNumericLiteral = isNumericLiteral;
|
977 |
|
|
|
978 |
|
|
var isImportDescr = function isImportDescr(node) {
|
979 |
|
|
return isGlobalType(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node);
|
980 |
|
|
};
|
981 |
|
|
|
982 |
|
|
exports.isImportDescr = isImportDescr;
|
983 |
|
|
|
984 |
|
|
var isIntrinsic = function isIntrinsic(node) {
|
985 |
|
|
return isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node);
|
986 |
|
|
};
|
987 |
|
|
|
988 |
|
|
exports.isIntrinsic = isIntrinsic;
|
989 |
|
|
var assertModule = assertTypeOf("Module");
|
990 |
|
|
exports.assertModule = assertModule;
|
991 |
|
|
var assertModuleMetadata = assertTypeOf("ModuleMetadata");
|
992 |
|
|
exports.assertModuleMetadata = assertModuleMetadata;
|
993 |
|
|
var assertModuleNameMetadata = assertTypeOf("ModuleNameMetadata");
|
994 |
|
|
exports.assertModuleNameMetadata = assertModuleNameMetadata;
|
995 |
|
|
var assertFunctionNameMetadata = assertTypeOf("FunctionNameMetadata");
|
996 |
|
|
exports.assertFunctionNameMetadata = assertFunctionNameMetadata;
|
997 |
|
|
var assertLocalNameMetadata = assertTypeOf("LocalNameMetadata");
|
998 |
|
|
exports.assertLocalNameMetadata = assertLocalNameMetadata;
|
999 |
|
|
var assertBinaryModule = assertTypeOf("BinaryModule");
|
1000 |
|
|
exports.assertBinaryModule = assertBinaryModule;
|
1001 |
|
|
var assertQuoteModule = assertTypeOf("QuoteModule");
|
1002 |
|
|
exports.assertQuoteModule = assertQuoteModule;
|
1003 |
|
|
var assertSectionMetadata = assertTypeOf("SectionMetadata");
|
1004 |
|
|
exports.assertSectionMetadata = assertSectionMetadata;
|
1005 |
|
|
var assertProducersSectionMetadata = assertTypeOf("ProducersSectionMetadata");
|
1006 |
|
|
exports.assertProducersSectionMetadata = assertProducersSectionMetadata;
|
1007 |
|
|
var assertProducerMetadata = assertTypeOf("ProducerMetadata");
|
1008 |
|
|
exports.assertProducerMetadata = assertProducerMetadata;
|
1009 |
|
|
var assertProducerMetadataVersionedName = assertTypeOf("ProducerMetadataVersionedName");
|
1010 |
|
|
exports.assertProducerMetadataVersionedName = assertProducerMetadataVersionedName;
|
1011 |
|
|
var assertLoopInstruction = assertTypeOf("LoopInstruction");
|
1012 |
|
|
exports.assertLoopInstruction = assertLoopInstruction;
|
1013 |
|
|
var assertInstr = assertTypeOf("Instr");
|
1014 |
|
|
exports.assertInstr = assertInstr;
|
1015 |
|
|
var assertIfInstruction = assertTypeOf("IfInstruction");
|
1016 |
|
|
exports.assertIfInstruction = assertIfInstruction;
|
1017 |
|
|
var assertStringLiteral = assertTypeOf("StringLiteral");
|
1018 |
|
|
exports.assertStringLiteral = assertStringLiteral;
|
1019 |
|
|
var assertNumberLiteral = assertTypeOf("NumberLiteral");
|
1020 |
|
|
exports.assertNumberLiteral = assertNumberLiteral;
|
1021 |
|
|
var assertLongNumberLiteral = assertTypeOf("LongNumberLiteral");
|
1022 |
|
|
exports.assertLongNumberLiteral = assertLongNumberLiteral;
|
1023 |
|
|
var assertFloatLiteral = assertTypeOf("FloatLiteral");
|
1024 |
|
|
exports.assertFloatLiteral = assertFloatLiteral;
|
1025 |
|
|
var assertElem = assertTypeOf("Elem");
|
1026 |
|
|
exports.assertElem = assertElem;
|
1027 |
|
|
var assertIndexInFuncSection = assertTypeOf("IndexInFuncSection");
|
1028 |
|
|
exports.assertIndexInFuncSection = assertIndexInFuncSection;
|
1029 |
|
|
var assertValtypeLiteral = assertTypeOf("ValtypeLiteral");
|
1030 |
|
|
exports.assertValtypeLiteral = assertValtypeLiteral;
|
1031 |
|
|
var assertTypeInstruction = assertTypeOf("TypeInstruction");
|
1032 |
|
|
exports.assertTypeInstruction = assertTypeInstruction;
|
1033 |
|
|
var assertStart = assertTypeOf("Start");
|
1034 |
|
|
exports.assertStart = assertStart;
|
1035 |
|
|
var assertGlobalType = assertTypeOf("GlobalType");
|
1036 |
|
|
exports.assertGlobalType = assertGlobalType;
|
1037 |
|
|
var assertLeadingComment = assertTypeOf("LeadingComment");
|
1038 |
|
|
exports.assertLeadingComment = assertLeadingComment;
|
1039 |
|
|
var assertBlockComment = assertTypeOf("BlockComment");
|
1040 |
|
|
exports.assertBlockComment = assertBlockComment;
|
1041 |
|
|
var assertData = assertTypeOf("Data");
|
1042 |
|
|
exports.assertData = assertData;
|
1043 |
|
|
var assertGlobal = assertTypeOf("Global");
|
1044 |
|
|
exports.assertGlobal = assertGlobal;
|
1045 |
|
|
var assertTable = assertTypeOf("Table");
|
1046 |
|
|
exports.assertTable = assertTable;
|
1047 |
|
|
var assertMemory = assertTypeOf("Memory");
|
1048 |
|
|
exports.assertMemory = assertMemory;
|
1049 |
|
|
var assertFuncImportDescr = assertTypeOf("FuncImportDescr");
|
1050 |
|
|
exports.assertFuncImportDescr = assertFuncImportDescr;
|
1051 |
|
|
var assertModuleImport = assertTypeOf("ModuleImport");
|
1052 |
|
|
exports.assertModuleImport = assertModuleImport;
|
1053 |
|
|
var assertModuleExportDescr = assertTypeOf("ModuleExportDescr");
|
1054 |
|
|
exports.assertModuleExportDescr = assertModuleExportDescr;
|
1055 |
|
|
var assertModuleExport = assertTypeOf("ModuleExport");
|
1056 |
|
|
exports.assertModuleExport = assertModuleExport;
|
1057 |
|
|
var assertLimit = assertTypeOf("Limit");
|
1058 |
|
|
exports.assertLimit = assertLimit;
|
1059 |
|
|
var assertSignature = assertTypeOf("Signature");
|
1060 |
|
|
exports.assertSignature = assertSignature;
|
1061 |
|
|
var assertProgram = assertTypeOf("Program");
|
1062 |
|
|
exports.assertProgram = assertProgram;
|
1063 |
|
|
var assertIdentifier = assertTypeOf("Identifier");
|
1064 |
|
|
exports.assertIdentifier = assertIdentifier;
|
1065 |
|
|
var assertBlockInstruction = assertTypeOf("BlockInstruction");
|
1066 |
|
|
exports.assertBlockInstruction = assertBlockInstruction;
|
1067 |
|
|
var assertCallInstruction = assertTypeOf("CallInstruction");
|
1068 |
|
|
exports.assertCallInstruction = assertCallInstruction;
|
1069 |
|
|
var assertCallIndirectInstruction = assertTypeOf("CallIndirectInstruction");
|
1070 |
|
|
exports.assertCallIndirectInstruction = assertCallIndirectInstruction;
|
1071 |
|
|
var assertByteArray = assertTypeOf("ByteArray");
|
1072 |
|
|
exports.assertByteArray = assertByteArray;
|
1073 |
|
|
var assertFunc = assertTypeOf("Func");
|
1074 |
|
|
exports.assertFunc = assertFunc;
|
1075 |
|
|
var assertInternalBrUnless = assertTypeOf("InternalBrUnless");
|
1076 |
|
|
exports.assertInternalBrUnless = assertInternalBrUnless;
|
1077 |
|
|
var assertInternalGoto = assertTypeOf("InternalGoto");
|
1078 |
|
|
exports.assertInternalGoto = assertInternalGoto;
|
1079 |
|
|
var assertInternalCallExtern = assertTypeOf("InternalCallExtern");
|
1080 |
|
|
exports.assertInternalCallExtern = assertInternalCallExtern;
|
1081 |
|
|
var assertInternalEndAndReturn = assertTypeOf("InternalEndAndReturn");
|
1082 |
|
|
exports.assertInternalEndAndReturn = assertInternalEndAndReturn;
|
1083 |
|
|
var unionTypesMap = {
|
1084 |
|
|
Module: ["Node"],
|
1085 |
|
|
ModuleMetadata: ["Node"],
|
1086 |
|
|
ModuleNameMetadata: ["Node"],
|
1087 |
|
|
FunctionNameMetadata: ["Node"],
|
1088 |
|
|
LocalNameMetadata: ["Node"],
|
1089 |
|
|
BinaryModule: ["Node"],
|
1090 |
|
|
QuoteModule: ["Node"],
|
1091 |
|
|
SectionMetadata: ["Node"],
|
1092 |
|
|
ProducersSectionMetadata: ["Node"],
|
1093 |
|
|
ProducerMetadata: ["Node"],
|
1094 |
|
|
ProducerMetadataVersionedName: ["Node"],
|
1095 |
|
|
LoopInstruction: ["Node", "Block", "Instruction"],
|
1096 |
|
|
Instr: ["Node", "Expression", "Instruction"],
|
1097 |
|
|
IfInstruction: ["Node", "Instruction"],
|
1098 |
|
|
StringLiteral: ["Node", "Expression"],
|
1099 |
|
|
NumberLiteral: ["Node", "NumericLiteral", "Expression"],
|
1100 |
|
|
LongNumberLiteral: ["Node", "NumericLiteral", "Expression"],
|
1101 |
|
|
FloatLiteral: ["Node", "NumericLiteral", "Expression"],
|
1102 |
|
|
Elem: ["Node"],
|
1103 |
|
|
IndexInFuncSection: ["Node"],
|
1104 |
|
|
ValtypeLiteral: ["Node", "Expression"],
|
1105 |
|
|
TypeInstruction: ["Node", "Instruction"],
|
1106 |
|
|
Start: ["Node"],
|
1107 |
|
|
GlobalType: ["Node", "ImportDescr"],
|
1108 |
|
|
LeadingComment: ["Node"],
|
1109 |
|
|
BlockComment: ["Node"],
|
1110 |
|
|
Data: ["Node"],
|
1111 |
|
|
Global: ["Node"],
|
1112 |
|
|
Table: ["Node", "ImportDescr"],
|
1113 |
|
|
Memory: ["Node", "ImportDescr"],
|
1114 |
|
|
FuncImportDescr: ["Node", "ImportDescr"],
|
1115 |
|
|
ModuleImport: ["Node"],
|
1116 |
|
|
ModuleExportDescr: ["Node"],
|
1117 |
|
|
ModuleExport: ["Node"],
|
1118 |
|
|
Limit: ["Node"],
|
1119 |
|
|
Signature: ["Node"],
|
1120 |
|
|
Program: ["Node"],
|
1121 |
|
|
Identifier: ["Node", "Expression"],
|
1122 |
|
|
BlockInstruction: ["Node", "Block", "Instruction"],
|
1123 |
|
|
CallInstruction: ["Node", "Instruction"],
|
1124 |
|
|
CallIndirectInstruction: ["Node", "Instruction"],
|
1125 |
|
|
ByteArray: ["Node"],
|
1126 |
|
|
Func: ["Node", "Block"],
|
1127 |
|
|
InternalBrUnless: ["Node", "Intrinsic"],
|
1128 |
|
|
InternalGoto: ["Node", "Intrinsic"],
|
1129 |
|
|
InternalCallExtern: ["Node", "Intrinsic"],
|
1130 |
|
|
InternalEndAndReturn: ["Node", "Intrinsic"]
|
1131 |
|
|
};
|
1132 |
|
|
exports.unionTypesMap = unionTypesMap;
|
1133 |
|
|
var nodeAndUnionTypes = ["Module", "ModuleMetadata", "ModuleNameMetadata", "FunctionNameMetadata", "LocalNameMetadata", "BinaryModule", "QuoteModule", "SectionMetadata", "ProducersSectionMetadata", "ProducerMetadata", "ProducerMetadataVersionedName", "LoopInstruction", "Instr", "IfInstruction", "StringLiteral", "NumberLiteral", "LongNumberLiteral", "FloatLiteral", "Elem", "IndexInFuncSection", "ValtypeLiteral", "TypeInstruction", "Start", "GlobalType", "LeadingComment", "BlockComment", "Data", "Global", "Table", "Memory", "FuncImportDescr", "ModuleImport", "ModuleExportDescr", "ModuleExport", "Limit", "Signature", "Program", "Identifier", "BlockInstruction", "CallInstruction", "CallIndirectInstruction", "ByteArray", "Func", "InternalBrUnless", "InternalGoto", "InternalCallExtern", "InternalEndAndReturn", "Node", "Block", "Instruction", "Expression", "NumericLiteral", "ImportDescr", "Intrinsic"];
|
1134 |
|
|
exports.nodeAndUnionTypes = nodeAndUnionTypes;
|