12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172type('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_loc(* An instruction record shares the [desc]/[info] field names with [annotated];
inside [Make_instructions] it is declared later and so wins field
disambiguation wherever the receiver's type is not already known. Read a
*generic* node's fields through this alias to say which record is meant:
[x.desc]. *)moduleAnnot=Wax_utils.AstmoduleUint32=Wax_utils.Uint32moduleUint64=Wax_utils.Uint64(* Types *)typepackedtype=I8|I16(* The alias payload of a representation without value-type aliases (the
binary format, the resolved type store): it has no value, so the [Alias] arm
of such a [valtype] can never be built and needs no case. *)typeno_alias=|type'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=sigtypeidxtypealiastype'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|Refofreftype|Aliasofaliastypefunctype={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:sigtypeidxtypealiastype'aannotated_arraytype'aopt_annotated_arrayend):TYPESwithtypeidx=X.idxandtypealias=X.aliasandtype'aannotated_array='aX.annotated_arrayandtype'aopt_annotated_array='aX.opt_annotated_array=structtypeidx=X.idxtypealias=X.aliastypenonrec'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|Refofreftype|Aliasofaliastypefunctype={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. A value-type alias is mapped by [M.alias] to a whole value type, kept
as an alias or expanded to its definition; [M.alias] is passed the value-type
mapper, to map a definition with. *)moduleMap_types_spine(Src:TYPES)(Dst:TYPES)(M:sigtypectxvalidx:ctx->Src.idx->Dst.idxvalalias:ctx->(Src.valtype->Dst.valtype)->Src.alias->Dst.valtypeend)=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}letrecvaltypectx(v:Src.valtype):Dst.valtype=matchvwith|I32->I32|I64->I64|F32->F32|F64->F64|V128->V128|Refr->Ref(reftypectxr)|Aliasa->M.aliasctx(valtypectx)aletstoragetypectx(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.idxvalalias:ctx->(Src.valtype->Dst.valtype)->Src.alias->Dst.valtypevalparams: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.idxletalias=M.aliasend)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|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;}(* [hints] carries the advisory [metadata.code.*] metadata (branch-hinting and
compilation-hints proposals) of this instruction. It is a field rather than a
wrapper node so that the matches on [desc] — which is nearly every match on
an instruction — neither see it nor have to see through it. *)and'infoinstr={desc:'infoinstr_desc;info:'info;hints:X.idxHints.t;}(* A synthesized instruction: no source location, no hints. The instruction
counterpart of [Ast.no_loc], which builds an [annotated] and so cannot serve
a record that carries hints as well. *)letno_locdesc={desc;info=dummy_loc;hints=Hints.none}type'infoexpr='infoinstrlistend(* Modules *)typeexportable=Func|Memory|Table|Tag|GlobalmoduleText=structtypename=(string,location)annotatedtypeidx_desc=NumofUint32.t|Idofstringtypeidx=(idx_desc,location)annotatedmoduleX=structtypenonrecidx=idxtypealias=nametype'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;}(* The shared-type form is strictly name-only ([(item "n")]): its items
cannot bind an identifier, so a group whose items need ids is written (and
lifted from binary) as [Import_group1]; the binary encoder may still emit
such a group with the shared-type encoding when the types agree. *)|Import_group2of{module_:name;desc:importdesc;items:namelist}|Funcof{id:nameoption;typ:typeuse;locals:(nameoption*valtype,location)annotatedlist;instrs:'infoinstrlist;exports:namelist;(* compilation-hints proposal: the function's
[metadata.code.compilation_priority] entry, the one hint of that family
that is per-function rather than per-instruction. *)priority:Hints.priorityoption;}|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(* A value-type alias [(@type $id t)]: [(@type $id)] then stands for the
value type [t] wherever one is expected. It defines no type index; the
binary encoder expands every use. *)|Type_aliasof{id:name;typ:valtype}|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=idxtypealias=no_aliastype'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. *)priority:Hints.priorityoption;(* compilation-hints proposal: this function's
[metadata.code.compilation_priority] entry. *)}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