Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ValidateGraph ¶
ValidateGraph is the function form of Graph.Validate.
Types ¶
type BasicBlock ¶
type BasicBlock struct {
Label BlockLabel
Instructions []Instruction
Terminator *Terminator
}
BasicBlock is ordered in Graph.Blocks and contains instructions in source evaluation order.
type BlockLabel ¶
type BlockLabel string
BlockLabel is a stable, human-readable basic block identifier.
type Graph ¶
type Graph struct {
Entry BlockLabel
Blocks []*BasicBlock
}
Graph is a flat SSA control-flow graph for one expression or function body.
func LowerSSA ¶
LowerSSA lowers a checker-annotated shared AST expression into a flat SSA graph. It does not mutate the source tree or affect existing tree-IR users.
func LowerSSAFunction ¶
LowerSSAFunction lowers one function body into its own flat SSA graph, pre-binding each parameter as a resolvable SYMBOL reference via an OpParam instruction in the entry block, so the body's ordinary SYMBOL-lowering path in lower() resolves parameter references exactly like any other name bound by builder.env (e.g. a let binding).
type IRNode ¶
func LowerShared ¶
LowerShared performs the shared arity/shape validation and child extraction for the ~19 node kinds with identical cross-backend semantics. It intentionally does not unify the small number of validation asymmetries already present between the Go and JS backends (e.g. Go type-checks the append/map_set/map_delete target is a SYMBOL and JS does not; JS's binop arity check is absent where Go's exists) — preserving each backend's exact pre-refactor behavior takes priority over cosmetic validation parity, so those extra checks stay in the per-backend emit functions. LowerShared preserves the semantic type annotation produced by the checker. Backends that need native layout information can consume IRNode's Type without walking back to the source node.
type Instruction ¶
type Instruction struct {
Result Value
Op SSAOp
Operands []ValueID
Blocks []BlockLabel
Literal string
Symbol string
}
Instruction defines exactly one SSA value. Blocks is populated for phi instructions and is positionally aligned with Operands.
type Param ¶
Param describes one function parameter for LowerSSAFunction: the name it is referenced by within the function body, and its checker-inferred type.
type SSAOp ¶
type SSAOp string
SSAOp identifies a flat instruction operation.
const ( OpConst SSAOp = "const" OpSymbol SSAOp = "symbol" OpPhi SSAOp = "phi" OpUnit SSAOp = "unit" OpAdd SSAOp = "add" OpSubtract SSAOp = "subtract" OpMultiply SSAOp = "multiply" OpDivide SSAOp = "divide" OpLess SSAOp = "less" OpGreater SSAOp = "greater" OpLessEqual SSAOp = "less_equal" OpGreaterEqual SSAOp = "greater_equal" OpEqual SSAOp = "equal" OpNotEqual SSAOp = "not_equal" OpAnd SSAOp = "and" OpOr SSAOp = "or" OpSet SSAOp = "set" OpCall SSAOp = "call" OpParam SSAOp = "param" OpList SSAOp = "list" OpDict SSAOp = "dict" OpMapGet SSAOp = "map_get" OpListGet SSAOp = "list_get" OpPrint SSAOp = "print" OpToInt SSAOp = "to_int" OpToFloat SSAOp = "to_float" OpToString SSAOp = "to_string" OpBytesToString SSAOp = "bytes_to_string" )
type SourceLocation ¶
SourceLocation retains enough of the source AST location for diagnostics.
type Terminator ¶
type Terminator struct {
Kind TerminatorKind
Cond ValueID
Value ValueID
Target BlockLabel
TrueTarget BlockLabel
FalseTarget BlockLabel
Source SourceLocation
}
Terminator is an explicit control-flow edge. Value is optional for a void return and Cond is required for a branch.
type TerminatorKind ¶
type TerminatorKind string
TerminatorKind identifies the control transfer ending a basic block.
const ( TermJump TerminatorKind = "jump" TermBranch TerminatorKind = "branch" TermReturn TerminatorKind = "return" )