Skip to main content

ExprKind

Enum ExprKind 

Source
pub enum ExprKind {
Show 36 variants Ident(Ident), Null, Bool(bool), Number(f64), BigInt { digits: String, radix: u32, }, String(String), RegExp { pattern: String, flags: String, }, This, Array { elements: Vec<Option<ArrayElement>>, }, Object(Vec<ObjectProperty>), Function(Box<Function>), Arrow(Box<Function>), Class(Box<Class>), Template(Box<TemplateLiteral>), TaggedTemplate { tag: Box<Expr>, quasi: Box<TemplateLiteral>, }, Member { object: Box<Expr>, property: MemberProp, optional: bool, }, Call { callee: Box<Expr>, arguments: Vec<Expr>, optional: bool, }, New { callee: Box<Expr>, arguments: Option<Vec<Expr>>, }, NewTarget, ImportMeta, ImportCall(Box<Expr>), SuperCall(Vec<Expr>), SuperProp, Unary { op: UnaryOp, argument: Box<Expr>, }, Update { op: UpdateOp, argument: Box<Expr>, prefix: bool, }, Binary { op: BinaryOp, left: Box<Expr>, right: Box<Expr>, }, Logical { op: LogicalOp, left: Box<Expr>, right: Box<Expr>, }, Conditional { test: Box<Expr>, cons: Box<Expr>, alt: Box<Expr>, }, Assign { op: AssignOp, target: Box<Pattern>, value: Box<Expr>, }, Paren(Box<Expr>), Sequence(Vec<Expr>), Yield { argument: Option<Box<Expr>>, delegate: bool, }, Await(Box<Expr>), Spread(Box<Expr>), OptionalChain(Box<Expr>), PrivateIn { name: Ident, object: Box<Expr>, },
}
Expand description

Expression payloads.

Variants§

§

Ident(Ident)

An identifier reference (not resolved to a binding yet).

§

Null

null

§

Bool(bool)

true / false

§

Number(f64)

1.5

§

BigInt

1n

Fields

§digits: String

Digits without prefix or separators.

§radix: u32

2, 8, 10 or 16.

§

String(String)

"text"

§

RegExp

/pattern/flags

Fields

§pattern: String

Pattern source.

§flags: String

Flag letters.

§

This

this

§

Array

[a, b, ...c]

Fields

§elements: Vec<Option<ArrayElement>>

Elements; None for an elision.

§

Object(Vec<ObjectProperty>)

{ a, b: c, ...d }

§

Function(Box<Function>)

function name() {}

§

Arrow(Box<Function>)

(params) => body

§

Class(Box<Class>)

class { }

§

Template(Box<TemplateLiteral>)

`a${b}c`

§

TaggedTemplate

tag`a${b}c`

Fields

§tag: Box<Expr>

Tag function.

§quasi: Box<TemplateLiteral>

Template parts.

§

Member

a.b, a[b], a?.b, super.x

Fields

§object: Box<Expr>

Base object.

§property: MemberProp

Selector.

§optional: bool

Whether ?. was used.

§

Call

f(args)

Fields

§callee: Box<Expr>

Callee.

§arguments: Vec<Expr>

Arguments.

§optional: bool

Whether ?.() was used.

§

New

new C(args) / new C

Fields

§callee: Box<Expr>

Constructor.

§arguments: Option<Vec<Expr>>

Arguments; None for new C without a list.

§

NewTarget

new.target

§

ImportMeta

import.meta

§

ImportCall(Box<Expr>)

import(specifier)

§

SuperCall(Vec<Expr>)

super() — only valid in a derived constructor.

§

SuperProp

super.x / super[x] base (never standalone).

§

Unary

op expr

Fields

§op: UnaryOp

Operator.

§argument: Box<Expr>

Operand.

§

Update

++x, x--

Fields

§op: UpdateOp

Operator.

§argument: Box<Expr>

Operand.

§prefix: bool

Whether the operator came before the operand.

§

Binary

a + b, a instanceof b, a in b, …

Fields

§op: BinaryOp

Operator.

§left: Box<Expr>

Left operand.

§right: Box<Expr>

Right operand.

§

Logical

a && b, a || b, a ?? b (kept separate for mixing rules and short-circuit code generation).

Fields

§op: LogicalOp

Operator.

§left: Box<Expr>

Left operand.

§right: Box<Expr>

Right operand.

§

Conditional

a ? b : c

Fields

§test: Box<Expr>

Condition.

§cons: Box<Expr>

Consequent.

§alt: Box<Expr>

Alternate.

§

Assign

target op= value

Fields

§op: AssignOp

Assignment operator.

§target: Box<Pattern>

Assignment target (converted from the cover grammar).

§value: Box<Expr>

Right-hand side.

§

Paren(Box<Expr>)

(expr) — kept as a node so that early errors can tell (a ?? b) || c (legal) from a ?? b || c (SyntaxError), and (a) = 1 from (a, b) = 1.

§

Sequence(Vec<Expr>)

(a, b, c)

§

Yield

yield expr / yield* expr

Fields

§argument: Option<Box<Expr>>

Operand; None for yield;.

§delegate: bool

Whether yield* was used.

§

Await(Box<Expr>)

await expr

§

Spread(Box<Expr>)

...expr — only valid in call arguments, arrays and object literals.

§

OptionalChain(Box<Expr>)

A member/call chain that contains at least one ?.. Compiling the wrapper short-circuits the whole spine when a link’s base is nullish.

§

PrivateIn

#x in obj

Fields

§name: Ident

Private name.

§object: Box<Expr>

Tested object.

Trait Implementations§

Source§

impl Clone for ExprKind

Source§

fn clone(&self) -> Self

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 Debug for ExprKind

Source§

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

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

impl PartialEq for ExprKind

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ExprKind

Auto Trait Implementations§

§

impl Forget for ExprKind

§

impl Freeze for ExprKind

§

impl Move for ExprKind

§

impl RefUnwindSafe for ExprKind

§

impl Send for ExprKind
where RawVecInner: Send, BoxRaw<Expr>: Send, BoxRaw<Function>: Send, BoxRaw<Class>: Send, BoxRaw<TemplateLiteral>: Send, BoxRaw<Pattern>: Send,

§

impl Sync for ExprKind
where RawVecInner: Sync, BoxRaw<Expr>: Sync, BoxRaw<Function>: Sync, BoxRaw<Class>: Sync, BoxRaw<TemplateLiteral>: Sync, BoxRaw<Pattern>: Sync,

§

impl Unpin for ExprKind

§

impl UnsafeUnpin for ExprKind

§

impl UnwindSafe for ExprKind
where RawVecInner: UnwindSafe, BoxRaw<Expr>: UnwindSafe, BoxRaw<Function>: UnwindSafe, BoxRaw<Class>: UnwindSafe, BoxRaw<TemplateLiteral>: UnwindSafe, BoxRaw<Pattern>: UnwindSafe,

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