Module Ast.BinarySource

Sourcetype idx = int
Sourcemodule X : sig ... end
Sourcemodule Types : sig ... end
include sig ... end
Sourcetype 'a annotated_array = 'a X.annotated_array
Sourcetype 'a opt_annotated_array = 'a X.opt_annotated_array
Sourcetype heaptype = Make_types(X).heaptype =
  1. | Func
  2. | NoFunc
  3. | Exn
  4. | NoExn
  5. | Cont
  6. | NoCont
  7. | Extern
  8. | NoExtern
  9. | Any
  10. | Eq
  11. | I31
  12. | Struct
  13. | Array
  14. | None_
  15. | Type of idx
  16. | Exact of idx
Sourcetype reftype = Make_types(X).reftype = {
  1. nullable : bool;
  2. typ : heaptype;
}
Sourcetype valtype = Make_types(X).valtype =
  1. | I32
  2. | I64
  3. | F32
  4. | F64
  5. | V128
  6. | Ref of reftype
Sourcetype functype = Make_types(X).functype = {
  1. params : valtype opt_annotated_array;
  2. results : valtype array;
}
Sourcetype nonrec packedtype = packedtype =
  1. | I8
  2. | I16
Sourcetype storagetype = Make_types(X).storagetype =
  1. | Value of valtype
  2. | Packed of packedtype
Sourcetype nonrec !'typ muttype = 'typ muttype = {
  1. mut : bool;
  2. typ : 'typ;
}
Sourcetype fieldtype = storagetype muttype
Sourcetype comptype = Make_types(X).comptype =
  1. | Func of functype
  2. | Struct of fieldtype annotated_array
  3. | Array of fieldtype
  4. | Cont of idx
Sourcetype subtype = Make_types(X).subtype = {
  1. typ : comptype;
  2. supertype : idx option;
  3. final : bool;
  4. descriptor : idx option;
  5. describes : idx option;
}
Sourcetype nonrec limits = limits = {
  1. mi : Uint64.t;
  2. ma : Uint64.t option;
  3. address_type : [ `I32 | `I64 ];
  4. page_size_log2 : int option;
  5. shared : bool;
}
Sourcetype globaltype = valtype muttype
Sourceval heaptype_keyword : heaptype -> string option

The keyword naming a heap type (e.g. Some "func"); None for the Type case, whose index each printer renders in its own way.

Sourcetype typeuse = idx
Sourcetype tabletype = {
  1. limits : limits;
  2. reftype : reftype;
}
include sig ... end
Sourcetype nonrec (!'i32, !'i64, !'f32, !'f64) op = ('i32, 'i64, 'f32, 'f64) op =
  1. | I32 of 'i32
  2. | I64 of 'i64
  3. | F32 of 'f32
  4. | F64 of 'f64
Sourcetype nonrec signage = signage =
  1. | Signed
  2. | Unsigned
Sourcetype nonrec int_un_op = int_un_op =
  1. | Clz
  2. | Ctz
  3. | Popcnt
  4. | Eqz
  5. | Trunc of [ `F32 | `F64 ] * signage
  6. | TruncSat of [ `F32 | `F64 ] * signage
  7. | Reinterpret
  8. | ExtendS of [ `_16 | `_32 | `_8 ]
Sourcetype nonrec int_bin_op = int_bin_op =
  1. | Add
  2. | Sub
  3. | Mul
  4. | Div of signage
  5. | Rem of signage
  6. | And
  7. | Or
  8. | Xor
  9. | Shl
  10. | Shr of signage
  11. | Rotl
  12. | Rotr
  13. | Eq
  14. | Ne
  15. | Lt of signage
  16. | Gt of signage
  17. | Le of signage
  18. | Ge of signage
Sourcetype nonrec float_un_op = float_un_op =
  1. | Neg
  2. | Abs
  3. | Ceil
  4. | Floor
  5. | Trunc
  6. | Nearest
  7. | Sqrt
  8. | Convert of [ `I32 | `I64 ] * signage
  9. | Reinterpret
Sourcetype nonrec float_bin_op = float_bin_op =
  1. | Add
  2. | Sub
  3. | Mul
  4. | Div
  5. | Min
  6. | Max
  7. | CopySign
  8. | Eq
  9. | Ne
  10. | Lt
  11. | Gt
  12. | Le
  13. | Ge
Sourcetype nonrec num_type = num_type =
  1. | NumI32
  2. | NumI64
  3. | NumF32
  4. | NumF64
Sourcetype nonrec vec_shape = vec_shape =
  1. | I8x16
  2. | I16x8
  3. | I32x4
  4. | I64x2
  5. | F32x4
  6. | F64x2
Sourcetype nonrec vec_un_op = vec_un_op =
  1. | VecNeg of vec_shape
  2. | VecAbs of vec_shape
  3. | VecSqrt of [ `F32 | `F64 ]
  4. | VecNot
  5. | VecTruncSat of [ `F32 | `F64 ] * signage
  6. | VecConvert of [ `F32 | `F64 ] * signage
  7. | VecExtend of [ `High | `Low ] * [ `_16 | `_32 | `_8 ] * signage
  8. | VecPromote
  9. | VecDemote
  10. | VecCeil of [ `F32 | `F64 ]
  11. | VecFloor of [ `F32 | `F64 ]
  12. | VecTrunc of [ `F32 | `F64 ]
  13. | VecNearest of [ `F32 | `F64 ]
  14. | VecPopcnt
  15. | VecExtAddPairwise of signage * [ `I16 | `I8 ]
  16. | VecRelaxedTrunc of signage
  17. | VecRelaxedTruncZero of signage
Sourcetype nonrec vec_bin_op = vec_bin_op =
  1. | VecAdd of vec_shape
  2. | VecSub of vec_shape
  3. | VecMul of vec_shape
  4. | VecDiv of [ `F32 | `F64 ]
  5. | VecMin of signage option * vec_shape
  6. | VecMax of signage option * vec_shape
  7. | VecPMin of [ `F32 | `F64 ]
  8. | VecPMax of [ `F32 | `F64 ]
  9. | VecAvgr of [ `I16 | `I8 ]
  10. | VecQ15MulrSat
  11. | VecAddSat of signage * [ `I16 | `I8 ]
  12. | VecSubSat of signage * [ `I16 | `I8 ]
  13. | VecDot
  14. | VecEq of vec_shape
  15. | VecNe of vec_shape
  16. | VecLt of signage option * vec_shape
  17. | VecGt of signage option * vec_shape
  18. | VecLe of signage option * vec_shape
  19. | VecGe of signage option * vec_shape
  20. | VecAnd
  21. | VecOr
  22. | VecXor
  23. | VecAndNot
  24. | VecNarrow of signage * [ `I16 | `I8 ]
  25. | VecSwizzle
  26. | VecExtMulLow of signage * [ `_16 | `_32 | `_8 ]
  27. | VecExtMulHigh of signage * [ `_16 | `_32 | `_8 ]
  28. | VecRelaxedSwizzle
  29. | VecRelaxedMin of vec_shape
  30. | VecRelaxedMax of vec_shape
  31. | VecRelaxedQ15Mulr
  32. | VecRelaxedDot
Sourcetype nonrec vec_test_op = vec_test_op =
  1. | AnyTrue
  2. | AllTrue of vec_shape
Sourcetype nonrec vec_shift_op = vec_shift_op =
  1. | Shl of vec_shape
  2. | Shr of signage * vec_shape
Sourcetype nonrec vec_bitmask_op = vec_bitmask_op =
  1. | Bitmask of vec_shape
Sourcetype nonrec vec_tern_op = vec_tern_op =
  1. | VecRelaxedMAdd of [ `F32 | `F64 ]
  2. | VecRelaxedNMAdd of [ `F32 | `F64 ]
  3. | VecRelaxedLaneSelect of vec_shape
  4. | VecRelaxedDotAdd
Sourcetype nonrec vec_load_op = vec_load_op =
  1. | Load128
  2. | Load8x8S
  3. | Load8x8U
  4. | Load16x4S
  5. | Load16x4U
  6. | Load32x2S
  7. | Load32x2U
  8. | Load32Zero
  9. | Load64Zero
Sourcetype blocktype =
  1. | Typeuse of typeuse
  2. | Valtype of Make_types(X).valtype
Sourcetype nonrec memarg = memarg = {
  1. offset : Uint64.t;
  2. align : Uint64.t;
}
Sourcetype catch =
  1. | Catch of idx * idx
  2. | CatchRef of idx * idx
  3. | CatchAll of idx
  4. | CatchAllRef of idx
Sourcetype on_clause =
  1. | OnLabel of idx * idx
  2. | OnSwitch of idx
Sourcetype !'info instr_desc =
  1. | Block of {
    1. label : unit;
    2. typ : blocktype option;
    3. block : ('info instr list, location) annotated;
    }
  2. | Loop of {
    1. label : unit;
    2. typ : blocktype option;
    3. block : ('info instr list, location) annotated;
    }
  3. | If of {
    1. label : unit;
    2. typ : blocktype option;
    3. if_block : ('info instr list, location) annotated;
    4. else_block : ('info instr list, location) annotated;
    }
  4. | TryTable of {
    1. label : unit;
    2. typ : blocktype option;
    3. catches : catch list;
    4. block : ('info instr list, location) annotated;
    }
  5. | Try of {
    1. label : unit;
    2. typ : blocktype option;
    3. block : ('info instr list, location) annotated;
    4. catches : (idx * ('info instr list, location) annotated) list;
    5. catch_all : ('info instr list, location) annotated option;
    }
  6. | Unreachable
  7. | Nop
  8. | Throw of idx
  9. | ThrowRef
  10. | ContNew of idx
  11. | ContBind of idx * idx
  12. | Suspend of idx
  13. | Resume of idx * on_clause list
  14. | ResumeThrow of idx * idx * on_clause list
  15. | ResumeThrowRef of idx * on_clause list
  16. | Switch of idx * idx
  17. | Br of idx
  18. | Br_if of idx
  19. | Br_table of idx list * idx
  20. | Br_on_null of idx
  21. | Br_on_non_null of idx
  22. | Br_on_cast of idx * Make_types(X).reftype * Make_types(X).reftype
  23. | Br_on_cast_fail of idx * Make_types(X).reftype * Make_types(X).reftype
  24. | Br_on_cast_desc_eq of idx * Make_types(X).reftype * Make_types(X).reftype
  25. | Br_on_cast_desc_eq_fail of idx * Make_types(X).reftype * Make_types(X).reftype
  26. | Hinted of bool * 'info instr
  27. | Return
  28. | Call of idx
  29. | CallRef of idx
  30. | CallIndirect of idx * typeuse
  31. | ReturnCall of idx
  32. | ReturnCallRef of idx
  33. | ReturnCallIndirect of idx * typeuse
  34. | Drop
  35. | Select of Make_types(X).valtype list option
  36. | LocalGet of idx
  37. | LocalSet of idx
  38. | LocalTee of idx
  39. | GlobalGet of idx
  40. | GlobalSet of idx
  41. | Load of idx * memarg * num_type
  42. | LoadS of idx * memarg * [ `I32 | `I64 ] * [ `I16 | `I32 | `I8 ] * signage
  43. | Store of idx * memarg * num_type
  44. | StoreS of idx * memarg * [ `I32 | `I64 ] * [ `I16 | `I32 | `I8 ]
  45. | Atomic of idx * atomicop * memarg
  46. | AtomicFence
  47. | MemorySize of idx
  48. | MemoryGrow of idx
  49. | MemoryFill of idx
  50. | MemoryCopy of idx * idx
  51. | MemoryInit of idx * idx
  52. | DataDrop of idx
  53. | TableGet of idx
  54. | TableSet of idx
  55. | TableSize of idx
  56. | TableGrow of idx
  57. | TableFill of idx
  58. | TableCopy of idx * idx
  59. | TableInit of idx * idx
  60. | ElemDrop of idx
  61. | RefNull of Make_types(X).heaptype
  62. | RefFunc of idx
  63. | RefIsNull
  64. | RefAsNonNull
  65. | RefEq
  66. | RefTest of Make_types(X).reftype
  67. | RefCast of Make_types(X).reftype
  68. | RefCastDescEq of Make_types(X).reftype
  69. | RefGetDesc of idx
  70. | StructNew of idx
  71. | StructNewDefault of idx
  72. | StructNewDesc of idx
  73. | StructNewDefaultDesc of idx
  74. | StructGet of signage option * idx * idx
  75. | StructSet of idx * idx
  76. | ArrayNew of idx
  77. | ArrayNewDefault of idx
  78. | ArrayNewFixed of idx * Uint32.t
  79. | ArrayNewData of idx * idx
  80. | ArrayNewElem of idx * idx
  81. | ArrayGet of signage option * idx
  82. | ArraySet of idx
  83. | ArrayLen
  84. | ArrayFill of idx
  85. | ArrayCopy of idx * idx
  86. | ArrayInitData of idx * idx
  87. | ArrayInitElem of idx * idx
  88. | RefI31
  89. | I31Get of signage
  90. | Const of (Int32.t, Int64.t, Int32.t, float) op
  91. | BinOp of (int_bin_op, int_bin_op, float_bin_op, float_bin_op) op
  92. | UnOp of (int_un_op, int_un_op, float_un_op, float_un_op) op
  93. | Add128
  94. | Sub128
  95. | MulWide of signage
  96. | VecConst of string
  97. | VecUnOp of vec_un_op
  98. | VecBinOp of vec_bin_op
  99. | VecTest of vec_test_op
  100. | VecShift of vec_shift_op
  101. | VecBitmask of vec_bitmask_op
  102. | VecTernOp of vec_tern_op
  103. | VecBitselect
  104. | VecLoad of idx * vec_load_op * memarg
  105. | VecStore of idx * memarg
  106. | VecLoadLane of idx * [ `I16 | `I32 | `I64 | `I8 ] * memarg * int
  107. | VecStoreLane of idx * [ `I16 | `I32 | `I64 | `I8 ] * memarg * int
  108. | VecLoadSplat of idx * [ `I16 | `I32 | `I64 | `I8 ] * memarg
  109. | VecExtract of vec_shape * signage option * int
  110. | VecReplace of vec_shape * int
  111. | VecSplat of vec_shape
  112. | VecShuffle of string
  113. | I32WrapI64
  114. | I64ExtendI32 of signage
  115. | F32DemoteF64
  116. | F64PromoteF32
  117. | ExternConvertAny
  118. | AnyConvertExtern
  119. | Folded of 'info instr * 'info instr list
  120. | String of idx option * (string, location) annotated list
  121. | Char of Uchar.t
  122. | If_annotation of {
    1. cond : cond;
    2. then_body : ('info instr list, location) annotated;
    3. else_body : ('info instr list, location) annotated option;
    }
Sourceand !'info instr = ('info instr_desc, 'info) annotated
Sourcetype !'info expr = 'info instr list

A sequence of instructions.

Sourcetype nonrec exportable = exportable =
  1. | Func
  2. | Memory
  3. | Table
  4. | Tag
  5. | Global
Sourcetype 'info datamode =
  1. | Passive
  2. | Active of idx * 'info expr
Sourcetype 'info elemmode =
  1. | Passive
  2. | Active of idx * 'info expr
  3. | Declare
Sourcetype importdesc =
  1. | Func of {
    1. exact : bool;
    2. typ : typeuse;
    }
  2. | Memory of limits
  3. | Table of tabletype
  4. | Global of globaltype
  5. | Tag of typeuse
Sourcetype import = {
  1. module_ : string;
  2. name : string;
  3. desc : importdesc;
}
Sourcetype import_entry =
  1. | Single of import
  2. | Group1 of {
    1. module_ : string;
    2. items : (string * importdesc) list;
    }
  3. | Group2 of {
    1. module_ : string;
    2. desc : importdesc;
    3. names : string list;
    }
Sourcetype 'info table = {
  1. typ : tabletype;
  2. expr : 'info expr option;
}
Sourcetype 'info memory = {
  1. limits : limits;
  2. init : string option;
  3. exports : string list;
}
Sourcetype tag = {
  1. typ : typeuse;
  2. exports : string list;
}
Sourcetype 'info global = {
  1. typ : globaltype;
  2. init : 'info expr;
}
Sourcetype export = {
  1. name : string;
  2. kind : exportable;
  3. index : idx;
}
Sourcetype 'info elem = {
  1. typ : reftype;
  2. init : 'info expr list;
  3. mode : 'info elemmode;
}
Sourcetype 'info code = {
  1. locals : valtype list;
  2. instrs : 'info instr list;
  3. loc : location;
    (*

    The defining function's source span; its loc_end locates the body's terminating end opcode (closing brace) in a source map. dummy_loc for a function decoded from a binary.

    *)
}
Sourcetype 'info data = {
  1. init : string;
  2. mode : 'info datamode;
}
Sourcemodule IntMap : Map.S with type key = idx
Sourcetype name_map = string IntMap.t
Sourcetype indirect_name_map = string IntMap.t IntMap.t
Sourcetype names = {
  1. module_ : string option;
  2. functions : name_map;
  3. locals : indirect_name_map;
  4. labels : indirect_name_map;
  5. types : name_map;
  6. fields : indirect_name_map;
  7. tags : name_map;
  8. globals : name_map;
  9. tables : name_map;
  10. memories : name_map;
  11. data : name_map;
  12. elem : name_map;
}
Sourcetype 'info module_ = {
  1. types : rectype list;
  2. imports : import_entry list;
  3. functions : idx list;
  4. tables : 'info table list;
  5. memories : limits list;
  6. tags : idx list;
  7. globals : 'info global list;
  8. exports : export list;
  9. start : idx option;
  10. elem : 'info elem list;
  11. code : 'info code list;
  12. data : 'info data list;
  13. names : names;
  14. target_features : (char * string) list;
}

A Wasm module in binary format.