Module Wax_wasm.AstSource

WebAssembly Abstract Syntax Tree.

Sourcetype ('desc, 'info) annotated = ('desc, 'info) Wax_utils.Ast.annotated = {
  1. desc : 'desc;
  2. info : 'info;
}

An annotated tree node.

Sourcetype location = Wax_utils.Ast.location = {
  1. loc_start : Lexing.position;
  2. loc_end : Lexing.position;
}

A source code location.

Sourceval no_loc : 'desc -> ('desc, location) annotated

no_loc d creates an annotated node with a dummy location.

Sourceval dummy_loc : location

A location with dummy start/end positions, for synthesized nodes.

Sourcemodule Uint32 = Wax_utils.Uint32
Sourcemodule Uint64 = Wax_utils.Uint64
Sourcetype packedtype =
  1. | I8
  2. | I16
Sourcetype 'typ muttype = {
  1. mut : bool;
  2. typ : 'typ;
}
Sourcetype limits = {
  1. mi : Uint64.t;
  2. ma : Uint64.t option;
  3. address_type : [ `I32 | `I64 ];
  4. page_size_log2 : int option;
  5. shared : bool;
}
Sourcemodule type TYPES = sig ... end

The set of types produced by Make_types, abstracted over the index and array-wrapper representations. Naming it lets Map_types map the whole family from one instance to another.

Sourcemodule Make_types (X : sig ... end) : TYPES with type idx = X.idx and type 'a annotated_array = 'a X.annotated_array and type 'a opt_annotated_array = 'a X.opt_annotated_array
Sourcemodule Map_types_spine (Src : TYPES) (Dst : TYPES) (M : sig ... end) : sig ... end

Map the heaptype/reftype/valtype/storagetype/fieldtype family from one Make_types instance to another. Only the idx-carrying arms differ between instances; everything else 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, …).

Sourcemodule Map_types (Src : TYPES) (Dst : TYPES) (M : sig ... end) : sig ... 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; the functype/comptype/subtype/rectype structure is copied through.

Sourcetype signage =
  1. | Signed
  2. | Unsigned
Sourcetype 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 [ `_8 | `_16 | `_32 ]
Sourcetype 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 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 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 num_type =
  1. | NumI32
  2. | NumI64
  3. | NumF32
  4. | NumF64
Sourcetype vec_shape =
  1. | I8x16
  2. | I16x8
  3. | I32x4
  4. | I64x2
  5. | F32x4
  6. | F64x2
Sourcetype 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 [ `Low | `High ] * [ `_8 | `_16 | `_32 ] * 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 * [ `I8 | `I16 ]
  16. | VecRelaxedTrunc of signage
  17. | VecRelaxedTruncZero of signage
Sourcetype 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 [ `I8 | `I16 ]
  10. | VecQ15MulrSat
  11. | VecAddSat of signage * [ `I8 | `I16 ]
  12. | VecSubSat of signage * [ `I8 | `I16 ]
  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 * [ `I8 | `I16 ]
  25. | VecSwizzle
  26. | VecExtMulLow of signage * [ `_8 | `_16 | `_32 ]
  27. | VecExtMulHigh of signage * [ `_8 | `_16 | `_32 ]
  28. | VecRelaxedSwizzle
  29. | VecRelaxedMin of vec_shape
  30. | VecRelaxedMax of vec_shape
  31. | VecRelaxedQ15Mulr
  32. | VecRelaxedDot
Sourcetype vec_test_op =
  1. | AnyTrue
  2. | AllTrue of vec_shape
Sourcetype vec_shift_op =
  1. | Shl of vec_shape
  2. | Shr of signage * vec_shape
Sourcetype vec_bitmask_op =
  1. | Bitmask of vec_shape
Sourcetype vec_tern_op =
  1. | VecRelaxedMAdd of [ `F32 | `F64 ]
  2. | VecRelaxedNMAdd of [ `F32 | `F64 ]
  3. | VecRelaxedLaneSelect of vec_shape
  4. | VecRelaxedDotAdd
Sourcetype vec_load_op =
  1. | Load128
  2. | Load8x8S
  3. | Load8x8U
  4. | Load16x4S
  5. | Load16x4U
  6. | Load32x2S
  7. | Load32x2U
  8. | Load32Zero
  9. | Load64Zero
Sourcetype atomic_rmwop =
  1. | AtomicAdd
  2. | AtomicSub
  3. | AtomicAnd
  4. | AtomicOr
  5. | AtomicXor
  6. | AtomicXchg
  7. | AtomicCmpxchg
Sourcetype atomicop =
  1. | AtomicNotify
  2. | AtomicWait of [ `I32 | `I64 ]
  3. | AtomicLoad of [ `I32 | `I64 ] * [ `I8 | `I16 | `I32 ] option
  4. | AtomicStore of [ `I32 | `I64 ] * [ `I8 | `I16 | `I32 ] option
  5. | AtomicRmw of atomic_rmwop * [ `I32 | `I64 ] * [ `I8 | `I16 | `I32 ] option
Sourcetype ('i32, 'i64, 'f32, 'f64) op =
  1. | I32 of 'i32
  2. | I64 of 'i64
  3. | F32 of 'f32
  4. | F64 of 'f64
Sourcetype memarg = {
  1. offset : Uint64.t;
  2. align : Uint64.t;
}
Sourcetype cmp_op =
  1. | Eq
  2. | Ne
  3. | Lt
  4. | Gt
  5. | Le
  6. | Ge
Sourcetype cond =
  1. | Cond_var of (string, location) annotated
  2. | Cond_string of (string, location) annotated
  3. | Cond_version of int * int * int
  4. | Cond_and of cond list
  5. | Cond_or of cond list
  6. | Cond_not of cond
  7. | Cond_cmp of cmp_op * cond * cond
Sourcemodule Make_instructions (X : sig ... end) : sig ... end

Functor to create instructions for a given implementation of indices and types.

Sourcetype exportable =
  1. | Func
  2. | Memory
  3. | Table
  4. | Tag
  5. | Global
Sourcemodule Text : sig ... end

Wasm Text format specific AST.

Sourcemodule Binary : sig ... end

Wasm Binary format specific AST.