package wax-lib
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=4361e1324b7754a4c08ab5b505df32061f3ce0cea60443fd0d3699e0fa796b32
sha512=fcc756d2f160ba90a9aa1131f2ab22ed7f45466ccd658c21cf9df6868a6aab0cee7f404719d698a379958802f9820398f2fe0685ecc4dda018ca4f653294e39b
doc/wax-lib.wax/Wax_lang/Ast/index.html
Module Wax_lang.AstSource
Wax Abstract Syntax Tree.
type location = Wax_utils.Ast.location = {loc_start : Lexing.position;loc_end : Lexing.position;
}include sig ... end
type nonrec limits = {mi : Wax_utils.Uint64.t;ma : Wax_utils.Uint64.t option;address_type : [ `I32 | `I64 ];page_size_log2 : int option;
}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.
Whether a struct field is the .. splice sentinel.
Build a .. splice sentinel field at the given location.
The located (name, thing) pairs the type family carries: a function parameter (its name optional), a struct field, a rec-group member. Named accessors rather than fst/snd over .desc, because desc on a node whose type is not already known resolves to the instruction record's field of that name (see Annot). Their declared return types also let a chained read — (field_name f).desc — resolve on its own.
Signage for integer operations.
Unary operators.
Binary operators.
type casttype = | Valtype of valtype| Functype of {nullable : bool;sign : functype;
}| Signedtype of {typ : [ `I32 | `I64 | `F32 | `F64 ];signage : signage;strict : bool;
}| Ascribed of valtype(*The parenthesized type ascription
*)(e : t): a static assertion thate's type is a subtype oft, with result typet. Never lowers to an instruction, and — unlike a cast — an ascribed bare hole claims no pending value: it GROUNDS a value of typetoff the polymorphic floor.
Helper to format signed types (e.g., "i32_s_strict").
A match arm pattern: a (optionally bound) reference-type test, or a null test. See the Match node and Ast_utils.lower_match.
type 'info instr_desc = | Block of {}| Loop of {}| While of {label : label option;cond : 'info instr;step : 'info instr option;block : ('info instr list, location) annotated;
}| If of {label : label option;typ : functype;cond : 'info instr;if_block : ('info instr list, location) annotated;else_block : ('info instr list, location) annotated option;
}| TryTable of {label : label option;typ : functype;catches : catch list;block : ('info instr list, location) annotated;
}| Try of {label : label option;typ : functype;block : ('info instr list, location) annotated;catches : (ident * ('info instr list, location) annotated) list;catch_all : ('info instr list, location) annotated option;
}(*The deprecated legacy exception handler (
*)try_legacy), compiling to the legacytry/catchinstructions.| TryCatch of {label : label option;typ : functype;block : ('info instr list, location) annotated;arms : 'info trycatch_arm list;
}(*The structured
*)try { … } catch { tag => { … } … }, lowering totry_tableplus 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.| Unreachable| Nop| Hole| Null| Get of ident| Path of ident * ident| Set of ident * (binop, location) annotated option * 'info instr| Tee of ident * 'info instr| Call of 'info instr * 'info instr list| TailCall of 'info instr * 'info instr list| Labelled of ident * 'info instr| Char of Uchar.t| String of ident option * string| Int of string| Float of string| Cast of 'info instr * casttype| CastDesc of 'info instr * bool * 'info instr| Test of 'info instr * reftype| NonNull of 'info instr| Struct of ident option * (ident * 'info instr option) list| StructDefault of ident option| StructDesc of 'info instr * (ident * 'info instr option) list| StructDefaultDesc of 'info instr| StructGet of 'info instr * ident| GetDescriptor of 'info instr| StructSet of 'info instr * ident * 'info instr| Array of ident option * 'info instr * 'info instr| ArrayDefault of ident option * 'info instr| ArrayFixed of ident option * 'info instr list| ArraySegment of ident option * ident * 'info instr * 'info instr| ArrayGet of 'info instr * 'info instr| ArraySet of 'info instr * 'info instr * 'info instr| BinOp of (binop, location) annotated * 'info instr * 'info instr| UnOp of (unop, location) annotated * 'info instr| Let of (ident option * valtype option) list * 'info instr option| Br of label * 'info instr option| Br_if of label * 'info instr| Br_table of label list * 'info instr| Dispatch of {index : 'info instr;cases : label list;default : label;arms : (label * ('info instr list, location) annotated) list;
}| Match of {scrutinee : 'info instr;arms : (match_pattern * ('info instr list, location) annotated) list;default : ('info instr list, location) annotated;
}| Br_on_null of label * 'info instr| Br_on_non_null of label * 'info instr| Br_on_cast of label * reftype * 'info instr| Br_on_cast_fail of label * reftype * 'info instr| Br_on_cast_desc_eq of label * bool * 'info instr * 'info instr| Br_on_cast_desc_eq_fail of label * bool * 'info instr * 'info instr| Throw of ident * 'info instr list| ThrowRef of 'info instr| ContNew of ident * 'info instr| ContBind of ident * ident * 'info instr list| Suspend of ident * 'info instr list| Resume of ident * on_clause list * 'info instr list| ResumeThrow of ident * ident * on_clause list * 'info instr list| ResumeThrowRef of ident * on_clause list * 'info instr list| Switch of ident * ident * 'info instr list| On of 'info instr * on_clause list(*The postfix handler clause
*)e on [t -> 'l, ...]as parsed; the typer folds it into theResume/ResumeThrow/ResumeThrowRefit wraps.| Return of 'info instr option| Sequence of 'info instr list| Select of 'info instr * 'info instr * 'info instr| If_annotation of {cond : Wax_wasm.Ast.cond;then_body : ('info instr list, location) annotated;else_body : ('info instr list, location) annotated option;
}
and expectation = | Unset(*No producer ever considered this node: the default for parsed source and for nodes synthesized after the Wasm-to-Wax conversion. On a numeric-valued node the conversion emitted, it is a recording GAP — invisible to the width check by construction, so only able to surface as a silent drift;
*)--debug width-recordreports every such node.| Contextual(*A producer considered this node and deliberately made no claim: its width comes from its context rather than its own printed form (
*)Wax_conversion.From_wasm'sforget_expected), or its type is a reference — the one class outside the width channel.| Recorded of valtype(*The type the value this node produces MUST have, known independently of Wax inference: the type stated by the Wasm opcode this node was decompiled from.
*)
and 'info instr = {desc : 'info instr_desc;info : 'info;hints : ident Wax_wasm.Hints.t;(*The advisory
*)metadata.code.*metadata of this instruction (branch-hinting and compilation-hints proposals), written in Wax as an attribute prefixing it (#[likely],#[freq = 16], ...). A field rather than a wrapper node, so that the matches ondesc— which is nearly every match on an instruction — neither see it nor have to see through it.expected : expectation;(*What this node's producer states about the type of the value it produces:
*)Wax_conversion.From_wasmrecords the type stated by the Wasm opcode a node was decompiled from. Nothing in the source language sets it (a parsed module leaves every nodeUnset) and nothing user-visible reads it — unlikehintsit is never printed. The typer's width-check mode (Typing.f's~width_check) compares its own inferred type for the node against aRecordedclaim, so a decompiled expression whose printed form Wax would re-infer at another width — silently changing the opcode on recompile — is reported instead of shipped. Readers asking "does this node state its type?" must treatUnsetandContextualidentically (onlyRecordedinforms); the two exist as distinct states solely so the recording-gap census can tell "never considered" from "deliberately no claim". A field rather than a location-keyed side table, because a synthesized dead-code node carries no real span.
}and 'info trycatch_arm = {arm_tag : ident option;(*
*)Nonefor the trailing catch-allarm_ref : bool;(*
*)&arm: the&exnis delivered above the payloadarm_types : valtype array;(*the arm's entry stack — the tag's payload, plus the
*)&exnfor a&arm:[||]as parsed, filled by the typer forTo_wasm's re-loweringarm_body : ('info instr list, location) annotated;
}type attribute = {attr_name : string;attr_value : location instr option;(*
*)#[export = "f"]carries one,#[start]does not.attr_guard : (Wax_wasm.Ast.cond, location) annotated option;(*A conditional-compilation guard,
*)#[export = "f", if not(portable)], making just this attribute conditional (independent of the field's own reachability). Onlyexportmay be guarded; located at itsif.attr_span : location;(*The whole
*)#[...], so a diagnostic about the attribute names it rather than falling back toattr_value(absent on a valueless attribute) or to the whole field. A synthesized attribute — one the Wasm-to-Wax conversion invents rather than reads — takes the entity's span.
}type import_kind = | Import_func of {}| Import_global of {mut : bool;typ : valtype;
}| Import_tag of {}| Import_memory of {address_type : [ `I32 | `I64 ];limits : (Wax_utils.Uint64.t * Wax_utils.Uint64.t option) option;page_size_log2 : int option;
}| Import_table of {address_type : [ `I32 | `I64 ];reftype : reftype;limits : (Wax_utils.Uint64.t * Wax_utils.Uint64.t option) option;
}
type data_elem = | Data_string of string| Data_run of storagetype * (string, location) annotated list| Data_v128 of (Wax_utils.V128.t, location) annotated list
type 'info modulefield = | Type of rectype| Func of {name : ident;typ : ident option;sign : functype option;body : label option * 'info instr list;attributes : attributes;
}| Global of {name : ident;mut : bool;typ : valtype option;def : 'info instr;attributes : attributes;
}| Tag of {name : ident;typ : ident option;sign : functype option;attributes : attributes;
}| Memory of {name : ident;address_type : [ `I32 | `I64 ];limits : (Wax_utils.Uint64.t * Wax_utils.Uint64.t option) option;page_size_log2 : int option;data : 'info memdata list;attributes : attributes;
}| Data of {name : ident option;mode : 'info datamode;init : data_elem list;attributes : attributes;
}| Table of {name : ident;address_type : [ `I32 | `I64 ];reftype : reftype;limits : (Wax_utils.Uint64.t * Wax_utils.Uint64.t option) option;init : 'info instr option;attributes : attributes;
}| Elem of {name : ident;reftype : reftype;mode : 'info elemmode;init : 'info instr list;attributes : attributes;
}| Import of {module_ : (string, location) annotated;decl : (import_decl, location) annotated;
}| Import_group of {module_ : (string, location) annotated;decls : (import_decl, location) annotated list;
}| Module_annotation of attributes| Conditional of {cond : Wax_wasm.Ast.cond;then_fields : (('info modulefield, location) annotated list, location) annotated;else_fields : (('info modulefield, location) annotated list, location) annotated option;
}