source: trip-planner-front/node_modules/@webassemblyjs/ast/lib/nodes.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 41.1 KB
RevLine 
[6a3a178]1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.module = _module;
7exports.moduleMetadata = moduleMetadata;
8exports.moduleNameMetadata = moduleNameMetadata;
9exports.functionNameMetadata = functionNameMetadata;
10exports.localNameMetadata = localNameMetadata;
11exports.binaryModule = binaryModule;
12exports.quoteModule = quoteModule;
13exports.sectionMetadata = sectionMetadata;
14exports.producersSectionMetadata = producersSectionMetadata;
15exports.producerMetadata = producerMetadata;
16exports.producerMetadataVersionedName = producerMetadataVersionedName;
17exports.loopInstruction = loopInstruction;
18exports.instr = instr;
19exports.ifInstruction = ifInstruction;
20exports.stringLiteral = stringLiteral;
21exports.numberLiteral = numberLiteral;
22exports.longNumberLiteral = longNumberLiteral;
23exports.floatLiteral = floatLiteral;
24exports.elem = elem;
25exports.indexInFuncSection = indexInFuncSection;
26exports.valtypeLiteral = valtypeLiteral;
27exports.typeInstruction = typeInstruction;
28exports.start = start;
29exports.globalType = globalType;
30exports.leadingComment = leadingComment;
31exports.blockComment = blockComment;
32exports.data = data;
33exports.global = global;
34exports.table = table;
35exports.memory = memory;
36exports.funcImportDescr = funcImportDescr;
37exports.moduleImport = moduleImport;
38exports.moduleExportDescr = moduleExportDescr;
39exports.moduleExport = moduleExport;
40exports.limit = limit;
41exports.signature = signature;
42exports.program = program;
43exports.identifier = identifier;
44exports.blockInstruction = blockInstruction;
45exports.callInstruction = callInstruction;
46exports.callIndirectInstruction = callIndirectInstruction;
47exports.byteArray = byteArray;
48exports.func = func;
49exports.internalBrUnless = internalBrUnless;
50exports.internalGoto = internalGoto;
51exports.internalCallExtern = internalCallExtern;
52exports.internalEndAndReturn = internalEndAndReturn;
53exports.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;
54exports.nodeAndUnionTypes = exports.unionTypesMap = exports.assertInternalEndAndReturn = void 0;
55
56function _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
60function isTypeOf(t) {
61 return function (n) {
62 return n.type === t;
63 };
64}
65
66function 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
76function _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
100function 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
143function 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
155function 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
172function 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
194function 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
213function 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
232function 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
247function 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
259function 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
281function 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
298function 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
313function 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
339function 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
364function 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
376function 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
393function 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
406function 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
444function 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
462function indexInFuncSection(index) {
463 var node = {
464 type: "IndexInFuncSection",
465 index: index
466 };
467 return node;
468}
469
470function valtypeLiteral(name) {
471 var node = {
472 type: "ValtypeLiteral",
473 name: name
474 };
475 return node;
476}
477
478function typeInstruction(id, functype) {
479 var node = {
480 type: "TypeInstruction",
481 id: id,
482 functype: functype
483 };
484 return node;
485}
486
487function start(index) {
488 var node = {
489 type: "Start",
490 index: index
491 };
492 return node;
493}
494
495function globalType(valtype, mutability) {
496 var node = {
497 type: "GlobalType",
498 valtype: valtype,
499 mutability: mutability
500 };
501 return node;
502}
503
504function 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
516function 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
528function 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
538function 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
552function 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
577function memory(limits, id) {
578 var node = {
579 type: "Memory",
580 limits: limits,
581 id: id
582 };
583 return node;
584}
585
586function funcImportDescr(id, signature) {
587 var node = {
588 type: "FuncImportDescr",
589 id: id,
590 signature: signature
591 };
592 return node;
593}
594
595function 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
613function moduleExportDescr(exportType, id) {
614 var node = {
615 type: "ModuleExportDescr",
616 exportType: exportType,
617 id: id
618 };
619 return node;
620}
621
622function 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
635function limit(min, max, shared) {
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 if (shared !== null && shared !== undefined) {
647 if (!(typeof shared === "boolean")) {
648 throw new Error('typeof shared === "boolean"' + " error: " + ("Argument shared must be of type boolean, given: " + _typeof(shared) || "unknown"));
649 }
650 }
651
652 var node = {
653 type: "Limit",
654 min: min
655 };
656
657 if (typeof max !== "undefined") {
658 node.max = max;
659 }
660
661 if (shared === true) {
662 node.shared = true;
663 }
664
665 return node;
666}
667
668function signature(params, results) {
669 if (!(_typeof(params) === "object" && typeof params.length !== "undefined")) {
670 throw new Error('typeof params === "object" && typeof params.length !== "undefined"' + " error: " + (undefined || "unknown"));
671 }
672
673 if (!(_typeof(results) === "object" && typeof results.length !== "undefined")) {
674 throw new Error('typeof results === "object" && typeof results.length !== "undefined"' + " error: " + (undefined || "unknown"));
675 }
676
677 var node = {
678 type: "Signature",
679 params: params,
680 results: results
681 };
682 return node;
683}
684
685function program(body) {
686 if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
687 throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
688 }
689
690 var node = {
691 type: "Program",
692 body: body
693 };
694 return node;
695}
696
697function identifier(value, raw) {
698 if (!(typeof value === "string")) {
699 throw new Error('typeof value === "string"' + " error: " + ("Argument value must be of type string, given: " + _typeof(value) || "unknown"));
700 }
701
702 if (raw !== null && raw !== undefined) {
703 if (!(typeof raw === "string")) {
704 throw new Error('typeof raw === "string"' + " error: " + ("Argument raw must be of type string, given: " + _typeof(raw) || "unknown"));
705 }
706 }
707
708 var node = {
709 type: "Identifier",
710 value: value
711 };
712
713 if (typeof raw !== "undefined") {
714 node.raw = raw;
715 }
716
717 return node;
718}
719
720function blockInstruction(label, instr, result) {
721 if (!(_typeof(instr) === "object" && typeof instr.length !== "undefined")) {
722 throw new Error('typeof instr === "object" && typeof instr.length !== "undefined"' + " error: " + (undefined || "unknown"));
723 }
724
725 var node = {
726 type: "BlockInstruction",
727 id: "block",
728 label: label,
729 instr: instr,
730 result: result
731 };
732 return node;
733}
734
735function callInstruction(index, instrArgs, numeric) {
736 if (instrArgs !== null && instrArgs !== undefined) {
737 if (!(_typeof(instrArgs) === "object" && typeof instrArgs.length !== "undefined")) {
738 throw new Error('typeof instrArgs === "object" && typeof instrArgs.length !== "undefined"' + " error: " + (undefined || "unknown"));
739 }
740 }
741
742 var node = {
743 type: "CallInstruction",
744 id: "call",
745 index: index
746 };
747
748 if (typeof instrArgs !== "undefined" && instrArgs.length > 0) {
749 node.instrArgs = instrArgs;
750 }
751
752 if (typeof numeric !== "undefined") {
753 node.numeric = numeric;
754 }
755
756 return node;
757}
758
759function callIndirectInstruction(signature, intrs) {
760 if (intrs !== null && intrs !== undefined) {
761 if (!(_typeof(intrs) === "object" && typeof intrs.length !== "undefined")) {
762 throw new Error('typeof intrs === "object" && typeof intrs.length !== "undefined"' + " error: " + (undefined || "unknown"));
763 }
764 }
765
766 var node = {
767 type: "CallIndirectInstruction",
768 id: "call_indirect",
769 signature: signature
770 };
771
772 if (typeof intrs !== "undefined" && intrs.length > 0) {
773 node.intrs = intrs;
774 }
775
776 return node;
777}
778
779function byteArray(values) {
780 if (!(_typeof(values) === "object" && typeof values.length !== "undefined")) {
781 throw new Error('typeof values === "object" && typeof values.length !== "undefined"' + " error: " + (undefined || "unknown"));
782 }
783
784 var node = {
785 type: "ByteArray",
786 values: values
787 };
788 return node;
789}
790
791function func(name, signature, body, isExternal, metadata) {
792 if (!(_typeof(body) === "object" && typeof body.length !== "undefined")) {
793 throw new Error('typeof body === "object" && typeof body.length !== "undefined"' + " error: " + (undefined || "unknown"));
794 }
795
796 if (isExternal !== null && isExternal !== undefined) {
797 if (!(typeof isExternal === "boolean")) {
798 throw new Error('typeof isExternal === "boolean"' + " error: " + ("Argument isExternal must be of type boolean, given: " + _typeof(isExternal) || "unknown"));
799 }
800 }
801
802 var node = {
803 type: "Func",
804 name: name,
805 signature: signature,
806 body: body
807 };
808
809 if (isExternal === true) {
810 node.isExternal = true;
811 }
812
813 if (typeof metadata !== "undefined") {
814 node.metadata = metadata;
815 }
816
817 return node;
818}
819
820function internalBrUnless(target) {
821 if (!(typeof target === "number")) {
822 throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
823 }
824
825 var node = {
826 type: "InternalBrUnless",
827 target: target
828 };
829 return node;
830}
831
832function internalGoto(target) {
833 if (!(typeof target === "number")) {
834 throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
835 }
836
837 var node = {
838 type: "InternalGoto",
839 target: target
840 };
841 return node;
842}
843
844function internalCallExtern(target) {
845 if (!(typeof target === "number")) {
846 throw new Error('typeof target === "number"' + " error: " + ("Argument target must be of type number, given: " + _typeof(target) || "unknown"));
847 }
848
849 var node = {
850 type: "InternalCallExtern",
851 target: target
852 };
853 return node;
854}
855
856function internalEndAndReturn() {
857 var node = {
858 type: "InternalEndAndReturn"
859 };
860 return node;
861}
862
863var isModule = isTypeOf("Module");
864exports.isModule = isModule;
865var isModuleMetadata = isTypeOf("ModuleMetadata");
866exports.isModuleMetadata = isModuleMetadata;
867var isModuleNameMetadata = isTypeOf("ModuleNameMetadata");
868exports.isModuleNameMetadata = isModuleNameMetadata;
869var isFunctionNameMetadata = isTypeOf("FunctionNameMetadata");
870exports.isFunctionNameMetadata = isFunctionNameMetadata;
871var isLocalNameMetadata = isTypeOf("LocalNameMetadata");
872exports.isLocalNameMetadata = isLocalNameMetadata;
873var isBinaryModule = isTypeOf("BinaryModule");
874exports.isBinaryModule = isBinaryModule;
875var isQuoteModule = isTypeOf("QuoteModule");
876exports.isQuoteModule = isQuoteModule;
877var isSectionMetadata = isTypeOf("SectionMetadata");
878exports.isSectionMetadata = isSectionMetadata;
879var isProducersSectionMetadata = isTypeOf("ProducersSectionMetadata");
880exports.isProducersSectionMetadata = isProducersSectionMetadata;
881var isProducerMetadata = isTypeOf("ProducerMetadata");
882exports.isProducerMetadata = isProducerMetadata;
883var isProducerMetadataVersionedName = isTypeOf("ProducerMetadataVersionedName");
884exports.isProducerMetadataVersionedName = isProducerMetadataVersionedName;
885var isLoopInstruction = isTypeOf("LoopInstruction");
886exports.isLoopInstruction = isLoopInstruction;
887var isInstr = isTypeOf("Instr");
888exports.isInstr = isInstr;
889var isIfInstruction = isTypeOf("IfInstruction");
890exports.isIfInstruction = isIfInstruction;
891var isStringLiteral = isTypeOf("StringLiteral");
892exports.isStringLiteral = isStringLiteral;
893var isNumberLiteral = isTypeOf("NumberLiteral");
894exports.isNumberLiteral = isNumberLiteral;
895var isLongNumberLiteral = isTypeOf("LongNumberLiteral");
896exports.isLongNumberLiteral = isLongNumberLiteral;
897var isFloatLiteral = isTypeOf("FloatLiteral");
898exports.isFloatLiteral = isFloatLiteral;
899var isElem = isTypeOf("Elem");
900exports.isElem = isElem;
901var isIndexInFuncSection = isTypeOf("IndexInFuncSection");
902exports.isIndexInFuncSection = isIndexInFuncSection;
903var isValtypeLiteral = isTypeOf("ValtypeLiteral");
904exports.isValtypeLiteral = isValtypeLiteral;
905var isTypeInstruction = isTypeOf("TypeInstruction");
906exports.isTypeInstruction = isTypeInstruction;
907var isStart = isTypeOf("Start");
908exports.isStart = isStart;
909var isGlobalType = isTypeOf("GlobalType");
910exports.isGlobalType = isGlobalType;
911var isLeadingComment = isTypeOf("LeadingComment");
912exports.isLeadingComment = isLeadingComment;
913var isBlockComment = isTypeOf("BlockComment");
914exports.isBlockComment = isBlockComment;
915var isData = isTypeOf("Data");
916exports.isData = isData;
917var isGlobal = isTypeOf("Global");
918exports.isGlobal = isGlobal;
919var isTable = isTypeOf("Table");
920exports.isTable = isTable;
921var isMemory = isTypeOf("Memory");
922exports.isMemory = isMemory;
923var isFuncImportDescr = isTypeOf("FuncImportDescr");
924exports.isFuncImportDescr = isFuncImportDescr;
925var isModuleImport = isTypeOf("ModuleImport");
926exports.isModuleImport = isModuleImport;
927var isModuleExportDescr = isTypeOf("ModuleExportDescr");
928exports.isModuleExportDescr = isModuleExportDescr;
929var isModuleExport = isTypeOf("ModuleExport");
930exports.isModuleExport = isModuleExport;
931var isLimit = isTypeOf("Limit");
932exports.isLimit = isLimit;
933var isSignature = isTypeOf("Signature");
934exports.isSignature = isSignature;
935var isProgram = isTypeOf("Program");
936exports.isProgram = isProgram;
937var isIdentifier = isTypeOf("Identifier");
938exports.isIdentifier = isIdentifier;
939var isBlockInstruction = isTypeOf("BlockInstruction");
940exports.isBlockInstruction = isBlockInstruction;
941var isCallInstruction = isTypeOf("CallInstruction");
942exports.isCallInstruction = isCallInstruction;
943var isCallIndirectInstruction = isTypeOf("CallIndirectInstruction");
944exports.isCallIndirectInstruction = isCallIndirectInstruction;
945var isByteArray = isTypeOf("ByteArray");
946exports.isByteArray = isByteArray;
947var isFunc = isTypeOf("Func");
948exports.isFunc = isFunc;
949var isInternalBrUnless = isTypeOf("InternalBrUnless");
950exports.isInternalBrUnless = isInternalBrUnless;
951var isInternalGoto = isTypeOf("InternalGoto");
952exports.isInternalGoto = isInternalGoto;
953var isInternalCallExtern = isTypeOf("InternalCallExtern");
954exports.isInternalCallExtern = isInternalCallExtern;
955var isInternalEndAndReturn = isTypeOf("InternalEndAndReturn");
956exports.isInternalEndAndReturn = isInternalEndAndReturn;
957
958var isNode = function isNode(node) {
959 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);
960};
961
962exports.isNode = isNode;
963
964var isBlock = function isBlock(node) {
965 return isLoopInstruction(node) || isBlockInstruction(node) || isFunc(node);
966};
967
968exports.isBlock = isBlock;
969
970var isInstruction = function isInstruction(node) {
971 return isLoopInstruction(node) || isInstr(node) || isIfInstruction(node) || isTypeInstruction(node) || isBlockInstruction(node) || isCallInstruction(node) || isCallIndirectInstruction(node);
972};
973
974exports.isInstruction = isInstruction;
975
976var isExpression = function isExpression(node) {
977 return isInstr(node) || isStringLiteral(node) || isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node) || isValtypeLiteral(node) || isIdentifier(node);
978};
979
980exports.isExpression = isExpression;
981
982var isNumericLiteral = function isNumericLiteral(node) {
983 return isNumberLiteral(node) || isLongNumberLiteral(node) || isFloatLiteral(node);
984};
985
986exports.isNumericLiteral = isNumericLiteral;
987
988var isImportDescr = function isImportDescr(node) {
989 return isGlobalType(node) || isTable(node) || isMemory(node) || isFuncImportDescr(node);
990};
991
992exports.isImportDescr = isImportDescr;
993
994var isIntrinsic = function isIntrinsic(node) {
995 return isInternalBrUnless(node) || isInternalGoto(node) || isInternalCallExtern(node) || isInternalEndAndReturn(node);
996};
997
998exports.isIntrinsic = isIntrinsic;
999var assertModule = assertTypeOf("Module");
1000exports.assertModule = assertModule;
1001var assertModuleMetadata = assertTypeOf("ModuleMetadata");
1002exports.assertModuleMetadata = assertModuleMetadata;
1003var assertModuleNameMetadata = assertTypeOf("ModuleNameMetadata");
1004exports.assertModuleNameMetadata = assertModuleNameMetadata;
1005var assertFunctionNameMetadata = assertTypeOf("FunctionNameMetadata");
1006exports.assertFunctionNameMetadata = assertFunctionNameMetadata;
1007var assertLocalNameMetadata = assertTypeOf("LocalNameMetadata");
1008exports.assertLocalNameMetadata = assertLocalNameMetadata;
1009var assertBinaryModule = assertTypeOf("BinaryModule");
1010exports.assertBinaryModule = assertBinaryModule;
1011var assertQuoteModule = assertTypeOf("QuoteModule");
1012exports.assertQuoteModule = assertQuoteModule;
1013var assertSectionMetadata = assertTypeOf("SectionMetadata");
1014exports.assertSectionMetadata = assertSectionMetadata;
1015var assertProducersSectionMetadata = assertTypeOf("ProducersSectionMetadata");
1016exports.assertProducersSectionMetadata = assertProducersSectionMetadata;
1017var assertProducerMetadata = assertTypeOf("ProducerMetadata");
1018exports.assertProducerMetadata = assertProducerMetadata;
1019var assertProducerMetadataVersionedName = assertTypeOf("ProducerMetadataVersionedName");
1020exports.assertProducerMetadataVersionedName = assertProducerMetadataVersionedName;
1021var assertLoopInstruction = assertTypeOf("LoopInstruction");
1022exports.assertLoopInstruction = assertLoopInstruction;
1023var assertInstr = assertTypeOf("Instr");
1024exports.assertInstr = assertInstr;
1025var assertIfInstruction = assertTypeOf("IfInstruction");
1026exports.assertIfInstruction = assertIfInstruction;
1027var assertStringLiteral = assertTypeOf("StringLiteral");
1028exports.assertStringLiteral = assertStringLiteral;
1029var assertNumberLiteral = assertTypeOf("NumberLiteral");
1030exports.assertNumberLiteral = assertNumberLiteral;
1031var assertLongNumberLiteral = assertTypeOf("LongNumberLiteral");
1032exports.assertLongNumberLiteral = assertLongNumberLiteral;
1033var assertFloatLiteral = assertTypeOf("FloatLiteral");
1034exports.assertFloatLiteral = assertFloatLiteral;
1035var assertElem = assertTypeOf("Elem");
1036exports.assertElem = assertElem;
1037var assertIndexInFuncSection = assertTypeOf("IndexInFuncSection");
1038exports.assertIndexInFuncSection = assertIndexInFuncSection;
1039var assertValtypeLiteral = assertTypeOf("ValtypeLiteral");
1040exports.assertValtypeLiteral = assertValtypeLiteral;
1041var assertTypeInstruction = assertTypeOf("TypeInstruction");
1042exports.assertTypeInstruction = assertTypeInstruction;
1043var assertStart = assertTypeOf("Start");
1044exports.assertStart = assertStart;
1045var assertGlobalType = assertTypeOf("GlobalType");
1046exports.assertGlobalType = assertGlobalType;
1047var assertLeadingComment = assertTypeOf("LeadingComment");
1048exports.assertLeadingComment = assertLeadingComment;
1049var assertBlockComment = assertTypeOf("BlockComment");
1050exports.assertBlockComment = assertBlockComment;
1051var assertData = assertTypeOf("Data");
1052exports.assertData = assertData;
1053var assertGlobal = assertTypeOf("Global");
1054exports.assertGlobal = assertGlobal;
1055var assertTable = assertTypeOf("Table");
1056exports.assertTable = assertTable;
1057var assertMemory = assertTypeOf("Memory");
1058exports.assertMemory = assertMemory;
1059var assertFuncImportDescr = assertTypeOf("FuncImportDescr");
1060exports.assertFuncImportDescr = assertFuncImportDescr;
1061var assertModuleImport = assertTypeOf("ModuleImport");
1062exports.assertModuleImport = assertModuleImport;
1063var assertModuleExportDescr = assertTypeOf("ModuleExportDescr");
1064exports.assertModuleExportDescr = assertModuleExportDescr;
1065var assertModuleExport = assertTypeOf("ModuleExport");
1066exports.assertModuleExport = assertModuleExport;
1067var assertLimit = assertTypeOf("Limit");
1068exports.assertLimit = assertLimit;
1069var assertSignature = assertTypeOf("Signature");
1070exports.assertSignature = assertSignature;
1071var assertProgram = assertTypeOf("Program");
1072exports.assertProgram = assertProgram;
1073var assertIdentifier = assertTypeOf("Identifier");
1074exports.assertIdentifier = assertIdentifier;
1075var assertBlockInstruction = assertTypeOf("BlockInstruction");
1076exports.assertBlockInstruction = assertBlockInstruction;
1077var assertCallInstruction = assertTypeOf("CallInstruction");
1078exports.assertCallInstruction = assertCallInstruction;
1079var assertCallIndirectInstruction = assertTypeOf("CallIndirectInstruction");
1080exports.assertCallIndirectInstruction = assertCallIndirectInstruction;
1081var assertByteArray = assertTypeOf("ByteArray");
1082exports.assertByteArray = assertByteArray;
1083var assertFunc = assertTypeOf("Func");
1084exports.assertFunc = assertFunc;
1085var assertInternalBrUnless = assertTypeOf("InternalBrUnless");
1086exports.assertInternalBrUnless = assertInternalBrUnless;
1087var assertInternalGoto = assertTypeOf("InternalGoto");
1088exports.assertInternalGoto = assertInternalGoto;
1089var assertInternalCallExtern = assertTypeOf("InternalCallExtern");
1090exports.assertInternalCallExtern = assertInternalCallExtern;
1091var assertInternalEndAndReturn = assertTypeOf("InternalEndAndReturn");
1092exports.assertInternalEndAndReturn = assertInternalEndAndReturn;
1093var unionTypesMap = {
1094 Module: ["Node"],
1095 ModuleMetadata: ["Node"],
1096 ModuleNameMetadata: ["Node"],
1097 FunctionNameMetadata: ["Node"],
1098 LocalNameMetadata: ["Node"],
1099 BinaryModule: ["Node"],
1100 QuoteModule: ["Node"],
1101 SectionMetadata: ["Node"],
1102 ProducersSectionMetadata: ["Node"],
1103 ProducerMetadata: ["Node"],
1104 ProducerMetadataVersionedName: ["Node"],
1105 LoopInstruction: ["Node", "Block", "Instruction"],
1106 Instr: ["Node", "Expression", "Instruction"],
1107 IfInstruction: ["Node", "Instruction"],
1108 StringLiteral: ["Node", "Expression"],
1109 NumberLiteral: ["Node", "NumericLiteral", "Expression"],
1110 LongNumberLiteral: ["Node", "NumericLiteral", "Expression"],
1111 FloatLiteral: ["Node", "NumericLiteral", "Expression"],
1112 Elem: ["Node"],
1113 IndexInFuncSection: ["Node"],
1114 ValtypeLiteral: ["Node", "Expression"],
1115 TypeInstruction: ["Node", "Instruction"],
1116 Start: ["Node"],
1117 GlobalType: ["Node", "ImportDescr"],
1118 LeadingComment: ["Node"],
1119 BlockComment: ["Node"],
1120 Data: ["Node"],
1121 Global: ["Node"],
1122 Table: ["Node", "ImportDescr"],
1123 Memory: ["Node", "ImportDescr"],
1124 FuncImportDescr: ["Node", "ImportDescr"],
1125 ModuleImport: ["Node"],
1126 ModuleExportDescr: ["Node"],
1127 ModuleExport: ["Node"],
1128 Limit: ["Node"],
1129 Signature: ["Node"],
1130 Program: ["Node"],
1131 Identifier: ["Node", "Expression"],
1132 BlockInstruction: ["Node", "Block", "Instruction"],
1133 CallInstruction: ["Node", "Instruction"],
1134 CallIndirectInstruction: ["Node", "Instruction"],
1135 ByteArray: ["Node"],
1136 Func: ["Node", "Block"],
1137 InternalBrUnless: ["Node", "Intrinsic"],
1138 InternalGoto: ["Node", "Intrinsic"],
1139 InternalCallExtern: ["Node", "Intrinsic"],
1140 InternalEndAndReturn: ["Node", "Intrinsic"]
1141};
1142exports.unionTypesMap = unionTypesMap;
1143var 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"];
1144exports.nodeAndUnionTypes = nodeAndUnionTypes;
Note: See TracBrowser for help on using the repository browser.