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