README

marianoguerra/wax/wasm/wat does not have a README file

#
WatError

pub suberror WatError {
NotPrinted(String)
}

impl Show for WatError

#
BlockKind

pub(all) enum BlockKind {
KBox
KHov
KHv
}

How a Block packs its elements.

#
Node

One folded instruction: a head, the operands folded under it, and -- for the structural instructions -- the bodies they enclose, each folded too.

Operands and bodies are different things: an operand is a value the instruction consumes and a body is code it guards. They are one node here because the text format writes both inside the same parentheses.

#
Sexp

pub(all) enum Sexp {
Atom(String)
List(Array[Sexp])
Block(Array[Sexp], BlockKind, Bool)
VBlock(Array[Sexp])
SBlock(Array[Structure])
At(
Location
, Sexp)
}

A layout node.

#
Structure

pub(all) enum Structure {
Delimiter(Sexp)
Contents(Array[Sexp])
}

#
block

fn block(l : Array[Sexp]) -> Sexp

A plain block: elements packed, breaking all together.

#
fold

Fold a lowered body, given the spans recorded while lowering it.

A span is one node's whole run, and it always follows its children's -- so the widest span at a position is the node there, and the last instruction in it is the head.

The NESTED lists arrive in completion order: deepest first, then left to right, with each enclosing body after the bodies inside it. Taking them from the BACK while walking each body's structural instructions right to left visits them in exactly that order reversed, which is how each body finds its own.

#
heaptype

fn heaptype(h :
HeapType
[Int], names : Map[Int, Bytes]) -> String

A heap type.

#
ident

fn ident(b : Bytes) -> String

An identifier as the format spells one: $x when every character may appear in a bare identifier, and the quoted $"..." form otherwise -- which is the only way to write a name that is empty or holds a space.

#
mnemonic

fn mnemonic(i :
Instruction
, names :
Names
, locals : Map[Int, Bytes], scope? : Array[String?]) -> Sexp raise WatError

The mnemonic and immediates of one instruction, without its operands.

#
nullary

The text name of an instruction with no immediate, or None when it takes one and so belongs in the table that knows its shape.

Print a module's text form.

#
reftype

fn reftype(r :
RefType
[Int], names : Map[Int, Bytes]) -> String

A reference type. The nullable abstract ones have one-word spellings -- funcref rather than (ref null func) -- and the format prefers them.

#
render

fn render(s : Sexp, top_depth? : Int, trivia? :
Context
?) -> String

Lay out a document at the width the reference uses.

TWO PASSES, as the Wax printer does and for the same reason: the first records which spans the layout will actually look up, and associate then attaches comments to exactly those. Attaching first would let a comment land on a node this printer never reaches, and vanish.

#
valtype

fn valtype(v :
ValType
[Int], names : Map[Int, Bytes]) -> String

A value type, as the text format spells it.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io