NodeTag

Enum NodeTag 

Source
#[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§

Source§

impl Clone for NodeTag

Source§

fn clone(&self) -> NodeTag

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeTag

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for NodeTag

Source§

fn eq(&self, other: &NodeTag) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for NodeTag

Source§

impl Eq for NodeTag

Source§

impl StructuralPartialEq for NodeTag

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

§

type Proj<U: 'src> = U

§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

§

impl<'p, T> Seq<'p, T> for T
where T: Clone,

§

type Item<'a> = &'a T where T: 'a

The item yielded by the iterator.
§

type Iter<'a> = Once<&'a T> where T: 'a

An iterator over the items within this container, by reference.
§

fn seq_iter(&self) -> <T as Seq<'p, T>>::Iter<'_>

Iterate over the elements of the container.
§

fn contains(&self, val: &T) -> bool
where T: PartialEq,

Check whether an item is contained within this sequence.
§

fn to_maybe_ref<'b>(item: <T as Seq<'p, T>>::Item<'b>) -> Maybe<T, &'p T>
where 'p: 'b,

Convert an item of the sequence into a [MaybeRef].
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> OrderedSeq<'_, T> for T
where T: Clone,