Wax_lang.Ast_utilsSourcemap_instr f instr applies the function f to the info field of instr and recursively applies it to all nested instructions.
sub_instrs i is the instructions immediately nested within i (its operands and block bodies), in no particular order.
iter_instr f i applies f to i and, recursively, to every instruction nested within it. Unlike map_instr, f receives the whole node (so it can inspect the desc), not just the info field.
val lower_dispatch :
block_info:'info ->
index:'info Ast.instr ->
cases:Ast.label list ->
default:Ast.label ->
arms:(Ast.label * ('info Ast.instr list, Ast.location) Ast.annotated) list ->
'info Ast.instr listlower_dispatch desugars a dispatch to its nested-block-around-a-br_table form: a list of the outermost case block followed by the first arm's trailing body (see the implementation). It is the inverse of Recover_dispatch and is used by both type checking and Wax-to-Wasm conversion.
Placeholder loop label used only in the discarded type-check lowering (the name never reaches emitted Wat; see lower_while and To_wasm).
val lower_while :
block_info:'info ->
fresh_loop:Ast.label ->
label:Ast.label option ->
cond:'info Ast.instr ->
step:'info Ast.instr option ->
block:'info Ast.instr list ->
'info Ast.instr listlower_while desugars a leading-test while C { B } to 'L: loop { if C { B; br 'L; } }. A continue-expression step runs at the end of every iteration: an unlabelled loop appends it to the body; a labelled loop wraps the body in a block (the continue target) so a continue runs the step before the fresh_loop back-edge. Inverse of the while case of Recover_loops; used by both type checking and Wax-to-Wasm conversion.
val lower_match :
block_info:'info ->
labels:Ast.label list ->
scrutinee:'info Ast.instr ->
arms:
(Ast.match_pattern * ('info Ast.instr list, Ast.location) Ast.annotated)
list ->
default:('info Ast.instr list, Ast.location) Ast.annotated ->
'info Ast.instr listlower_match desugars a match to a nested type-test ladder: the scrutinee is evaluated once and threaded through a br_on_cast/br_on_null chain in the innermost block, each test branching out to its arm's block (carrying the narrowed value), with the arm body just after that block and an outer void escape block past all the bodies. labels supplies n+1 fresh block labels — one per arm in order, then the escape label. It is the inverse of Recover_match and is used by both type checking and Wax-to-Wasm conversion.
val lower_trycatch :
block_info:'info ->
join:Ast.label ->
arm_labels:Ast.label list ->
typ:Ast.functype ->
block:('info Ast.instr list, Ast.location) Ast.annotated ->
arms:'info Ast.trycatch_arm list ->
'info Ast.instrlower_trycatch desugars a structured try to try_table plus a block ladder: one block per arm (the first innermost, its result type the arm's entry stack) inside the join block, the try_table innermost with one catch clause per arm, arm bodies as trailing code (fall-through order), and the body's completion escaping with a br to join carrying the try's value. arm_labels supplies one fresh label per arm; join is the try's own label when it has one. It is the exact inverse of Recover_trycatch and is used by Wax-to-Wasm conversion.
map_modulefield f modulefield applies the function f to the info field of instructions within modulefield and returns a new modulefield.
val iter_fields :
(('info Ast.modulefield, Ast.location) Ast.annotated -> unit) ->
'info Ast.module_ ->
unititer_module_instr f m applies f to every instruction in m — each field's operands and bodies, and everything nested within them (including through conditionals).
binop_kind op is the precedence class of op.
confusing_precedence outer inner is whether a binary operator of kind outer whose operand is a binary operator of kind inner is a precedence footgun — a shift mixed with arithmetic, or a comparison mixed with a bitwise operator. Symmetric.
import_name decl is the name decl is imported under: its import_as override if present, else the Wax name decl.id.