#[repr(u8)]pub enum NodeTag {
Show 59 variants
Function = 0,
StructDecl = 1,
EnumDecl = 2,
DropFn = 3,
ConstDecl = 4,
IntLit = 5,
StringLit = 6,
BoolLit = 7,
UnitLit = 8,
Ident = 9,
Path = 10,
UnaryExpr = 11,
ParenExpr = 12,
BinaryExpr = 13,
IfExpr = 14,
MatchExpr = 15,
WhileExpr = 16,
ForExpr = 17,
LoopExpr = 18,
BreakExpr = 19,
ContinueExpr = 20,
ReturnExpr = 21,
BlockExpr = 22,
LetStmt = 23,
AssignStmt = 24,
ExprStmt = 25,
Call = 26,
MethodCall = 27,
IntrinsicCall = 28,
AssocFnCall = 29,
StructLit = 30,
FieldExpr = 31,
FieldInit = 32,
ArrayLit = 33,
IndexExpr = 34,
SelfExpr = 35,
ComptimeBlockExpr = 36,
CheckedBlockExpr = 37,
TypeLit = 38,
TypeNamed = 39,
TypeUnit = 40,
TypeNever = 41,
TypeArray = 42,
TypeAnonStruct = 43,
TypePointerConst = 44,
TypePointerMut = 45,
PatternWildcard = 46,
PatternInt = 47,
PatternBool = 48,
PatternPath = 49,
Param = 50,
Method = 51,
MatchArm = 52,
CallArg = 53,
FieldDecl = 54,
EnumVariant = 55,
Directive = 56,
DirectiveArg = 57,
ErrorNode = 58,
}Expand description
Node tag - identifies what kind of node this is.
The tag determines how to interpret the lhs/rhs fields in NodeData. See docs/designs/soa-ast-layout.md for encoding details.
Variants§
Function = 0
Function declaration: fn name(params) -> ret { body }
- lhs: index into extra (param count + param nodes)
- rhs: body expression node
StructDecl = 1
Struct declaration: struct Name { fields… methods… }
- lhs: index into extra (field count + field nodes)
- rhs: index into extra (method count + method nodes)
EnumDecl = 2
Enum declaration: enum Name { variants… }
- lhs: index into extra (variant count + variant nodes)
- rhs: 0 (unused)
DropFn = 3
Drop function: drop fn TypeName(self) { body }
- lhs: type name identifier
- rhs: body expression node
ConstDecl = 4
Constant declaration: const name: type = init;
- lhs: type expression node (or NULL_NODE if inferred)
- rhs: initializer expression node
IntLit = 5
Integer literal: 42
- lhs: low 32 bits of u64 value
- rhs: high 32 bits of u64 value
StringLit = 6
String literal: “hello”
- lhs: Spur index (u32) for interned string
- rhs: 0 (unused)
BoolLit = 7
Boolean literal: true, false
- lhs: 0 (false) or 1 (true)
- rhs: 0 (unused)
UnitLit = 8
Unit literal: ()
- lhs: 0 (unused)
- rhs: 0 (unused)
Ident = 9
Identifier: variable_name
- lhs: Spur index (u32) for identifier name
- rhs: 0 (unused)
Path = 10
Path expression: Color::Red
- lhs: type name identifier node
- rhs: variant name identifier node
UnaryExpr = 11
Unary expression: -x, !x, ~x
- lhs: operand expression node
- rhs: operator kind (u32 from UnaryOp enum)
ParenExpr = 12
Parenthesized expression: (expr)
- lhs: inner expression node
- rhs: 0 (unused)
BinaryExpr = 13
Binary expression: a + b, a == b, etc.
- main_token: the operator token
- lhs: left operand expression node
- rhs: right operand expression node
IfExpr = 14
If expression: if cond { then } else { else_block }
- lhs: condition expression node
- rhs: index into extra (then_block, else_block or NULL_NODE)
MatchExpr = 15
Match expression: match x { arms… }
- lhs: scrutinee expression node
- rhs: index into extra (arm count + arm nodes)
WhileExpr = 16
While loop: while cond { body }
- lhs: condition expression node
- rhs: body block expression node
ForExpr = 17
For-in loop: for [mut] x in expr { body }
- lhs: iterable expression node
- rhs: body block expression node
- extra: binding name (Spur index), is_mut flag
LoopExpr = 18
Infinite loop: loop { body }
- lhs: body block expression node
- rhs: 0 (unused)
BreakExpr = 19
Break statement: break
- lhs: 0 (unused)
- rhs: 0 (unused)
ContinueExpr = 20
Continue statement: continue
- lhs: 0 (unused)
- rhs: 0 (unused)
ReturnExpr = 21
Return statement: return expr
- lhs: value expression node (or NULL_NODE for implicit unit return)
- rhs: 0 (unused)
BlockExpr = 22
Block expression: { stmts…; final_expr }
- lhs: index into extra (stmt count + stmt nodes)
- rhs: final expression node
LetStmt = 23
Let statement: let x: type = init;
- lhs: pattern node (identifier or wildcard)
- rhs: index into extra (flags, type_expr or NULL_NODE, init_expr)
AssignStmt = 24
Assignment statement: x = value;
- lhs: target node (Ident, FieldExpr, or IndexExpr)
- rhs: value expression node
ExprStmt = 25
Expression statement: expr;
- lhs: expression node
- rhs: 0 (unused)
Call = 26
Function call: func(args…)
- lhs: callee identifier node
- rhs: index into extra (arg count + arg nodes)
MethodCall = 27
Method call: receiver.method(args…)
- lhs: receiver expression node
- rhs: index into extra (method name, arg count, arg nodes)
IntrinsicCall = 28
Intrinsic call: @intrinsic(args…)
- lhs: intrinsic name identifier node
- rhs: index into extra (arg count + arg nodes)
AssocFnCall = 29
Associated function call: Type::func(args…)
- lhs: type name identifier node
- rhs: index into extra (fn name, arg count, arg nodes)
StructLit = 30
Struct literal: Point { x: 1, y: 2 }
- lhs: struct name identifier node
- rhs: index into extra (field init count + field init nodes)
FieldExpr = 31
Field access: obj.field
- lhs: base expression node
- rhs: field name identifier node
FieldInit = 32
Field initializer in struct literal: field_name: value
- lhs: field name identifier node
- rhs: value expression node
ArrayLit = 33
Array literal: [1, 2, 3]
- lhs: index into extra (element count + element nodes)
- rhs: 0 (unused, count stored in extra)
IndexExpr = 34
Array index: arr[index]
- lhs: base expression node
- rhs: index expression node
SelfExpr = 35
Self expression: self
- lhs: 0 (unused)
- rhs: 0 (unused)
ComptimeBlockExpr = 36
Comptime block: comptime { expr }
- lhs: inner expression node
- rhs: 0 (unused)
CheckedBlockExpr = 37
Checked block: checked { expr }
- lhs: inner expression node
- rhs: 0 (unused)
TypeLit = 38
Type literal: i32 (used as value)
- lhs: type expression node
- rhs: 0 (unused)
TypeNamed = 39
Named type: i32, MyStruct
- lhs: name identifier node
- rhs: 0 (unused)
TypeUnit = 40
Unit type: ()
- lhs: 0 (unused)
- rhs: 0 (unused)
TypeNever = 41
Never type: !
- lhs: 0 (unused)
- rhs: 0 (unused)
TypeArray = 42
Array type: [T; N]
- lhs: element type expression node
- rhs: length (u32, stored directly)
TypeAnonStruct = 43
Anonymous struct type: struct { fields… methods… }
- lhs: index into extra (field count + field nodes)
- rhs: index into extra (method count + method nodes)
TypePointerConst = 44
Const pointer type: ptr const T
- lhs: pointee type expression node
- rhs: 0 (unused)
TypePointerMut = 45
Mutable pointer type: ptr mut T
- lhs: pointee type expression node
- rhs: 0 (unused)
PatternWildcard = 46
Wildcard pattern: _
- lhs: 0 (unused)
- rhs: 0 (unused)
PatternInt = 47
Integer literal pattern: 42, -1
- lhs: low 32 bits of value
- rhs: high 32 bits of value
PatternBool = 48
Boolean literal pattern: true, false
- lhs: 0 (false) or 1 (true)
- rhs: 0 (unused)
PatternPath = 49
Path pattern: Color::Red
- lhs: type name identifier node
- rhs: variant name identifier node
Param = 50
Function parameter: name: type
- lhs: name identifier node
- rhs: type expression node
- extra: flags (is_comptime, mode)
Method = 51
Method definition
- lhs: index into extra (name, receiver?, param count, params)
- rhs: index into extra (return_type or NULL_NODE, body_expr)
MatchArm = 52
Match arm: pattern => body
- lhs: pattern node
- rhs: body expression node
CallArg = 53
Call argument (wraps expression with mode flags)
- lhs: expression node
- rhs: flags (normal=0, inout=1, borrow=2)
FieldDecl = 54
Field declaration in struct
- lhs: name identifier node
- rhs: type expression node
EnumVariant = 55
Enum variant
- lhs: name identifier node
- rhs: 0 (unused, payload support future)
Directive = 56
Directive: @name(args…)
- lhs: name identifier node
- rhs: index into extra (arg count + arg nodes)
DirectiveArg = 57
Directive argument (currently just identifiers)
- lhs: identifier node
- rhs: 0 (unused)
ErrorNode = 58
Error node (parse error recovery)
- lhs: 0 (unused)
- rhs: 0 (unused)
Trait Implementations§
impl Copy for NodeTag
impl Eq for NodeTag
impl StructuralPartialEq for NodeTag
Auto Trait Implementations§
impl Freeze for NodeTag
impl RefUnwindSafe for NodeTag
impl Send for NodeTag
impl Sync for NodeTag
impl Unpin for NodeTag
impl UnwindSafe for NodeTag
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
impl<'src, T> IntoMaybe<'src, T> for Twhere
T: 'src,
§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
§type Iter<'a> = Once<&'a T>
where
T: 'a
type Iter<'a> = Once<&'a T> where T: 'a
§fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
fn contains(&self, val: &T) -> boolwhere
T: PartialEq,
§fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>where
'p: 'b,
MaybeRef].