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.
- Body
Source Map - Maps every
ExprIdback 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. - Local
Var - A local
var/constdeclaration. - Match
Arm - One
matcharm. - Match
Bind - One
var xcapture in amatchpattern — a local binding (so navigation can find/rename it). - Param
Binding - 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
ptrfromrootand lower its body. - body_
of_ decl_ stmt - Lower a class-level
VarDecl/ConstDeclnode into aBodyholding one local-var statement — socrate::inferruns 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-levelvar/constinitializer). - body_
of_ func - Lower a
FuncDeclnode into aBody.
Type Aliases§
- Block
- A lowered block: its statements, in order.