Module Wax_lang.AstSource

Wax Abstract Syntax Tree.

Sourcetype ('desc, 'info) annotated = ('desc, 'info) Wax_utils.Ast.annotated = {
  1. desc : 'desc;
  2. info : 'info;
}
Sourcetype location = Wax_utils.Ast.location = {
  1. loc_start : Lexing.position;
  2. loc_end : Lexing.position;
}
Sourceval no_loc : 'desc -> ('desc, location) annotated
Sourcetype ident = (string, location) annotated

An identifier with its source location.

include sig ... end
Sourcetype idx = ident
Sourcetype 'a annotated_array = (ident * 'a, location) annotated array
Sourcetype 'a opt_annotated_array = (ident option * 'a, location) annotated array
Sourcetype 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 = {
  1. nullable : bool;
  2. typ : heaptype;
}
Sourcetype valtype =
  1. | I32
  2. | I64
  3. | F32
  4. | F64
  5. | V128
  6. | Ref of reftype
Sourcetype functype = {
  1. params : valtype opt_annotated_array;
  2. results : valtype array;
}
Sourcetype nonrec packedtype =
  1. | I8
  2. | I16
Sourcetype storagetype =
  1. | Value of valtype
  2. | Packed of packedtype
Sourcetype nonrec !'typ muttype = {
  1. mut : bool;
  2. typ : 'typ;
}
Sourcetype fieldtype = storagetype muttype
Sourcetype comptype =
  1. | Func of functype
  2. | Struct of fieldtype annotated_array
  3. | Array of fieldtype
  4. | Cont of idx
Sourcetype subtype = {
  1. typ : comptype;
  2. supertype : idx option;
  3. final : bool;
  4. descriptor : idx option;
  5. describes : idx option;
}
Sourcetype nonrec limits = {
  1. mi : Wax_utils.Uint64.t;
  2. ma : Wax_utils.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
Sourceval splice_field_name : string

The reserved field name marking a .. splice at the head of a struct definition (inherits the supertype's fields). Not a valid identifier, so it never collides with a real field.

Sourceval is_splice_field : (ident * fieldtype, location) annotated -> bool

Whether a struct field is the .. splice sentinel.

Sourceval splice_field : location -> (ident * fieldtype, location) annotated

Build a .. splice sentinel field at the given location.

Sourcetype signage = Wax_wasm.Ast.signage =
  1. | Signed
  2. | Unsigned

Signage for integer operations.

Sourcetype unop =
  1. | Neg
  2. | Pos
  3. | Not

Unary operators.

Sourcetype binop =
  1. | Add
  2. | Sub
  3. | Mul
  4. | Div of signage option
  5. | Rem of signage
  6. | And
  7. | Or
  8. | Xor
  9. | Shl
  10. | Shr of signage
  11. | Eq
  12. | Ne
  13. | Lt of signage option
  14. | Gt of signage option
  15. | Le of signage option
  16. | Ge of signage option

Binary operators.

Sourcetype label = ident
Sourcetype casttype =
  1. | Valtype of valtype
  2. | Functype of {
    1. nullable : bool;
    2. sign : functype;
    }
  3. | Signedtype of {
    1. typ : [ `I32 | `I64 | `F32 | `F64 ];
    2. signage : signage;
    3. strict : bool;
    }
Sourceval format_signed_type : [ `F32 | `F64 | `I32 | `I64 ] -> signage -> bool -> string

Helper to format signed types (e.g., "i32_s_strict").

Sourcetype catch =
  1. | Catch of ident * label
  2. | CatchRef of ident * label
  3. | CatchAll of label
  4. | CatchAllRef of label
Sourcetype on_clause =
  1. | OnLabel of ident * label
  2. | OnSwitch of ident
Sourcetype match_pattern =
  1. | MatchCast of ident option * reftype
  2. | MatchNull

A match arm pattern: a (optionally bound) reference-type test, or a null test. See the Match node and Ast_utils.lower_match.

Sourcetype 'info instr_desc =
  1. | Block of {
    1. label : label option;
    2. typ : functype;
    3. block : ('info instr list, location) annotated;
    }
  2. | Loop of {
    1. label : label option;
    2. typ : functype;
    3. block : ('info instr list, location) annotated;
    }
  3. | While of {
    1. label : label option;
    2. cond : 'info instr;
    3. step : 'info instr option;
    4. block : ('info instr list, location) annotated;
    }
  4. | If of {
    1. label : label option;
    2. typ : functype;
    3. cond : 'info instr;
    4. if_block : ('info instr list, location) annotated;
    5. else_block : ('info instr list, location) annotated option;
    }
  5. | TryTable of {
    1. label : label option;
    2. typ : functype;
    3. catches : catch list;
    4. block : ('info instr list, location) annotated;
    }
  6. | Try of {
    1. label : label option;
    2. typ : functype;
    3. block : ('info instr list, location) annotated;
    4. catches : (ident * ('info instr list, location) annotated) list;
    5. catch_all : ('info instr list, location) annotated option;
    }
    (*

    The deprecated legacy exception handler (try_legacy), compiling to the legacy try/catch instructions.

    *)
  7. | TryCatch of {
    1. label : label option;
    2. typ : functype;
    3. block : ('info instr list, location) annotated;
    4. arms : 'info trycatch_arm list;
    }
    (*

    The structured try { … } catch { tag => { … } … }, lowering to try_table plus a block ladder. Arms are honest trailing code in clause order: an arm's completion falls into the next arm, the last arm's into the join; the body's completion escapes past all arms. The label (the join) is a block-like exit carrying the result.

    *)
  8. | Unreachable
  9. | Nop
  10. | Hole
  11. | Null
  12. | Get of ident
  13. | Path of ident * ident
  14. | Set of ident * (binop, location) annotated option * 'info instr
  15. | Tee of ident * 'info instr
  16. | Call of 'info instr * 'info instr list
  17. | TailCall of 'info instr * 'info instr list
  18. | Labelled of ident * 'info instr
  19. | Char of Uchar.t
  20. | String of ident option * string
  21. | Int of string
  22. | Float of string
  23. | Cast of 'info instr * casttype
  24. | CastDesc of 'info instr * bool * 'info instr
  25. | Test of 'info instr * reftype
  26. | NonNull of 'info instr
  27. | Struct of ident option * (ident * 'info instr option) list
  28. | StructDefault of ident option
  29. | StructDesc of 'info instr * (ident * 'info instr option) list
  30. | StructDefaultDesc of 'info instr
  31. | StructGet of 'info instr * ident
  32. | GetDescriptor of 'info instr
  33. | StructSet of 'info instr * ident * 'info instr
  34. | Array of ident option * 'info instr * 'info instr
  35. | ArrayDefault of ident option * 'info instr
  36. | ArrayFixed of ident option * 'info instr list
  37. | ArraySegment of ident option * ident * 'info instr * 'info instr
  38. | ArrayGet of 'info instr * 'info instr
  39. | ArraySet of 'info instr * 'info instr * 'info instr
  40. | BinOp of (binop, location) annotated * 'info instr * 'info instr
  41. | UnOp of (unop, location) annotated * 'info instr
  42. | Let of (ident option * valtype option) list * 'info instr option
  43. | Br of label * 'info instr option
  44. | Br_if of label * 'info instr
  45. | Br_table of label list * 'info instr
  46. | Dispatch of {
    1. index : 'info instr;
    2. cases : label list;
    3. default : label;
    4. arms : (label * ('info instr list, location) annotated) list;
    }
  47. | Match of {
    1. scrutinee : 'info instr;
    2. arms : (match_pattern * ('info instr list, location) annotated) list;
    3. default : ('info instr list, location) annotated;
    }
  48. | Br_on_null of label * 'info instr
  49. | Br_on_non_null of label * 'info instr
  50. | Br_on_cast of label * reftype * 'info instr
  51. | Br_on_cast_fail of label * reftype * 'info instr
  52. | Br_on_cast_desc_eq of label * bool * 'info instr * 'info instr
  53. | Br_on_cast_desc_eq_fail of label * bool * 'info instr * 'info instr
  54. | Hinted of bool * 'info instr
  55. | Throw of ident * 'info instr list
  56. | ThrowRef of 'info instr
  57. | ContNew of ident * 'info instr
  58. | ContBind of ident * ident * 'info instr list
  59. | Suspend of ident * 'info instr list
  60. | Resume of ident * on_clause list * 'info instr list
  61. | ResumeThrow of ident * ident * on_clause list * 'info instr list
  62. | ResumeThrowRef of ident * on_clause list * 'info instr list
  63. | Switch of ident * ident * 'info instr list
  64. | On of 'info instr * on_clause list
    (*

    The postfix handler clause e on [t -> 'l, ...] as parsed; the typer folds it into the Resume/ResumeThrow/ResumeThrowRef it wraps.

    *)
  65. | Return of 'info instr option
  66. | Sequence of 'info instr list
  67. | Select of 'info instr * 'info instr * 'info instr
  68. | If_annotation of {
    1. cond : Wax_wasm.Ast.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
Sourceand 'info trycatch_arm = {
  1. arm_tag : ident option;
    (*

    None for the trailing catch-all

    *)
  2. arm_ref : bool;
    (*

    & arm: the &exn is delivered above the payload

    *)
  3. arm_types : valtype array;
    (*

    the arm's entry stack — the tag's payload, plus the &exn for a & arm: [||] as parsed, filled by the typer for To_wasm's re-lowering

    *)
  4. arm_body : ('info instr list, location) annotated;
}
Sourcetype attributes = (string * location instr option * (Wax_wasm.Ast.cond, location) annotated option) list
Sourcetype import_kind =
  1. | Import_func of {
    1. typ : ident option;
    2. sign : functype option;
    3. exact : bool;
    }
  2. | Import_global of {
    1. mut : bool;
    2. typ : valtype;
    }
  3. | Import_tag of {
    1. typ : ident option;
    2. sign : functype option;
    }
  4. | Import_memory of {
    1. address_type : [ `I32 | `I64 ];
    2. limits : (Wax_utils.Uint64.t * Wax_utils.Uint64.t option) option;
    3. page_size_log2 : int option;
    4. shared : bool;
    }
  5. | Import_table of {
    1. address_type : [ `I32 | `I64 ];
    2. reftype : reftype;
    3. limits : (Wax_utils.Uint64.t * Wax_utils.Uint64.t option) option;
    }
Sourcetype import_decl = {
  1. id : ident;
  2. kind : import_kind;
  3. attributes : attributes;
}
Sourcetype data_elem =
  1. | Data_string of string
  2. | Data_run of storagetype * (string, location) annotated list
  3. | Data_v128 of (Wax_utils.V128.t, location) annotated list
Sourcetype 'info memdata = {
  1. data_name : ident option;
  2. offset : 'info instr;
  3. init : data_elem list;
}
Sourcetype 'info datamode =
  1. | Passive
  2. | Active of ident * 'info instr
Sourcetype 'info elemmode =
  1. | EPassive
  2. | EActive of ident * 'info instr
Sourcetype 'info modulefield =
  1. | Type of rectype
  2. | Func of {
    1. name : ident;
    2. typ : ident option;
    3. sign : functype option;
    4. body : label option * 'info instr list;
    5. attributes : attributes;
    }
  3. | Global of {
    1. name : ident;
    2. mut : bool;
    3. typ : valtype option;
    4. def : 'info instr;
    5. attributes : attributes;
    }
  4. | Tag of {
    1. name : ident;
    2. typ : ident option;
    3. sign : functype option;
    4. attributes : attributes;
    }
  5. | Memory of {
    1. name : ident;
    2. address_type : [ `I32 | `I64 ];
    3. limits : (Wax_utils.Uint64.t * Wax_utils.Uint64.t option) option;
    4. page_size_log2 : int option;
    5. shared : bool;
    6. data : 'info memdata list;
    7. attributes : attributes;
    }
  6. | Data of {
    1. name : ident option;
    2. mode : 'info datamode;
    3. init : data_elem list;
    4. attributes : attributes;
    }
  7. | Table of {
    1. name : ident;
    2. address_type : [ `I32 | `I64 ];
    3. reftype : reftype;
    4. limits : (Wax_utils.Uint64.t * Wax_utils.Uint64.t option) option;
    5. init : 'info instr option;
    6. attributes : attributes;
    }
  8. | Elem of {
    1. name : ident;
    2. reftype : reftype;
    3. mode : 'info elemmode;
    4. init : 'info instr list;
    5. attributes : attributes;
    }
  9. | Import of {
    1. module_ : (string, location) annotated;
    2. decl : (import_decl, location) annotated;
    }
  10. | Import_group of {
    1. module_ : (string, location) annotated;
    2. decls : (import_decl, location) annotated list;
    }
  11. | Module_annotation of attributes
  12. | Conditional of {
    1. cond : Wax_wasm.Ast.cond;
    2. then_fields : (('info modulefield, location) annotated list, location) annotated;
    3. else_fields : (('info modulefield, location) annotated list, location) annotated option;
    }
Sourcetype 'info module_ = ('info modulefield, location) annotated list