pub enum Node {
Show 16 variants
Literal {
id: NodeId,
node_type: Type,
value: LiteralValue,
},
Param {
id: NodeId,
name: String,
index: u32,
node_type: Type,
},
Let {
id: NodeId,
name: String,
node_type: Type,
value: Box<Node>,
body: Box<Node>,
},
If {
id: NodeId,
node_type: Type,
cond: Box<Node>,
then_branch: Box<Node>,
else_branch: Box<Node>,
},
Call {
id: NodeId,
node_type: Type,
target: String,
args: Vec<Node>,
},
Return {
id: NodeId,
node_type: Type,
value: Box<Node>,
},
BinOp {
id: NodeId,
op: BinOpKind,
node_type: Type,
lhs: Box<Node>,
rhs: Box<Node>,
},
UnaryOp {
id: NodeId,
op: UnaryOpKind,
node_type: Type,
operand: Box<Node>,
},
Block {
id: NodeId,
node_type: Type,
statements: Vec<Node>,
result: Box<Node>,
},
Loop {
id: NodeId,
node_type: Type,
body: Box<Node>,
},
Match {
id: NodeId,
node_type: Type,
scrutinee: Box<Node>,
arms: Vec<MatchArm>,
},
StructLiteral {
id: NodeId,
node_type: Type,
fields: Vec<(String, Node)>,
},
FieldAccess {
id: NodeId,
node_type: Type,
object: Box<Node>,
field: String,
},
ArrayLiteral {
id: NodeId,
node_type: Type,
elements: Vec<Node>,
},
IndexAccess {
id: NodeId,
node_type: Type,
array: Box<Node>,
index: Box<Node>,
},
Error {
id: NodeId,
message: String,
},
}Expand description
The core IR node enum. Each variant represents a different kind of computation in the AIRL intermediate representation.
Nodes are serialized to/from JSON with a "kind" discriminator field.
All variants share:
id— uniqueNodeIdfor patch targetingnode_type— theTypethis node evaluates to (except forNode::Error)
Variants§
Literal
A literal value (integer, float, bool, string, unit).
Param
Reference to a function parameter or let-bound local variable.
Let
let name = value in body — introduces a local binding.
If
if cond then then_branch else else_branch.
Call
A function call. target is a name (user-defined or builtin like std::io::println).
Return
return value — early exit from a function.
BinOp
Binary operator application (lhs op rhs). See BinOpKind.
UnaryOp
Unary operator application (op operand). See UnaryOpKind.
Block
A sequence of statements followed by a result expression.
Loop
Infinite loop — exit only via Return or internal LoopBreak.
Match
Pattern match. Evaluates scrutinee, then the first matching arm’s body.
StructLiteral
Struct literal: { field1: v1, field2: v2 }.
FieldAccess
Access a struct field: object.field.
ArrayLiteral
Array literal: [e1, e2, e3].
IndexAccess
Array index access: array[index].
Error
An explicit error node, used as a placeholder when parsing fails.