Skip to main content

NodeKind

Enum NodeKind 

Source
pub enum NodeKind {
Show 41 variants Block, Empty, Yield, ExprStmt, VarDecl, Assign, If, While, DoWhile, For, ForEach, Return, Break, Continue, Throw, Try, Catch, Synchronized, Switch, Case, Label, Assert, Binary, Unary, Call, Literal, VarRef, Ternary, Cast, Paren, Member, Index, New, NewArray, ArrayLit, This, InstanceOf, Lambda, MethodRef, Raw, Custom(u16),
}

Variants§

§

Block

[stmt…]

§

Empty

空语句 ;,无 children。

§

Yield

yield expr;(switch 表达式块内的产出语句)。

§

ExprStmt

[expr]

§

VarDecl

局部变量声明,children: [(init)?],名字由 Lang::var_name 提供。 目标变量必须可写(普通局部变量),声明的类型语义由语言侧保证。

§

Assign

[target, value];target 必须是 VarRef(复合赋值通过 Lang::assign_op 区分)。

§

If

[cond, then] 或 [cond, then, else]

§

While

[cond, body]

§

DoWhile

[body, cond]

§

For

[(init)?, (cond)?, (step)?, body]

§

ForEach

增强 for:[iterable, body],变量名/类型为语言侧 attr。

§

Return

[(value)?]

§

Break

[(label)?](label 以字符串 attr 提供,不在 children)

§

Continue

§

Throw

[expr]

§

Try

[(resource)?, try_block, (catch)?, (finally)?];资源是语句节点,catch 子节点。

§

Catch

[body];参数为语言侧 attr(var_name 返回绑定名)。

§

Synchronized

[lock, block]

§

Switch

[subject, case…]

§

Case

[label…, stmts…](label 数与是否 default 为语言侧 attr)

§

Label

[stmt],标签名为 attr。

§

Assert

[(cond, (msg)?)]

§

Binary

[lhs, rhs],运算符由 Lang::bin_op 提供。

§

Unary

[operand],运算符由 Lang::un_op 提供。

§

Call

[callee, arg…];callee 不能为空。

§

Literal

字面量,值由 Lang::literal 提供,无 children。

§

VarRef

变量读,名字由 Lang::var_name 提供。

§

Ternary

[cond, then, else]

§

Cast

[expr],目标类型为语言侧 attr。

§

Paren

[expr] 纯括号分组,可被 ParenRemoval 删除。

§

Member

[object],成员名为语言侧 attr(null 安全调用等也是语言侧语义)。

§

Index

[array, index]

§

New

[arg…],构造类型为语言侧 attr。

§

NewArray

[size…, (init)?],元素类型与已给尺寸数为语言侧 attr。

§

ArrayLit

[elem…]

§

This

无 children(或语言侧自定)。

§

InstanceOf

[expr],类型/模式绑定为语言侧 attr。x instanceof T b

§

Lambda

[body](body 为 Block 或表达式),参数原文为语言侧 attr。

§

MethodRef

[receiver],成员名为语言侧 attr。recv::name

§

Raw

不可解析的原文区域:语言侧原样保留,通用规则不触碰。

§

Custom(u16)

语言特有节点逃逸口;引擎通用规则不匹配。

Implementations§

Source§

impl NodeKind

Source

pub const SLOT_COUNT: usize = 42

slot 的上界(分派表定容用)。

Source

pub fn slot(self) -> usize

数组分派用的小整数键:字段变体 Custom 折叠到统一槽位。 穷尽 match —— 枚举加变体时编译器强制补分支(不会静默漏桶)。

Source§

impl NodeKind

Source

pub fn is_stmt(self) -> bool

Trait Implementations§

Source§

impl Clone for NodeKind

Source§

fn clone(&self) -> NodeKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for NodeKind

Source§

impl Debug for NodeKind

Source§

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

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

impl Display for NodeKind

Source§

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

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

impl Eq for NodeKind

Source§

impl Hash for NodeKind

Source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Ord for NodeKind

Source§

fn cmp(&self, other: &NodeKind) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for NodeKind

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for NodeKind

Source§

fn partial_cmp(&self, other: &NodeKind) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for NodeKind

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
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.

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.