source: trip-planner-front/node_modules/@webassemblyjs/ast/esm/definitions.js@ 76712b2

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

initial commit

  • Property mode set to 100644
File size: 10.7 KB
RevLine 
[6a3a178]1var definitions = {};
2
3function defineType(typeName, metadata) {
4 definitions[typeName] = metadata;
5}
6
7defineType("Module", {
8 spec: {
9 wasm: "https://webassembly.github.io/spec/core/binary/modules.html#binary-module",
10 wat: "https://webassembly.github.io/spec/core/text/modules.html#text-module"
11 },
12 doc: "A module consists of a sequence of sections (termed fields in the text format).",
13 unionType: ["Node"],
14 fields: {
15 id: {
16 maybe: true,
17 type: "string"
18 },
19 fields: {
20 array: true,
21 type: "Node"
22 },
23 metadata: {
24 optional: true,
25 type: "ModuleMetadata"
26 }
27 }
28});
29defineType("ModuleMetadata", {
30 unionType: ["Node"],
31 fields: {
32 sections: {
33 array: true,
34 type: "SectionMetadata"
35 },
36 functionNames: {
37 optional: true,
38 array: true,
39 type: "FunctionNameMetadata"
40 },
41 localNames: {
42 optional: true,
43 array: true,
44 type: "ModuleMetadata"
45 },
46 producers: {
47 optional: true,
48 array: true,
49 type: "ProducersSectionMetadata"
50 }
51 }
52});
53defineType("ModuleNameMetadata", {
54 unionType: ["Node"],
55 fields: {
56 value: {
57 type: "string"
58 }
59 }
60});
61defineType("FunctionNameMetadata", {
62 unionType: ["Node"],
63 fields: {
64 value: {
65 type: "string"
66 },
67 index: {
68 type: "number"
69 }
70 }
71});
72defineType("LocalNameMetadata", {
73 unionType: ["Node"],
74 fields: {
75 value: {
76 type: "string"
77 },
78 localIndex: {
79 type: "number"
80 },
81 functionIndex: {
82 type: "number"
83 }
84 }
85});
86defineType("BinaryModule", {
87 unionType: ["Node"],
88 fields: {
89 id: {
90 maybe: true,
91 type: "string"
92 },
93 blob: {
94 array: true,
95 type: "string"
96 }
97 }
98});
99defineType("QuoteModule", {
100 unionType: ["Node"],
101 fields: {
102 id: {
103 maybe: true,
104 type: "string"
105 },
106 string: {
107 array: true,
108 type: "string"
109 }
110 }
111});
112defineType("SectionMetadata", {
113 unionType: ["Node"],
114 fields: {
115 section: {
116 type: "SectionName"
117 },
118 startOffset: {
119 type: "number"
120 },
121 size: {
122 type: "NumberLiteral"
123 },
124 vectorOfSize: {
125 comment: "Size of the vector in the section (if any)",
126 type: "NumberLiteral"
127 }
128 }
129});
130defineType("ProducersSectionMetadata", {
131 unionType: ["Node"],
132 fields: {
133 producers: {
134 array: true,
135 type: "ProducerMetadata"
136 }
137 }
138});
139defineType("ProducerMetadata", {
140 unionType: ["Node"],
141 fields: {
142 language: {
143 type: "ProducerMetadataVersionedName",
144 array: true
145 },
146 processedBy: {
147 type: "ProducerMetadataVersionedName",
148 array: true
149 },
150 sdk: {
151 type: "ProducerMetadataVersionedName",
152 array: true
153 }
154 }
155});
156defineType("ProducerMetadataVersionedName", {
157 unionType: ["Node"],
158 fields: {
159 name: {
160 type: "string"
161 },
162 version: {
163 type: "string"
164 }
165 }
166});
167/*
168Instructions
169*/
170
171defineType("LoopInstruction", {
172 unionType: ["Node", "Block", "Instruction"],
173 fields: {
174 id: {
175 constant: true,
176 type: "string",
177 value: "loop"
178 },
179 label: {
180 maybe: true,
181 type: "Identifier"
182 },
183 resulttype: {
184 maybe: true,
185 type: "Valtype"
186 },
187 instr: {
188 array: true,
189 type: "Instruction"
190 }
191 }
192});
193defineType("Instr", {
194 unionType: ["Node", "Expression", "Instruction"],
195 fields: {
196 id: {
197 type: "string"
198 },
199 object: {
200 optional: true,
201 type: "Valtype"
202 },
203 args: {
204 array: true,
205 type: "Expression"
206 },
207 namedArgs: {
208 optional: true,
209 type: "Object"
210 }
211 }
212});
213defineType("IfInstruction", {
214 unionType: ["Node", "Instruction"],
215 fields: {
216 id: {
217 constant: true,
218 type: "string",
219 value: "if"
220 },
221 testLabel: {
222 comment: "only for WAST",
223 type: "Identifier"
224 },
225 test: {
226 array: true,
227 type: "Instruction"
228 },
229 result: {
230 maybe: true,
231 type: "Valtype"
232 },
233 consequent: {
234 array: true,
235 type: "Instruction"
236 },
237 alternate: {
238 array: true,
239 type: "Instruction"
240 }
241 }
242});
243/*
244Concrete value types
245*/
246
247defineType("StringLiteral", {
248 unionType: ["Node", "Expression"],
249 fields: {
250 value: {
251 type: "string"
252 }
253 }
254});
255defineType("NumberLiteral", {
256 unionType: ["Node", "NumericLiteral", "Expression"],
257 fields: {
258 value: {
259 type: "number"
260 },
261 raw: {
262 type: "string"
263 }
264 }
265});
266defineType("LongNumberLiteral", {
267 unionType: ["Node", "NumericLiteral", "Expression"],
268 fields: {
269 value: {
270 type: "LongNumber"
271 },
272 raw: {
273 type: "string"
274 }
275 }
276});
277defineType("FloatLiteral", {
278 unionType: ["Node", "NumericLiteral", "Expression"],
279 fields: {
280 value: {
281 type: "number"
282 },
283 nan: {
284 optional: true,
285 type: "boolean"
286 },
287 inf: {
288 optional: true,
289 type: "boolean"
290 },
291 raw: {
292 type: "string"
293 }
294 }
295});
296defineType("Elem", {
297 unionType: ["Node"],
298 fields: {
299 table: {
300 type: "Index"
301 },
302 offset: {
303 array: true,
304 type: "Instruction"
305 },
306 funcs: {
307 array: true,
308 type: "Index"
309 }
310 }
311});
312defineType("IndexInFuncSection", {
313 unionType: ["Node"],
314 fields: {
315 index: {
316 type: "Index"
317 }
318 }
319});
320defineType("ValtypeLiteral", {
321 unionType: ["Node", "Expression"],
322 fields: {
323 name: {
324 type: "Valtype"
325 }
326 }
327});
328defineType("TypeInstruction", {
329 unionType: ["Node", "Instruction"],
330 fields: {
331 id: {
332 maybe: true,
333 type: "Index"
334 },
335 functype: {
336 type: "Signature"
337 }
338 }
339});
340defineType("Start", {
341 unionType: ["Node"],
342 fields: {
343 index: {
344 type: "Index"
345 }
346 }
347});
348defineType("GlobalType", {
349 unionType: ["Node", "ImportDescr"],
350 fields: {
351 valtype: {
352 type: "Valtype"
353 },
354 mutability: {
355 type: "Mutability"
356 }
357 }
358});
359defineType("LeadingComment", {
360 unionType: ["Node"],
361 fields: {
362 value: {
363 type: "string"
364 }
365 }
366});
367defineType("BlockComment", {
368 unionType: ["Node"],
369 fields: {
370 value: {
371 type: "string"
372 }
373 }
374});
375defineType("Data", {
376 unionType: ["Node"],
377 fields: {
378 memoryIndex: {
379 type: "Memidx"
380 },
381 offset: {
382 type: "Instruction"
383 },
384 init: {
385 type: "ByteArray"
386 }
387 }
388});
389defineType("Global", {
390 unionType: ["Node"],
391 fields: {
392 globalType: {
393 type: "GlobalType"
394 },
395 init: {
396 array: true,
397 type: "Instruction"
398 },
399 name: {
400 maybe: true,
401 type: "Identifier"
402 }
403 }
404});
405defineType("Table", {
406 unionType: ["Node", "ImportDescr"],
407 fields: {
408 elementType: {
409 type: "TableElementType"
410 },
411 limits: {
412 assertNodeType: true,
413 type: "Limit"
414 },
415 name: {
416 maybe: true,
417 type: "Identifier"
418 },
419 elements: {
420 array: true,
421 optional: true,
422 type: "Index"
423 }
424 }
425});
426defineType("Memory", {
427 unionType: ["Node", "ImportDescr"],
428 fields: {
429 limits: {
430 type: "Limit"
431 },
432 id: {
433 maybe: true,
434 type: "Index"
435 }
436 }
437});
438defineType("FuncImportDescr", {
439 unionType: ["Node", "ImportDescr"],
440 fields: {
441 id: {
442 type: "Identifier"
443 },
444 signature: {
445 type: "Signature"
446 }
447 }
448});
449defineType("ModuleImport", {
450 unionType: ["Node"],
451 fields: {
452 module: {
453 type: "string"
454 },
455 name: {
456 type: "string"
457 },
458 descr: {
459 type: "ImportDescr"
460 }
461 }
462});
463defineType("ModuleExportDescr", {
464 unionType: ["Node"],
465 fields: {
466 exportType: {
467 type: "ExportDescrType"
468 },
469 id: {
470 type: "Index"
471 }
472 }
473});
474defineType("ModuleExport", {
475 unionType: ["Node"],
476 fields: {
477 name: {
478 type: "string"
479 },
480 descr: {
481 type: "ModuleExportDescr"
482 }
483 }
484});
485defineType("Limit", {
486 unionType: ["Node"],
487 fields: {
488 min: {
489 type: "number"
490 },
491 max: {
492 optional: true,
493 type: "number"
494 },
495 // Threads proposal, shared memory
496 shared: {
497 optional: true,
498 type: "boolean"
499 }
500 }
501});
502defineType("Signature", {
503 unionType: ["Node"],
504 fields: {
505 params: {
506 array: true,
507 type: "FuncParam"
508 },
509 results: {
510 array: true,
511 type: "Valtype"
512 }
513 }
514});
515defineType("Program", {
516 unionType: ["Node"],
517 fields: {
518 body: {
519 array: true,
520 type: "Node"
521 }
522 }
523});
524defineType("Identifier", {
525 unionType: ["Node", "Expression"],
526 fields: {
527 value: {
528 type: "string"
529 },
530 raw: {
531 optional: true,
532 type: "string"
533 }
534 }
535});
536defineType("BlockInstruction", {
537 unionType: ["Node", "Block", "Instruction"],
538 fields: {
539 id: {
540 constant: true,
541 type: "string",
542 value: "block"
543 },
544 label: {
545 maybe: true,
546 type: "Identifier"
547 },
548 instr: {
549 array: true,
550 type: "Instruction"
551 },
552 result: {
553 maybe: true,
554 type: "Valtype"
555 }
556 }
557});
558defineType("CallInstruction", {
559 unionType: ["Node", "Instruction"],
560 fields: {
561 id: {
562 constant: true,
563 type: "string",
564 value: "call"
565 },
566 index: {
567 type: "Index"
568 },
569 instrArgs: {
570 array: true,
571 optional: true,
572 type: "Expression"
573 },
574 numeric: {
575 type: "Index",
576 optional: true
577 }
578 }
579});
580defineType("CallIndirectInstruction", {
581 unionType: ["Node", "Instruction"],
582 fields: {
583 id: {
584 constant: true,
585 type: "string",
586 value: "call_indirect"
587 },
588 signature: {
589 type: "SignatureOrTypeRef"
590 },
591 intrs: {
592 array: true,
593 optional: true,
594 type: "Expression"
595 }
596 }
597});
598defineType("ByteArray", {
599 unionType: ["Node"],
600 fields: {
601 values: {
602 array: true,
603 type: "Byte"
604 }
605 }
606});
607defineType("Func", {
608 unionType: ["Node", "Block"],
609 fields: {
610 name: {
611 maybe: true,
612 type: "Index"
613 },
614 signature: {
615 type: "SignatureOrTypeRef"
616 },
617 body: {
618 array: true,
619 type: "Instruction"
620 },
621 isExternal: {
622 comment: "means that it has been imported from the outside js",
623 optional: true,
624 type: "boolean"
625 },
626 metadata: {
627 optional: true,
628 type: "FuncMetadata"
629 }
630 }
631});
632/**
633 * Intrinsics
634 */
635
636defineType("InternalBrUnless", {
637 unionType: ["Node", "Intrinsic"],
638 fields: {
639 target: {
640 type: "number"
641 }
642 }
643});
644defineType("InternalGoto", {
645 unionType: ["Node", "Intrinsic"],
646 fields: {
647 target: {
648 type: "number"
649 }
650 }
651});
652defineType("InternalCallExtern", {
653 unionType: ["Node", "Intrinsic"],
654 fields: {
655 target: {
656 type: "number"
657 }
658 }
659}); // function bodies are terminated by an `end` instruction but are missing a
660// return instruction
661//
662// Since we can't inject a new instruction we are injecting a new instruction.
663
664defineType("InternalEndAndReturn", {
665 unionType: ["Node", "Intrinsic"],
666 fields: {}
667});
668module.exports = definitions;
Note: See TracBrowser for help on using the repository browser.