-
Notifications
You must be signed in to change notification settings - Fork 840
Expand file tree
/
Copy pathcontexts.h
More file actions
3005 lines (2625 loc) · 93.8 KB
/
contexts.h
File metadata and controls
3005 lines (2625 loc) · 93.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2023 WebAssembly Community Group participants
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef parser_context_h
#define parser_context_h
#include "common.h"
#include "ir/names.h"
#include "lexer.h"
#include "support/name.h"
#include "support/result.h"
#include "support/string.h"
#include "wasm-annotations.h"
#include "wasm-builder.h"
#include "wasm-ir-builder.h"
#include "wasm.h"
namespace wasm::WATParser {
using IndexMap = std::unordered_map<Name, Index>;
inline std::vector<Type> getUnnamedTypes(const std::vector<NameType>& named) {
std::vector<Type> types;
types.reserve(named.size());
for (auto& t : named) {
types.push_back(t.type);
}
return types;
}
struct Limits {
uint64_t initial;
std::optional<uint64_t> max;
};
struct MemType {
Type addressType;
Limits limits;
uint8_t pageSizeLog2;
bool shared;
};
struct Memarg {
uint64_t offset;
uint32_t align;
};
struct TableType {
Type addressType;
Limits limits;
};
// The location, possible name, and index in the respective module index space
// of a module-level definition in the input.
struct DefPos {
Name name;
Index pos;
Index index;
std::vector<Annotation> annotations;
};
struct GlobalType {
Mutability mutability;
Type type;
};
// A signature type and parameter names (possibly empty), used for parsing
// function types.
struct TypeUse {
HeapType type;
std::vector<Name> names;
};
struct NullTypeParserCtx {
using IndexT = Ok;
using HeapTypeT = Ok;
using TupleElemListT = Ok;
using TypeT = Ok;
using ParamsT = Ok;
using ResultsT = size_t;
using BlockTypeT = Ok;
using SignatureT = Ok;
using ContinuationT = Ok;
using StorageT = Ok;
using FieldT = Ok;
using FieldsT = Ok;
using StructT = Ok;
using ArrayT = Ok;
using LimitsT = Ok;
using MemTypeT = Ok;
using GlobalTypeT = Ok;
using TypeUseT = Ok;
using LocalsT = Ok;
using ElemListT = Ok;
using DataStringT = Ok;
HeapTypeT makeFuncType(Shareability) { return Ok{}; }
HeapTypeT makeAnyType(Shareability) { return Ok{}; }
HeapTypeT makeExternType(Shareability) { return Ok{}; }
HeapTypeT makeEqType(Shareability) { return Ok{}; }
HeapTypeT makeI31Type(Shareability) { return Ok{}; }
HeapTypeT makeStructType(Shareability) { return Ok{}; }
HeapTypeT makeArrayType(Shareability) { return Ok{}; }
HeapTypeT makeExnType(Shareability) { return Ok{}; }
HeapTypeT makeStringType(Shareability) { return Ok{}; }
HeapTypeT makeContType(Shareability) { return Ok{}; }
HeapTypeT makeNoneType(Shareability) { return Ok{}; }
HeapTypeT makeNoextType(Shareability) { return Ok{}; }
HeapTypeT makeNofuncType(Shareability) { return Ok{}; }
HeapTypeT makeNoexnType(Shareability) { return Ok{}; }
HeapTypeT makeNocontType(Shareability) { return Ok{}; }
TypeT makeI32() { return Ok{}; }
TypeT makeI64() { return Ok{}; }
TypeT makeF32() { return Ok{}; }
TypeT makeF64() { return Ok{}; }
TypeT makeV128() { return Ok{}; }
TypeT makeRefType(HeapTypeT, Nullability) { return Ok{}; }
TupleElemListT makeTupleElemList() { return Ok{}; }
void appendTupleElem(TupleElemListT&, TypeT) {}
TypeT makeTupleType(TupleElemListT) { return Ok{}; }
ParamsT makeParams() { return Ok{}; }
void appendParam(ParamsT&, Name, TypeT) {}
// We have to count results because whether or not a block introduces a
// typeuse that may implicitly define a type depends on how many results it
// has.
size_t makeResults() { return 0; }
void appendResult(size_t& results, TypeT) { ++results; }
size_t getResultsSize(size_t results) { return results; }
SignatureT makeFuncType(ParamsT*, ResultsT*) { return Ok{}; }
ContinuationT makeContType(HeapTypeT) { return Ok{}; }
StorageT makeI8() { return Ok{}; }
StorageT makeI16() { return Ok{}; }
StorageT makeWaitQueue() { return Ok{}; }
StorageT makeStorageType(TypeT) { return Ok{}; }
FieldT makeFieldType(StorageT, Mutability) { return Ok{}; }
FieldsT makeFields() { return Ok{}; }
void appendField(FieldsT&, Name, FieldT) {}
StructT makeStruct(FieldsT&) { return Ok{}; }
std::optional<ArrayT> makeArray(FieldsT&) { return Ok{}; }
GlobalTypeT makeGlobalType(Mutability, TypeT) { return Ok{}; }
LocalsT makeLocals() { return Ok{}; }
void appendLocal(LocalsT&, Name, TypeT) {}
Result<Index> getTypeIndex(Name) { return 1; }
Result<HeapTypeT> getHeapTypeFromIdx(Index) { return Ok{}; }
HeapTypeT makeExact(HeapTypeT) { return Ok{}; }
DataStringT makeDataString() { return Ok{}; }
void appendDataString(DataStringT&, std::string_view) {}
BlockTypeT getBlockTypeFromResult(size_t results) { return Ok{}; }
Result<> getBlockTypeFromTypeUse(Index, TypeUseT) { return Ok{}; }
bool skipFunctionBody() { return false; }
};
template<typename Ctx> struct TypeParserCtx {
// Exactness is syntactically part of the heap type, but it is not part of the
// HeapType in our IR, so we have to store it separately.
struct HeapTypeT {
HeapType type;
Exactness exactness = Inexact;
// Implicitly convert to and from HeapType.
HeapTypeT(HeapType::BasicHeapType type) : type(type) {}
HeapTypeT(HeapType type) : type(type) {}
operator HeapType() { return type; }
};
using IndexT = Index;
using TypeT = Type;
using ParamsT = std::vector<NameType>;
using ResultsT = std::vector<Type>;
using BlockTypeT = HeapType;
using SignatureT = Signature;
using ContinuationT = Continuation;
using StorageT = Field;
using FieldT = Field;
using FieldsT = std::pair<std::vector<Name>, std::vector<Field>>;
using StructT = std::pair<std::vector<Name>, Struct>;
using ArrayT = Array;
using LimitsT = Ok;
using MemTypeT = Ok;
using LocalsT = std::vector<NameType>;
using DataStringT = Ok;
// Map heap type names to their indices.
const IndexMap& typeIndices;
TypeParserCtx(const IndexMap& typeIndices) : typeIndices(typeIndices) {}
Ctx& self() { return *static_cast<Ctx*>(this); }
HeapTypeT makeFuncType(Shareability share) {
return HeapTypes::func.getBasic(share);
}
HeapTypeT makeAnyType(Shareability share) {
return HeapTypes::any.getBasic(share);
}
HeapTypeT makeExternType(Shareability share) {
return HeapTypes::ext.getBasic(share);
}
HeapTypeT makeEqType(Shareability share) {
return HeapTypes::eq.getBasic(share);
}
HeapTypeT makeI31Type(Shareability share) {
return HeapTypes::i31.getBasic(share);
}
HeapTypeT makeStructType(Shareability share) {
return HeapTypes::struct_.getBasic(share);
}
HeapTypeT makeArrayType(Shareability share) {
return HeapTypes::array.getBasic(share);
}
HeapTypeT makeExnType(Shareability share) {
return HeapTypes::exn.getBasic(share);
}
HeapTypeT makeStringType(Shareability share) {
return HeapTypes::string.getBasic(share);
}
HeapTypeT makeContType(Shareability share) {
return HeapTypes::cont.getBasic(share);
}
HeapTypeT makeNoneType(Shareability share) {
return HeapTypes::none.getBasic(share);
}
HeapTypeT makeNoextType(Shareability share) {
return HeapTypes::noext.getBasic(share);
}
HeapTypeT makeNofuncType(Shareability share) {
return HeapTypes::nofunc.getBasic(share);
}
HeapTypeT makeNoexnType(Shareability share) {
return HeapTypes::noexn.getBasic(share);
}
HeapTypeT makeNocontType(Shareability share) {
return HeapTypes::nocont.getBasic(share);
}
HeapTypeT makeExact(HeapTypeT type) {
type.exactness = Exact;
return type;
}
TypeT makeI32() { return Type::i32; }
TypeT makeI64() { return Type::i64; }
TypeT makeF32() { return Type::f32; }
TypeT makeF64() { return Type::f64; }
TypeT makeV128() { return Type::v128; }
TypeT makeRefType(HeapTypeT ht, Nullability nullability) {
return Type(ht.type, nullability, ht.exactness);
}
std::vector<Type> makeTupleElemList() { return {}; }
void appendTupleElem(std::vector<Type>& elems, Type elem) {
elems.push_back(elem);
}
Result<TypeT> makeTupleType(const std::vector<Type>& types) {
return Tuple(types);
}
ParamsT makeParams() { return {}; }
void appendParam(ParamsT& params, Name id, TypeT type) {
params.push_back({id, type});
}
ResultsT makeResults() { return {}; }
void appendResult(ResultsT& results, TypeT type) { results.push_back(type); }
size_t getResultsSize(const ResultsT& results) { return results.size(); }
SignatureT makeFuncType(ParamsT* params, ResultsT* results) {
std::vector<Type> empty;
const auto& paramTypes = params ? getUnnamedTypes(*params) : empty;
const auto& resultTypes = results ? *results : empty;
return Signature(self().makeTupleType(paramTypes),
self().makeTupleType(resultTypes));
}
ContinuationT makeContType(HeapTypeT ft) { return Continuation(ft); }
StorageT makeI8() { return Field(Field::i8, Immutable); }
StorageT makeI16() { return Field(Field::i16, Immutable); }
StorageT makeWaitQueue() { return Field(Field::WaitQueue, Immutable); }
StorageT makeStorageType(TypeT type) { return Field(type, Immutable); }
FieldT makeFieldType(FieldT field, Mutability mutability) {
if (field.packedType == Field::NotPacked) {
return Field(field.type, mutability);
}
return Field(field.packedType, mutability);
}
FieldsT makeFields() { return {}; }
void appendField(FieldsT& fields, Name name, FieldT field) {
fields.first.push_back(name);
fields.second.push_back(field);
}
StructT makeStruct(FieldsT& fields) {
return {std::move(fields.first), Struct(std::move(fields.second))};
}
std::optional<ArrayT> makeArray(FieldsT& fields) {
if (fields.second.size() == 1) {
return Array(fields.second[0]);
}
return {};
}
LocalsT makeLocals() { return {}; }
void appendLocal(LocalsT& locals, Name id, TypeT type) {
locals.push_back({id, type});
}
Result<Index> getTypeIndex(Name id) {
auto it = typeIndices.find(id);
if (it == typeIndices.end()) {
return self().in.err("unknown type identifier");
}
return it->second;
}
DataStringT makeDataString() { return Ok{}; }
void appendDataString(DataStringT&, std::string_view) {}
Result<LimitsT> makeLimits(uint64_t, std::optional<uint64_t>) { return Ok{}; }
MemTypeT makeMemType(Type, LimitsT, bool, uint8_t) { return Ok{}; }
HeapType getBlockTypeFromResult(const std::vector<Type> results) {
assert(results.size() == 1);
return HeapType(Signature(Type::none, results[0]));
}
bool skipFunctionBody() { return false; }
};
struct NullInstrParserCtx {
using ExprT = Ok;
using CatchT = Ok;
using CatchListT = Ok;
using OnClauseT = Ok;
using OnClauseListT = Ok;
using TagLabelListT = Ok;
using FieldIdxT = Ok;
using FuncIdxT = Ok;
using LocalIdxT = Ok;
using TableIdxT = Ok;
using MemoryIdxT = Ok;
using GlobalIdxT = Ok;
using ElemIdxT = Ok;
using DataIdxT = Ok;
using LabelIdxT = Ok;
using TagIdxT = Ok;
using MemargT = Ok;
Result<> makeExpr() { return Ok{}; }
template<typename HeapTypeT> FieldIdxT getFieldFromIdx(HeapTypeT, uint32_t) {
return Ok{};
}
template<typename HeapTypeT> FieldIdxT getFieldFromName(HeapTypeT, Name) {
return Ok{};
}
FuncIdxT getFuncFromIdx(uint32_t) { return Ok{}; }
FuncIdxT getFuncFromName(Name) { return Ok{}; }
LocalIdxT getLocalFromIdx(uint32_t) { return Ok{}; }
LocalIdxT getLocalFromName(Name) { return Ok{}; }
GlobalIdxT getGlobalFromIdx(uint32_t) { return Ok{}; }
GlobalIdxT getGlobalFromName(Name) { return Ok{}; }
TableIdxT getTableFromIdx(uint32_t) { return Ok{}; }
TableIdxT getTableFromName(Name) { return Ok{}; }
MemoryIdxT getMemoryFromIdx(uint32_t) { return Ok{}; }
MemoryIdxT getMemoryFromName(Name) { return Ok{}; }
ElemIdxT getElemFromIdx(uint32_t) { return Ok{}; }
ElemIdxT getElemFromName(Name) { return Ok{}; }
DataIdxT getDataFromIdx(uint32_t) { return Ok{}; }
DataIdxT getDataFromName(Name) { return Ok{}; }
LabelIdxT getLabelFromIdx(uint32_t, bool) { return Ok{}; }
LabelIdxT getLabelFromName(Name, bool) { return Ok{}; }
TagIdxT getTagFromIdx(uint32_t) { return Ok{}; }
TagIdxT getTagFromName(Name) { return Ok{}; }
MemargT getMemarg(uint64_t, uint32_t) { return Ok{}; }
template<typename BlockTypeT>
Result<> makeBlock(Index,
const std::vector<Annotation>&,
std::optional<Name>,
BlockTypeT) {
return Ok{};
}
template<typename BlockTypeT>
Result<> makeIf(Index,
const std::vector<Annotation>&,
std::optional<Name>,
BlockTypeT) {
return Ok{};
}
Result<> visitElse() { return Ok{}; }
template<typename BlockTypeT>
Result<> makeLoop(Index,
const std::vector<Annotation>&,
std::optional<Name>,
BlockTypeT) {
return Ok{};
}
template<typename BlockTypeT>
Result<> makeTry(Index,
const std::vector<Annotation>&,
std::optional<Name>,
BlockTypeT) {
return Ok{};
}
Result<> visitCatch(Index, TagIdxT) { return Ok{}; }
Result<> visitCatchAll(Index) { return Ok{}; }
Result<> visitDelegate(Index, LabelIdxT) { return Ok{}; }
Result<> visitEnd() { return Ok{}; }
CatchListT makeCatchList() { return Ok{}; }
void appendCatch(CatchListT&, CatchT) {}
CatchT makeCatch(TagIdxT, LabelIdxT) { return Ok{}; }
CatchT makeCatchRef(TagIdxT, LabelIdxT) { return Ok{}; }
CatchT makeCatchAll(LabelIdxT) { return Ok{}; }
CatchT makeCatchAllRef(LabelIdxT) { return Ok{}; }
template<typename BlockTypeT>
Result<> makeTryTable(Index,
const std::vector<Annotation>&,
std::optional<Name>,
BlockTypeT,
CatchListT) {
return Ok{};
}
OnClauseListT makeOnClauseList() { return Ok{}; }
void appendOnClause(OnClauseListT&, OnClauseT) {}
OnClauseT makeOnLabel(TagIdxT, LabelIdxT) { return Ok{}; }
OnClauseT makeOnSwitch(TagIdxT) { return Ok{}; }
void setSrcLoc(const std::vector<Annotation>&) {}
Result<> makeUnreachable(Index, const std::vector<Annotation>&) {
return Ok{};
}
Result<> makeNop(Index, const std::vector<Annotation>&) { return Ok{}; }
Result<> makeBinary(Index, const std::vector<Annotation>&, BinaryOp) {
return Ok{};
}
Result<> makeUnary(Index, const std::vector<Annotation>&, UnaryOp) {
return Ok{};
}
template<typename ResultsT>
Result<> makeSelect(Index, const std::vector<Annotation>&, ResultsT*) {
return Ok{};
}
Result<> makeDrop(Index, const std::vector<Annotation>&) { return Ok{}; }
Result<> makeMemorySize(Index, const std::vector<Annotation>&, MemoryIdxT*) {
return Ok{};
}
Result<> makeMemoryGrow(Index, const std::vector<Annotation>&, MemoryIdxT*) {
return Ok{};
}
Result<> makeLocalGet(Index, const std::vector<Annotation>&, LocalIdxT) {
return Ok{};
}
Result<> makeLocalTee(Index, const std::vector<Annotation>&, LocalIdxT) {
return Ok{};
}
Result<> makeLocalSet(Index, const std::vector<Annotation>&, LocalIdxT) {
return Ok{};
}
Result<> makeGlobalGet(Index, const std::vector<Annotation>&, GlobalIdxT) {
return Ok{};
}
Result<> makeGlobalSet(Index, const std::vector<Annotation>&, GlobalIdxT) {
return Ok{};
}
Result<> makeI32Const(Index, const std::vector<Annotation>&, uint32_t) {
return Ok{};
}
Result<> makeI64Const(Index, const std::vector<Annotation>&, uint64_t) {
return Ok{};
}
Result<> makeF32Const(Index, const std::vector<Annotation>&, float) {
return Ok{};
}
Result<> makeF64Const(Index, const std::vector<Annotation>&, double) {
return Ok{};
}
Result<> makeI8x16Const(Index,
const std::vector<Annotation>&,
const std::array<uint8_t, 16>&) {
return Ok{};
}
Result<> makeI16x8Const(Index,
const std::vector<Annotation>&,
const std::array<uint16_t, 8>&) {
return Ok{};
}
Result<> makeI32x4Const(Index,
const std::vector<Annotation>&,
const std::array<uint32_t, 4>&) {
return Ok{};
}
Result<> makeI64x2Const(Index,
const std::vector<Annotation>&,
const std::array<uint64_t, 2>&) {
return Ok{};
}
Result<> makeF32x4Const(Index,
const std::vector<Annotation>&,
const std::array<float, 4>&) {
return Ok{};
}
Result<> makeF64x2Const(Index,
const std::vector<Annotation>&,
const std::array<double, 2>&) {
return Ok{};
}
Result<> makeLoad(Index,
const std::vector<Annotation>&,
Type,
bool,
int,
bool,
MemoryIdxT*,
MemargT,
MemoryOrder) {
return Ok{};
}
Result<> makeStore(Index,
const std::vector<Annotation>&,
Type,
int,
bool,
MemoryIdxT*,
MemargT,
MemoryOrder) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeArrayStore(Index, const std::vector<Annotation>&, Type, int, HeapTypeT) {
return Ok{};
}
Result<> makeAtomicRMW(Index,
const std::vector<Annotation>&,
AtomicRMWOp,
Type,
int,
MemoryIdxT*,
MemargT,
MemoryOrder) {
return Ok{};
}
Result<> makeAtomicCmpxchg(Index,
const std::vector<Annotation>&,
Type,
int,
MemoryIdxT*,
MemargT,
MemoryOrder) {
return Ok{};
}
Result<> makeAtomicWait(
Index, const std::vector<Annotation>&, Type, MemoryIdxT*, MemargT) {
return Ok{};
}
Result<> makeAtomicNotify(Index,
const std::vector<Annotation>&,
MemoryIdxT*,
MemargT) {
return Ok{};
}
Result<> makeAtomicFence(Index, const std::vector<Annotation>&) {
return Ok{};
}
Result<> makePause(Index, const std::vector<Annotation>&) { return Ok{}; }
Result<> makeSIMDExtract(Index,
const std::vector<Annotation>&,
SIMDExtractOp,
uint8_t) {
return Ok{};
}
Result<> makeSIMDReplace(Index,
const std::vector<Annotation>&,
SIMDReplaceOp,
uint8_t) {
return Ok{};
}
Result<> makeSIMDShuffle(Index,
const std::vector<Annotation>&,
const std::array<uint8_t, 16>&) {
return Ok{};
}
Result<>
makeSIMDTernary(Index, const std::vector<Annotation>&, SIMDTernaryOp) {
return Ok{};
}
Result<> makeSIMDShift(Index, const std::vector<Annotation>&, SIMDShiftOp) {
return Ok{};
}
Result<> makeSIMDLoad(
Index, const std::vector<Annotation>&, SIMDLoadOp, MemoryIdxT*, MemargT) {
return Ok{};
}
Result<> makeSIMDLoadStoreLane(Index,
const std::vector<Annotation>&,
SIMDLoadStoreLaneOp,
MemoryIdxT*,
MemargT,
uint8_t) {
return Ok{};
}
Result<>
makeMemoryInit(Index, const std::vector<Annotation>&, MemoryIdxT*, DataIdxT) {
return Ok{};
}
Result<> makeDataDrop(Index, const std::vector<Annotation>&, DataIdxT) {
return Ok{};
}
Result<> makeMemoryCopy(Index,
const std::vector<Annotation>&,
MemoryIdxT*,
MemoryIdxT*) {
return Ok{};
}
Result<> makeMemoryFill(Index, const std::vector<Annotation>&, MemoryIdxT*) {
return Ok{};
}
template<typename TypeT>
Result<> makePop(Index, const std::vector<Annotation>&, TypeT) {
return Ok{};
}
Result<> makeCall(Index, const std::vector<Annotation>&, FuncIdxT, bool) {
return Ok{};
}
template<typename TypeUseT>
Result<> makeCallIndirect(
Index, const std::vector<Annotation>&, TableIdxT*, TypeUseT, bool) {
return Ok{};
}
Result<> makeBreak(Index, const std::vector<Annotation>&, LabelIdxT, bool) {
return Ok{};
}
Result<> makeSwitch(Index,
const std::vector<Annotation>&,
const std::vector<LabelIdxT>&,
LabelIdxT) {
return Ok{};
}
Result<> makeReturn(Index, const std::vector<Annotation>&) { return Ok{}; }
template<typename HeapTypeT>
Result<> makeRefNull(Index, const std::vector<Annotation>&, HeapTypeT) {
return Ok{};
}
Result<> makeRefIsNull(Index, const std::vector<Annotation>&) { return Ok{}; }
Result<> makeRefFunc(Index, const std::vector<Annotation>&, FuncIdxT) {
return Ok{};
}
Result<> makeRefEq(Index, const std::vector<Annotation>&) { return Ok{}; }
Result<> makeTableGet(Index, const std::vector<Annotation>&, TableIdxT*) {
return Ok{};
}
Result<> makeTableSet(Index, const std::vector<Annotation>&, TableIdxT*) {
return Ok{};
}
Result<> makeTableSize(Index, const std::vector<Annotation>&, TableIdxT*) {
return Ok{};
}
Result<> makeTableGrow(Index, const std::vector<Annotation>&, TableIdxT*) {
return Ok{};
}
Result<> makeTableFill(Index, const std::vector<Annotation>&, TableIdxT*) {
return Ok{};
}
Result<>
makeTableCopy(Index, const std::vector<Annotation>&, TableIdxT*, TableIdxT*) {
return Ok{};
}
Result<>
makeTableInit(Index, const std::vector<Annotation>&, TableIdxT*, ElemIdxT) {
return Ok{};
}
Result<> makeElemDrop(Index, const std::vector<Annotation>&, ElemIdxT) {
return Ok{};
}
Result<> makeThrow(Index, const std::vector<Annotation>&, TagIdxT) {
return Ok{};
}
Result<> makeRethrow(Index, const std::vector<Annotation>&, LabelIdxT) {
return Ok{};
}
Result<> makeThrowRef(Index, const std::vector<Annotation>&) { return Ok{}; }
Result<> makeTupleMake(Index, const std::vector<Annotation>&, uint32_t) {
return Ok{};
}
Result<>
makeTupleExtract(Index, const std::vector<Annotation>&, uint32_t, uint32_t) {
return Ok{};
}
Result<> makeTupleDrop(Index, const std::vector<Annotation>&, uint32_t) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeCallRef(Index, const std::vector<Annotation>&, HeapTypeT, bool) {
return Ok{};
}
Result<>
makeRefI31(Index, const std::vector<Annotation>&, Shareability share) {
return Ok{};
}
Result<> makeI31Get(Index, const std::vector<Annotation>&, bool) {
return Ok{};
}
template<typename TypeT>
Result<> makeRefTest(Index, const std::vector<Annotation>&, TypeT) {
return Ok{};
}
template<typename TypeT>
Result<> makeRefCast(Index, const std::vector<Annotation>&, TypeT, bool) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeRefGetDesc(Index, const std::vector<Annotation>&, HeapTypeT) {
return Ok{};
}
Result<> makeBrOn(Index, const std::vector<Annotation>&, LabelIdxT, BrOnOp) {
return Ok{};
}
template<typename TypeT>
Result<> makeBrOn(
Index, const std::vector<Annotation>&, LabelIdxT, BrOnOp, TypeT, TypeT) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeStructNew(Index, const std::vector<Annotation>&, HeapTypeT, bool) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeStructNewDefault(Index, const std::vector<Annotation>&, HeapTypeT, bool) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeStructGet(Index,
const std::vector<Annotation>&,
HeapTypeT,
FieldIdxT,
bool,
MemoryOrder) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeStructSet(
Index, const std::vector<Annotation>&, HeapTypeT, FieldIdxT, MemoryOrder) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeStructRMW(Index,
const std::vector<Annotation>&,
AtomicRMWOp,
HeapTypeT,
FieldIdxT,
MemoryOrder) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeStructCmpxchg(
Index, const std::vector<Annotation>&, HeapTypeT, FieldIdxT, MemoryOrder) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeStructWait(Index, const std::vector<Annotation>&, HeapTypeT, FieldIdxT) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeStructNotify(Index,
const std::vector<Annotation>&,
HeapTypeT,
FieldIdxT) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeArrayNew(Index, const std::vector<Annotation>&, HeapTypeT) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeArrayNewDefault(Index, const std::vector<Annotation>&, HeapTypeT) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeArrayNewData(Index, const std::vector<Annotation>&, HeapTypeT, DataIdxT) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeArrayNewElem(Index, const std::vector<Annotation>&, HeapTypeT, ElemIdxT) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeArrayNewFixed(Index,
const std::vector<Annotation>&,
HeapTypeT,
uint32_t) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeArrayGet(
Index, const std::vector<Annotation>&, HeapTypeT, bool, MemoryOrder) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeArraySet(Index, const std::vector<Annotation>&, HeapTypeT, MemoryOrder) {
return Ok{};
}
Result<> makeArrayLen(Index, const std::vector<Annotation>&) { return Ok{}; }
template<typename HeapTypeT>
Result<>
makeArrayCopy(Index, const std::vector<Annotation>&, HeapTypeT, HeapTypeT) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeArrayFill(Index, const std::vector<Annotation>&, HeapTypeT) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeArrayInitData(Index,
const std::vector<Annotation>&,
HeapTypeT,
DataIdxT) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeArrayInitElem(Index,
const std::vector<Annotation>&,
HeapTypeT,
ElemIdxT) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeArrayRMW(Index,
const std::vector<Annotation>&,
AtomicRMWOp,
HeapTypeT,
MemoryOrder) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeArrayCmpxchg(Index,
const std::vector<Annotation>&,
HeapTypeT,
MemoryOrder) {
return Ok{};
}
Result<> makeRefAs(Index, const std::vector<Annotation>&, RefAsOp) {
return Ok{};
}
Result<> makeStringNew(Index, const std::vector<Annotation>&, StringNewOp) {
return Ok{};
}
Result<>
makeStringConst(Index, const std::vector<Annotation>&, std::string_view) {
return Ok{};
}
Result<>
makeStringMeasure(Index, const std::vector<Annotation>&, StringMeasureOp) {
return Ok{};
}
Result<>
makeStringEncode(Index, const std::vector<Annotation>&, StringEncodeOp) {
return Ok{};
}
Result<> makeStringConcat(Index, const std::vector<Annotation>&) {
return Ok{};
}
Result<> makeStringEq(Index, const std::vector<Annotation>&, StringEqOp) {
return Ok{};
}
Result<> makeStringTest(Index, const std::vector<Annotation>&) {
return Ok{};
}
Result<> makeStringWTF8Advance(Index, const std::vector<Annotation>&) {
return Ok{};
}
Result<> makeStringWTF16Get(Index, const std::vector<Annotation>&) {
return Ok{};
}
Result<> makeStringIterNext(Index, const std::vector<Annotation>&) {
return Ok{};
}
Result<> makeStringSliceWTF(Index, const std::vector<Annotation>&) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeContNew(Index, const std::vector<Annotation>&, HeapTypeT) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeContBind(Index, const std::vector<Annotation>&, HeapTypeT, HeapTypeT) {
return Ok{};
}
Result<> makeSuspend(Index, const std::vector<Annotation>&, TagIdxT) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeResume(Index,
const std::vector<Annotation>&,
HeapTypeT,
const TagLabelListT&) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeResumeThrow(Index,
const std::vector<Annotation>&,
HeapTypeT,
TagIdxT,
const TagLabelListT&) {
return Ok{};
}
template<typename HeapTypeT>
Result<> makeResumeThrowRef(Index,
const std::vector<Annotation>&,
HeapTypeT,
const TagLabelListT&) {
return Ok{};
}
template<typename HeapTypeT>
Result<>
makeStackSwitch(Index, const std::vector<Annotation>&, HeapTypeT, TagIdxT) {
return Ok{};
}
};
struct NullCtx : NullTypeParserCtx, NullInstrParserCtx {
Lexer in;
NullCtx(const Lexer& in) : in(in) {}
Result<> makeTypeUse(Index, std::optional<HeapTypeT>, ParamsT*, ResultsT*) {
return Ok{};
}
};
// Phase 1: Parse definition spans for top-level module elements and determine
// their indices and names.
struct ParseDeclsCtx : NullTypeParserCtx, NullInstrParserCtx {
using ExprT = Ok;
using LimitsT = Limits;
using ElemListT = Index;
using DataStringT = std::vector<char>;
using TableTypeT = TableType;
using MemTypeT = MemType;
Lexer in;
// At this stage we only look at types to find implicit type definitions,
// which are inserted directly into the context. We cannot materialize or
// validate any types because we don't know what types exist yet.
//
// Declared module elements are inserted into the module, but their bodies are