123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113type('desc,'info)annotated=('desc,'info)Wax_utils.Ast.annotated={desc:'desc;info:'info;}typelocation=Wax_utils.Ast.location={loc_start:Lexing.position;loc_end:Lexing.position;}letno_loc=Wax_utils.Ast.no_locletdummy_loc=Wax_utils.Ast.dummy_locmoduleUint32=Wax_utils.Uint32moduleUint64=Wax_utils.Uint64(* Types *)typepackedtype=I8|I16type'typmuttype={mut:bool;typ:'typ}typelimits={mi:Uint64.t;ma:Uint64.toption;address_type:[`I32|`I64];(* Custom page size, as its base-2 logarithm, for a memory that declares one
([None] is the default 65536-byte page, i.e. exponent 16). Always [None]
for a table. *)page_size_log2:intoption;(* A shared memory (the threads proposal); always [false] for a table. *)shared:bool;}(* The set of types produced by [Make_types], abstracted over the index and
array-wrapper representations. Naming it lets [Map_types] below map the whole
family from one instance to another. *)moduletypeTYPES=sigtypeidxtype'aannotated_arraytype'aopt_annotated_arraytypeheaptype=|Func|NoFunc|Exn|NoExn|Cont|NoCont|Extern|NoExtern|Any|Eq|I31|Struct|Array|None_|Typeofidx|Exactofidxtypereftype={nullable:bool;typ:heaptype}typevaltype=I32|I64|F32|F64|V128|Refofreftypetypefunctype={params:valtypeopt_annotated_array;results:valtypearray;}typenonrecpackedtype=packedtype=I8|I16typestoragetype=Valueofvaltype|Packedofpackedtypetypenonrec'typmuttype='typmuttype={mut:bool;typ:'typ}typefieldtype=storagetypemuttypetypecomptype=|Funcoffunctype|Structoffieldtypeannotated_array|Arrayoffieldtype|Contofidxtypesubtype={typ:comptype;supertype:idxoption;final:bool;descriptor:idxoption;describes:idxoption;}typerectype=subtypeannotated_arraytypenonreclimits=limits={mi:Uint64.t;ma:Uint64.toption;address_type:[`I32|`I64];page_size_log2:intoption;shared:bool;}typeglobaltype=valtypemuttypevalheaptype_keyword:heaptype->stringoptionendmoduleMake_types(X:sigtypeidxtype'aannotated_arraytype'aopt_annotated_arrayend):TYPESwithtypeidx=X.idxandtype'aannotated_array='aX.annotated_arrayandtype'aopt_annotated_array='aX.opt_annotated_array=structtypeidx=X.idxtypenonrec'aannotated_array='aX.annotated_arraytypenonrec'aopt_annotated_array='aX.opt_annotated_arraytypeheaptype=|Func|NoFunc|Exn|NoExn|Cont|NoCont|Extern|NoExtern|Any|Eq|I31|Struct|Array|None_|TypeofX.idx|ExactofX.idx(* The keyword naming a heap type, shared by both printers; [None] for the
[Type] and [Exact] cases, whose index each printer renders in its own way. *)letheaptype_keyword(ty:heaptype)=matchtywith|Func->Some"func"|NoFunc->Some"nofunc"|Exn->Some"exn"|NoExn->Some"noexn"|Cont->Some"cont"|NoCont->Some"nocont"|Extern->Some"extern"|NoExtern->Some"noextern"|Any->Some"any"|Eq->Some"eq"|I31->Some"i31"|Struct->Some"struct"|Array->Some"array"|None_->Some"none"|Type_->None|Exact_->Nonetypereftype={nullable:bool;typ:heaptype}typevaltype=I32|I64|F32|F64|V128|Refofreftypetypefunctype={params:valtypeX.opt_annotated_array;results:valtypearray;}typenonrecpackedtype=packedtype=I8|I16typestoragetype=Valueofvaltype|Packedofpackedtypetypenonrec'typmuttype='typmuttype={mut:bool;typ:'typ}typefieldtype=storagetypemuttypetypecomptype=|Funcoffunctype|StructoffieldtypeX.annotated_array|Arrayoffieldtype|ContofX.idxtypesubtype={typ:comptype;supertype:X.idxoption;final:bool;(* custom-descriptors: the type this struct's runtime descriptor has
([(descriptor $d)]), and the type this struct is the descriptor of
([(describes $o)]). A type may carry either, both, or neither. *)descriptor:X.idxoption;describes:X.idxoption;}typerectype=subtypeX.annotated_arraytypenonreclimits=limits={mi:Uint64.t;ma:Uint64.toption;address_type:[`I32|`I64];page_size_log2:intoption;shared:bool;}typeglobaltype=valtypemuttypeend(* Map the [heaptype]/[reftype]/[valtype]/[storagetype]/[fieldtype] family from
one [Make_types] instance to another. Only the [idx]-carrying arms actually
differ between instances; every other constructor is copied through. [ctx] is
threaded to [M.idx] so a mapper that resolves or renames indices can carry its
context (a name map, a symbol table, …) exactly as a hand-written mapper
would. *)moduleMap_types_spine(Src:TYPES)(Dst:TYPES)(M:sigtypectxvalidx:ctx->Src.idx->Dst.idxend)=structletheaptypectx(h:Src.heaptype):Dst.heaptype=matchhwith|Func->Func|NoFunc->NoFunc|Exn->Exn|NoExn->NoExn|Cont->Cont|NoCont->NoCont|Extern->Extern|NoExtern->NoExtern|Any->Any|Eq->Eq|I31->I31|Struct->Struct|Array->Array|None_->None_|Typei->Type(M.idxctxi)|Exacti->Exact(M.idxctxi)letreftypectx(r:Src.reftype):Dst.reftype={nullable=r.nullable;typ=heaptypectxr.typ}letvaltypectx(v:Src.valtype):Dst.valtype=matchvwith|I32->I32|I64->I64|F32->F32|F64->F64|V128->V128|Refr->Ref(reftypectxr)letstoragetypectx(s:Src.storagetype):Dst.storagetype=matchswithValuev->Value(valtypectxv)|Packedp->Packedpletfieldtypectx(f:Src.fieldtype):Dst.fieldtype={mut=f.mut;typ=storagetypectxf.typ}end(* Extends {!Map_types_spine} to the whole type family. The array wrappers differ
per instance, so the caller supplies how to map each one (dropping or adding
annotations, looking up names, …); the [functype]/[comptype]/[subtype]/
[rectype] structure is then copied through. *)moduleMap_types(Src:TYPES)(Dst:TYPES)(M:sigtypectxvalidx:ctx->Src.idx->Dst.idxvalparams:ctx->(Src.valtype->Dst.valtype)->Src.valtypeSrc.opt_annotated_array->Dst.valtypeDst.opt_annotated_arrayvalfields:ctx->(Src.fieldtype->Dst.fieldtype)->Src.fieldtypeSrc.annotated_array->Dst.fieldtypeDst.annotated_arrayvalmembers:ctx->(Src.subtype->Dst.subtype)->Src.subtypeSrc.annotated_array->Dst.subtypeDst.annotated_arrayend)=structincludeMap_types_spine(Src)(Dst)(structtypectx=M.ctxletidx=M.idxend)letfunctypectx(t:Src.functype):Dst.functype={params=M.paramsctx(valtypectx)t.params;results=Array.map(valtypectx)t.results;}letcomptypectx(c:Src.comptype):Dst.comptype=matchcwith|Funct->Func(functypectxt)|Structa->Struct(M.fieldsctx(fieldtypectx)a)|Arrayf->Array(fieldtypectxf)|Conti->Cont(M.idxctxi)letsubtypectx(s:Src.subtype):Dst.subtype={typ=comptypectxs.typ;supertype=Option.map(M.idxctx)s.supertype;final=s.final;descriptor=Option.map(M.idxctx)s.descriptor;describes=Option.map(M.idxctx)s.describes;}letrectypectx(r:Src.rectype):Dst.rectype=M.membersctx(subtypectx)rend(* Instructions *)typesignage=Signed|Unsignedtypeint_un_op=|Clz|Ctz|Popcnt|Eqz|Truncof[`F32|`F64]*signage|TruncSatof[`F32|`F64]*signage|Reinterpret|ExtendSof[`_8|`_16|`_32]typeint_bin_op=|Add|Sub|Mul|Divofsignage|Remofsignage|And|Or|Xor|Shl|Shrofsignage|Rotl|Rotr|Eq|Ne|Ltofsignage|Gtofsignage|Leofsignage|Geofsignagetypefloat_un_op=|Neg|Abs|Ceil|Floor|Trunc|Nearest|Sqrt|Convertof[`I32|`I64]*signage|Reinterprettypefloat_bin_op=|Add|Sub|Mul|Div|Min|Max|CopySign|Eq|Ne|Lt|Gt|Le|Getypenum_type=NumI32|NumI64|NumF32|NumF64typevec_shape=I8x16|I16x8|I32x4|I64x2|F32x4|F64x2typevec_un_op=|VecNegofvec_shape|VecAbsofvec_shape|VecSqrtof[`F32|`F64]|VecNot|VecTruncSatof[`F32|`F64]*signage|VecConvertof[`F32|`F64]*signage|VecExtendof[`Low|`High]*[`_8|`_16|`_32]*signage|VecPromote(* f32x4 => f64x2 *)|VecDemote(* f64x2 => f32x2 *)|VecCeilof[`F32|`F64]|VecFloorof[`F32|`F64]|VecTruncof[`F32|`F64]|VecNearestof[`F32|`F64]|VecPopcnt|VecExtAddPairwiseofsignage*[`I8|`I16](* Relaxed SIMD *)|VecRelaxedTruncofsignage|VecRelaxedTruncZeroofsignagetypevec_bin_op=|VecAddofvec_shape|VecSubofvec_shape|VecMulofvec_shape|VecDivof[`F32|`F64]|VecMinofsignageoption*vec_shape|VecMaxofsignageoption*vec_shape|VecPMinof[`F32|`F64]|VecPMaxof[`F32|`F64]|VecAvgrof[`I8|`I16]|VecQ15MulrSat|VecAddSatofsignage*[`I8|`I16]|VecSubSatofsignage*[`I8|`I16]|VecDot|VecEqofvec_shape|VecNeofvec_shape|VecLtofsignageoption*vec_shape|VecGtofsignageoption*vec_shape|VecLeofsignageoption*vec_shape|VecGeofsignageoption*vec_shape|VecAnd|VecOr|VecXor|VecAndNot|VecNarrowofsignage*[`I8|`I16]|VecSwizzle|VecExtMulLowofsignage*[`_8|`_16|`_32]|VecExtMulHighofsignage*[`_8|`_16|`_32](* Relaxed SIMD *)|VecRelaxedSwizzle|VecRelaxedMinofvec_shape|VecRelaxedMaxofvec_shape|VecRelaxedQ15Mulr|VecRelaxedDottypevec_test_op=AnyTrue|AllTrueofvec_shapetypevec_shift_op=Shlofvec_shape|Shrofsignage*vec_shapetypevec_bitmask_op=Bitmaskofvec_shapetypevec_tern_op=|VecRelaxedMAddof[`F32|`F64]|VecRelaxedNMAddof[`F32|`F64]|VecRelaxedLaneSelectofvec_shape|VecRelaxedDotAddtypevec_load_op=|Load128|Load8x8S|Load8x8U|Load16x4S|Load16x4U|Load32x2S|Load32x2U|Load32Zero|Load64Zero(* Atomic memory operations (the threads proposal). The width option is [None]
for the value type's full width and [Some w] for a narrower access, which is
always zero-extended (the [_u] mnemonics). *)typeatomic_rmwop=|AtomicAdd|AtomicSub|AtomicAnd|AtomicOr|AtomicXor|AtomicXchg|AtomicCmpxchgtypeatomicop=|AtomicNotify|AtomicWaitof[`I32|`I64]|AtomicLoadof[`I32|`I64]*[`I8|`I16|`I32]option|AtomicStoreof[`I32|`I64]*[`I8|`I16|`I32]option|AtomicRmwofatomic_rmwop*[`I32|`I64]*[`I8|`I16|`I32]optiontype('i32,'i64,'f32,'f64)op=|I32of'i32|I64of'i64|F32of'f32|F64of'f64typememarg={offset:Uint64.t;align:Uint64.t(* The wasm test suite contains large align values *);}(* Condition of a conditional annotation [(@if ...)], as used by the
js_of_ocaml WAT preprocessor. We parse and preserve these conditions but
do not evaluate them. *)typecmp_op=Eq|Ne|Lt|Gt|Le|Getypecond=|Cond_varof(string,location)annotated(* a variable, written [$name] *)|Cond_stringof(string,location)annotated|Cond_versionofint*int*int|Cond_andofcondlist|Cond_orofcondlist|Cond_notofcond|Cond_cmpofcmp_op*cond*condmoduleMake_instructions(X:sigtypeidxtypetypeusetypelabeltypeheaptypetypereftypetypevaltypetypeint32_ttypeint64_ttypef32_ttypefloat_ttypev128_tend)=structtypenonrec('i32,'i64,'f32,'f64)op=('i32,'i64,'f32,'f64)op=|I32of'i32|I64of'i64|F32of'f32|F64of'f64typenonrecsignage=signage=Signed|Unsignedtypenonrecint_un_op=int_un_op=|Clz|Ctz|Popcnt|Eqz|Truncof[`F32|`F64]*signage|TruncSatof[`F32|`F64]*signage|Reinterpret|ExtendSof[`_8|`_16|`_32]typenonrecint_bin_op=int_bin_op=|Add|Sub|Mul|Divofsignage|Remofsignage|And|Or|Xor|Shl|Shrofsignage|Rotl|Rotr|Eq|Ne|Ltofsignage|Gtofsignage|Leofsignage|Geofsignagetypenonrecfloat_un_op=float_un_op=|Neg|Abs|Ceil|Floor|Trunc|Nearest|Sqrt|Convertof[`I32|`I64]*signage|Reinterprettypenonrecfloat_bin_op=float_bin_op=|Add|Sub|Mul|Div|Min|Max|CopySign|Eq|Ne|Lt|Gt|Le|Getypenonrecnum_type=num_type=NumI32|NumI64|NumF32|NumF64typenonrecvec_shape=vec_shape=|I8x16|I16x8|I32x4|I64x2|F32x4|F64x2typenonrecvec_un_op=vec_un_op=|VecNegofvec_shape|VecAbsofvec_shape|VecSqrtof[`F32|`F64]|VecNot|VecTruncSatof[`F32|`F64]*signage|VecConvertof[`F32|`F64]*signage|VecExtendof[`Low|`High]*[`_8|`_16|`_32]*signage|VecPromote(* f32x4 => f64x2 *)|VecDemote(* f64x2 => f32x2 *)|VecCeilof[`F32|`F64]|VecFloorof[`F32|`F64]|VecTruncof[`F32|`F64]|VecNearestof[`F32|`F64]|VecPopcnt|VecExtAddPairwiseofsignage*[`I8|`I16](* Relaxed SIMD *)|VecRelaxedTruncofsignage|VecRelaxedTruncZeroofsignagetypenonrecvec_bin_op=vec_bin_op=|VecAddofvec_shape|VecSubofvec_shape|VecMulofvec_shape|VecDivof[`F32|`F64]|VecMinofsignageoption*vec_shape|VecMaxofsignageoption*vec_shape|VecPMinof[`F32|`F64]|VecPMaxof[`F32|`F64]|VecAvgrof[`I8|`I16]|VecQ15MulrSat|VecAddSatofsignage*[`I8|`I16]|VecSubSatofsignage*[`I8|`I16]|VecDot|VecEqofvec_shape|VecNeofvec_shape|VecLtofsignageoption*vec_shape|VecGtofsignageoption*vec_shape|VecLeofsignageoption*vec_shape|VecGeofsignageoption*vec_shape|VecAnd|VecOr|VecXor|VecAndNot|VecNarrowofsignage*[`I8|`I16]|VecSwizzle|VecExtMulLowofsignage*[`_8|`_16|`_32]|VecExtMulHighofsignage*[`_8|`_16|`_32](* Relaxed SIMD *)|VecRelaxedSwizzle|VecRelaxedMinofvec_shape|VecRelaxedMaxofvec_shape|VecRelaxedQ15Mulr|VecRelaxedDottypenonrecvec_test_op=vec_test_op=AnyTrue|AllTrueofvec_shapetypenonrecvec_shift_op=vec_shift_op=|Shlofvec_shape|Shrofsignage*vec_shapetypenonrecvec_bitmask_op=vec_bitmask_op=Bitmaskofvec_shapetypenonrecvec_tern_op=vec_tern_op=|VecRelaxedMAddof[`F32|`F64]|VecRelaxedNMAddof[`F32|`F64]|VecRelaxedLaneSelectofvec_shape|VecRelaxedDotAddtypenonrecvec_load_op=vec_load_op=|Load128|Load8x8S|Load8x8U|Load16x4S|Load16x4U|Load32x2S|Load32x2U|Load32Zero|Load64Zerotypeblocktype=TypeuseofX.typeuse|ValtypeofX.valtypetypenonrecmemarg=memarg={offset:Uint64.t;align:Uint64.t(* The wasm test suite contains large align values *);}typecatch=|CatchofX.idx*X.idx|CatchRefofX.idx*X.idx|CatchAllofX.idx|CatchAllRefofX.idxtypeon_clause=OnLabelofX.idx*X.idx|OnSwitchofX.idxtype'infoinstr_desc=|Blockof{label:X.label;typ:blocktypeoption;block:('infoinstrlist,location)annotated;}|Loopof{label:X.label;typ:blocktypeoption;block:('infoinstrlist,location)annotated;}|Ifof{label:X.label;typ:blocktypeoption;if_block:('infoinstrlist,location)annotated;else_block:('infoinstrlist,location)annotated;}|TryTableof{label:X.label;typ:blocktypeoption;catches:catchlist;block:('infoinstrlist,location)annotated;}|Tryof{label:X.label;typ:blocktypeoption;block:('infoinstrlist,location)annotated;catches:(X.idx*('infoinstrlist,location)annotated)list;catch_all:('infoinstrlist,location)annotatedoption;}|Unreachable|Nop|ThrowofX.idx|ThrowRef|ContNewofX.idx|ContBindofX.idx*X.idx|SuspendofX.idx|ResumeofX.idx*on_clauselist|ResumeThrowofX.idx*X.idx*on_clauselist|ResumeThrowRefofX.idx*on_clauselist|SwitchofX.idx*X.idx|BrofX.idx|Br_ifofX.idx|Br_tableofX.idxlist*X.idx|Br_on_nullofX.idx|Br_on_non_nullofX.idx|Br_on_castofX.idx*X.reftype*X.reftype|Br_on_cast_failofX.idx*X.reftype*X.reftype|Br_on_cast_desc_eqofX.idx*X.reftype*X.reftype|Br_on_cast_desc_eq_failofX.idx*X.reftype*X.reftype(* Branch-hinting proposal: wraps a conditional branch ([if], [br_if], or a
[br_on_*]) with its hint ([true] = likely taken, [false] = unlikely). No
bytecode of its own; the hint is emitted into the [metadata.code.branch_hint]
section at the wrapped instruction's offset. *)|Hintedof(* likely *)bool*'infoinstr|Return|CallofX.idx|CallRefofX.idx|CallIndirectofX.idx*X.typeuse|ReturnCallofX.idx|ReturnCallRefofX.idx|ReturnCallIndirectofX.idx*X.typeuse|Drop|SelectofX.valtypelistoption|LocalGetofX.idx|LocalSetofX.idx|LocalTeeofX.idx|GlobalGetofX.idx|GlobalSetofX.idx|LoadofX.idx*memarg*num_type|LoadSofX.idx*memarg*[`I32|`I64]*[`I8|`I16|`I32]*signage|StoreofX.idx*memarg*num_type|StoreSofX.idx*memarg*[`I32|`I64]*[`I8|`I16|`I32]|AtomicofX.idx*atomicop*memarg|AtomicFence|MemorySizeofX.idx|MemoryGrowofX.idx|MemoryFillofX.idx|MemoryCopyofX.idx*X.idx|MemoryInitofX.idx*X.idx|DataDropofX.idx|TableGetofX.idx|TableSetofX.idx|TableSizeofX.idx|TableGrowofX.idx|TableFillofX.idx|TableCopyofX.idx*X.idx|TableInitofX.idx*X.idx|ElemDropofX.idx|RefNullofX.heaptype|RefFuncofX.idx|RefIsNull|RefAsNonNull|RefEq|RefTestofX.reftype|RefCastofX.reftype|RefCastDescEqofX.reftype|RefGetDescofX.idx|StructNewofX.idx|StructNewDefaultofX.idx|StructNewDescofX.idx|StructNewDefaultDescofX.idx|StructGetofsignageoption*X.idx*X.idx|StructSetofX.idx*X.idx|ArrayNewofX.idx|ArrayNewDefaultofX.idx|ArrayNewFixedofX.idx*Uint32.t|ArrayNewDataofX.idx*X.idx|ArrayNewElemofX.idx*X.idx|ArrayGetofsignageoption*X.idx|ArraySetofX.idx|ArrayLen|ArrayFillofX.idx|ArrayCopyofX.idx*X.idx|ArrayInitDataofX.idx*X.idx|ArrayInitElemofX.idx*X.idx|RefI31|I31Getofsignage|Constof(X.int32_t,X.int64_t,X.f32_t,X.float_t)op|BinOpof(int_bin_op,int_bin_op,float_bin_op,float_bin_op)op|UnOpof(int_un_op,int_un_op,float_un_op,float_un_op)op(* Wide arithmetic: [i64 i64 i64 i64] -> [i64 i64] and, for [MulWide],
[i64 i64] -> [i64 i64]. Each operand/result pair is (low, high). *)|Add128|Sub128|MulWideofsignage|VecConstofX.v128_t|VecUnOpofvec_un_op|VecBinOpofvec_bin_op|VecTestofvec_test_op|VecShiftofvec_shift_op|VecBitmaskofvec_bitmask_op(* Relaxed SIMD *)|VecTernOpofvec_tern_op|VecBitselect|VecLoadofX.idx*vec_load_op*memarg|VecStoreofX.idx*memarg|VecLoadLaneofX.idx*[`I8|`I16|`I32|`I64]*memarg*int|VecStoreLaneofX.idx*[`I8|`I16|`I32|`I64]*memarg*int|VecLoadSplatofX.idx*[`I8|`I16|`I32|`I64]*memarg|VecExtractofvec_shape*signageoption*int|VecReplaceofvec_shape*int|VecSplatofvec_shape|VecShuffleofstring|I32WrapI64|I64ExtendI32ofsignage|F32DemoteF64|F64PromoteF32|ExternConvertAny|AnyConvertExtern|Foldedof'infoinstr*'infoinstrlist(* Our extensions *)|StringofX.idxoption*(string,location)annotatedlist|CharofUchar.t|If_annotationof{cond:cond;then_body:('infoinstrlist,location)annotated;else_body:('infoinstrlist,location)annotatedoption;}and'infoinstr=('infoinstr_desc,'info)annotatedtype'infoexpr='infoinstrlistend(* Modules *)typeexportable=Func|Memory|Table|Tag|GlobalmoduleText=structtypename=(string,location)annotatedtypeidx_desc=NumofUint32.t|Idofstringtypeidx=(idx_desc,location)annotatedmoduleX=structtypenonrecidx=idxtype'aannotated_array=(nameoption*'a,location)annotatedarraytype'aopt_annotated_array=(nameoption*'a,location)annotatedarraytypelabel=nameoptionendmoduleTypes=Make_types(X)include(Types:moduletypeofTypeswithtypeidx:=idx)typetypeuse=idxoption*functypeoptiontypetabletype={limits:(limits,location)annotated;reftype:reftype}includeMake_instructions(structincludeXincludeTypestypenonrectypeuse=typeusetypeint32_t=stringtypeint64_t=stringtypef32_t=stringtypefloat_t=stringtypev128_t=Wax_utils.V128.tend)typedatastring=(string,location)annotatedlist(* A data segment's contents (WAT numeric-values proposal): a sequence of
elements, each a byte string, a typed numeric run ([(i16 -1 2)], values kept
as raw literal strings), or a run of [v128] constants. Encoded little-endian
and concatenated at lowering. *)typedatavalelem=|Strofstring|Numlistofstoragetype*stringlist|V128listofWax_utils.V128.tlisttypedataval=(datavalelem,location)annotatedlisttypeimportdesc=|Funcof{exact:bool;typ:typeuse}|Memoryof(limits,location)annotated|Tableoftabletype|Globalofglobaltype|Tagoftypeusetypenonrecexportable=exportable=Func|Memory|Table|Tag|Globaltype'infodatamode=Passive|Activeofidx*'infoexprtype'infoelemmode=Passive|Activeofidx*'infoexpr|Declaretype'infotableinit=|Init_default|Init_exprof'infoexpr|Init_segmentof'infoexprlisttype'infomodulefield=|Typesofrectype|Importof{module_:name;name:name;id:nameoption;desc:importdesc;exports:namelist;}(* compact-import-section proposal: a run of same-module imports written as
one [(import "m" (item …) …)]. [Import_group1] carries a type per item;
[Import_group2] shares one type across name-only items. Both expand to
individual imports in every lowering pass; only the parser, printer and
binary codec treat them as groups (to preserve the form on round-trip). *)|Import_group1of{module_:name;items:(name*nameoption*importdesc)list;}(* [items] is [(name, id)] per entry; the id is a wax extension — the standard
form writes name-only [(item "n")]. It is text-only, round-tripping through
the binary name section rather than the import section. *)|Import_group2of{module_:name;desc:importdesc;items:(name*nameoption)list;}|Funcof{id:nameoption;typ:typeuse;locals:(nameoption*valtype,location)annotatedlist;instrs:'infoinstrlist;exports:namelist;}|Memoryof{id:nameoption;limits:(limits,location)annotated;init:datavaloption;exports:namelist;}|Tableof{id:nameoption;typ:tabletype;init:'infotableinit;exports:namelist;}|Tagof{id:nameoption;typ:typeuse;exports:namelist}|Globalof{id:nameoption;typ:globaltype;init:'infoexpr;exports:namelist;}|Exportof{name:name;kind:exportable;index:idx}|Startofidx|Elemof{id:nameoption;typ:reftype;init:'infoexprlist;mode:'infoelemmode;}|Dataof{id:nameoption;init:dataval;mode:'infodatamode}(* Our extensions *)|String_globalof{id:name;typ:idxoption;init:datastring}(* A module-level [(@feature "name")] annotation: the module declares it
uses the named optional proposal (the Wax [#![feature = "…"]] inner
attribute). *)|Feature_annotationofname|Module_if_annotationof{cond:cond;then_fields:(('infomodulefield,location)annotatedlist,location)annotated;else_fields:(('infomodulefield,location)annotatedlist,location)annotatedoption;}type'infomodule_=nameoption*('infomodulefield,location)annotatedlistendmoduleBinary=structtypeidx=intmoduleX=structtypenonrecidx=idxtype'aannotated_array='aarraytype'aopt_annotated_array='aarraytypelabel=unitendmoduleTypes=Make_types(X)include(Types:moduletypeofTypeswithtypeidx:=idx)typetypeuse=idxtypetabletype={limits:limits;reftype:reftype}includeMake_instructions(structincludeXincludeTypestypenonrectypeuse=typeusetypeint32_t=Int32.ttypeint64_t=Int64.t(* An f32 constant is kept as its raw 32 bits, never as an OCaml [float]
(a 64-bit double): widening single->double quiets a signaling NaN, so the
value could not survive the round trip otherwise. *)typef32_t=Int32.ttypefloat_t=floattypev128_t=stringend)typenonrecexportable=exportable=Func|Memory|Table|Tag|Globaltype'infodatamode=Passive|Activeofidx*'infoexprtype'infoelemmode=Passive|Activeofidx*'infoexpr|Declaretypeimportdesc=|Funcof{exact:bool;typ:typeuse}|Memoryoflimits|Tableoftabletype|Globalofglobaltype|Tagoftypeusetypeimport={module_:string;name:string;desc:importdesc}(* compact-import-section proposal: one import-section entry, either a plain
import or a same-module group ([Group1] = a type per item, [Group2] = one
shared type). The decoder keeps these instead of flattening and the encoder
emits them directly, so the compact form survives a binary round-trip. *)typeimport_entry=|Singleofimport|Group1of{module_:string;items:(string*importdesc)list}|Group2of{module_:string;desc:importdesc;names:stringlist}type'infotable={typ:tabletype;expr:'infoexproption}type'infomemory={limits:limits;init:stringoption;exports:stringlist;}typetag={typ:typeuse;exports:stringlist}type'infoglobal={typ:globaltype;init:'infoexpr}typeexport={name:string;kind:exportable;index:idx}type'infoelem={typ:reftype;init:'infoexprlist;mode:'infoelemmode;}type'infocode={locals:valtypelist;instrs:'infoinstrlist;loc:location;(* The defining function's source span; its [loc_end] is where the body's
terminating [end] opcode is mapped (closing brace). [dummy_loc] for a
function decoded from a binary, which carries no source location. *)}type'infodata={init:string;mode:'infodatamode}moduleIntMap=Map.Make(Int)typename_map=stringIntMap.ttypeindirect_name_map=stringIntMap.tIntMap.ttypenames={module_:stringoption;functions:name_map;locals:indirect_name_map;labels:indirect_name_map;types:name_map;fields:indirect_name_map;tags:name_map;globals:name_map;tables:name_map;memories:name_map;data:name_map;elem:name_map;}type'infomodule_={types:rectypelist;imports:import_entrylist;functions:idxlist;tables:'infotablelist;memories:limitslist;tags:idxlist;globals:'infogloballist;exports:exportlist;start:idxoption;elem:'infoelemlist;code:'infocodelist;data:'infodatalist;names:names;(* The [target_features] custom section (tool-conventions): one entry per
feature, a one-byte prefix (['+'] used/required, ['-'] disallowed) and
an opaque name. Third-party entries are preserved verbatim; our own
declarations use the [Wax_utils.Feature.name] spelling with ['+']. *)target_features:(char*string)list;}end