Skip to main content

Module body

Module body 

Source
Expand description

Body lowering (Playbook §3.1/§3.4): a function body (or a class-level initializer expression) lowered from the CST into a flat arena of Expr/Stmt addressed by ExprId/StmtId, plus a BodySourceMap mapping every ExprId back to its byte range. Every IDE feature (hover, inlay, completion) maps a cursor offset → ExprId through this source map, then reads the inferred type from crate::infer.

Lowering is a pure function of the CST: no engine API, no name resolution, no types. Type annotations (is/as/var/param/for) are kept as AstPtrs to their TypeRef nodes and resolved later, so this stage never depends on the model.

Structs§

Body
A lowered function body, or a single class-level initializer expression.
BodySourceMap
Maps every ExprId back to its source byte range. The reverse direction (offset → ExprId) is the tightest containing expression.
ExprId
An index into Body::exprs.
ForLoop
A for var [: T] in iter: loop.
LocalVar
A local var / const declaration.
MatchArm
One match arm.
MatchBind
One var x capture in a match pattern — a local binding (so navigation can find/rename it).
ParamBinding
A function / lambda parameter binding.
StmtId
An index into Body::stmts.

Enums§

BinOp
A binary operator.
Expr
A lowered expression. Children are referenced by ExprId.
Literal
A literal’s kind (the value text lives in the CST; only the kind drives typing).
Stmt
A lowered statement.
UnOp
A prefix unary operator.

Functions§

body
Recover the function node for ptr from root and lower its body.
body_of_decl_stmt
Lower a class-level VarDecl/ConstDecl node into a Body holding one local-var statement — so crate::infer runs the full annotation/inference checks (and records the member’s binding type) on a class field the same way it does for a local.
body_of_expr
Lower a single expression node into a Body (a class-level var/const initializer).
body_of_func
Lower a FuncDecl node into a Body.

Type Aliases§

Block
A lowered block: its statements, in order.