Skip to main content

ExpressionKind

Enum ExpressionKind 

Source
pub enum ExpressionKind {
Show 29 variants This, Super, Identifier(Identifier), PrivateIdentifier(PrivateIdentifier), Literal(Literal), Template { quasis: Vec<String>, expressions: Vec<Expression>, }, TaggedTemplate { tag: Box<Expression>, quasis: Vec<String>, expressions: Vec<Expression>, }, Array { elements: Vec<Option<Expression>>, }, Object { properties: Vec<ObjectMember>, }, Member { object: Box<Expression>, property: MemberProperty, optional: bool, }, Call { callee: Box<Expression>, arguments: Vec<Expression>, optional: bool, }, New { callee: Box<Expression>, arguments: Vec<Expression>, }, Update { operator: UpdateOperator, argument: Box<Expression>, prefix: bool, }, Unary { operator: UnaryOperator, argument: Box<Expression>, }, Binary { operator: BinaryOperator, left: Box<Expression>, right: Box<Expression>, }, Logical { operator: LogicalOperator, left: Box<Expression>, right: Box<Expression>, }, Conditional { test: Box<Expression>, consequent: Box<Expression>, alternate: Box<Expression>, }, Assignment { operator: AssignmentOperator, left: Box<Expression>, right: Box<Expression>, }, Sequence { expressions: Vec<Expression>, }, Spread { argument: Box<Expression>, }, ArrowFunction(Box<ArrowFunction>), FunctionExpression(Box<Function>), ClassExpression(Box<Class>), Yield { argument: Option<Box<Expression>>, delegate: bool, }, Await { argument: Box<Expression>, }, Chain { expression: Box<Expression>, }, ImportExpression { source: Box<Expression>, options: Option<Box<Expression>>, }, MetaProperty { meta: Identifier, property: Identifier, }, Parenthesized { expression: Box<Expression>, },
}
Expand description

The shape of an ECMAScript expression.

Variants§

§

This

The this keyword.

§

Super

The super keyword (only valid in certain method bodies).

§

Identifier(Identifier)

A variable reference.

§

PrivateIdentifier(PrivateIdentifier)

A private class-field identifier (#foo) used as a value.

§

Literal(Literal)

A static literal value.

§

Template

A template literal (`hello ${name}`). The number of quasis must satisfy quasis.len() == expressions.len() + 1.

Fields

§quasis: Vec<String>

Literal text chunks in source order.

§expressions: Vec<Expression>

Interpolated expressions, each appearing between two quasis.

§

TaggedTemplate

A tagged template (tag`hello ${name}`).

Fields

§tag: Box<Expression>

The tag function expression.

§quasis: Vec<String>

Literal text chunks.

§expressions: Vec<Expression>

Interpolated expressions.

§

Array

An array expression. None entries represent holes ([1, , 3]), and any element may be a ExpressionKind::Spread.

Fields

§elements: Vec<Option<Expression>>

Array elements; None for holes.

§

Object

An object expression.

Fields

§properties: Vec<ObjectMember>

Object members in source order.

§

Member

Property access: object.property or object[property], optionally ?.-qualified.

Fields

§object: Box<Expression>

The object expression.

§property: MemberProperty

The property selector.

§optional: bool

True when the access used ?. (optional chaining).

§

Call

Function application: callee(args), optionally ?.()-qualified.

Fields

§callee: Box<Expression>

The callee expression.

§arguments: Vec<Expression>

The argument list (each may be a spread).

§optional: bool

True when the call used ?.().

§

New

new invocation: new callee(args).

Fields

§callee: Box<Expression>

The constructor expression.

§arguments: Vec<Expression>

The argument list.

§

Update

++ or -- applied to an argument, prefix or postfix.

Fields

§operator: UpdateOperator

++ or --.

§argument: Box<Expression>

The target being updated.

§prefix: bool

True for ++x / --x, false for x++ / x--.

§

Unary

A unary prefix operator (!x, -x, typeof x, …).

Fields

§operator: UnaryOperator

The operator.

§argument: Box<Expression>

The operand.

§

Binary

A binary operator without short-circuit semantics.

Fields

§operator: BinaryOperator

The operator.

§left: Box<Expression>

The left operand.

§right: Box<Expression>

The right operand.

§

Logical

A short-circuit logical operator (&&, ||, ??).

Fields

§operator: LogicalOperator

The operator.

§left: Box<Expression>

The left operand.

§right: Box<Expression>

The right operand (evaluated lazily).

§

Conditional

The ternary conditional (test ? consequent : alternate).

Fields

§test: Box<Expression>

The test expression.

§consequent: Box<Expression>

The branch when test is truthy.

§alternate: Box<Expression>

The branch when test is falsy.

§

Assignment

An assignment expression (x = v, x += v, etc.).

Fields

§operator: AssignmentOperator

The assignment operator (plain = or compound).

§left: Box<Expression>

The target (an expression that must be a valid assignment target; patterns are validated structurally rather than at the type level).

§right: Box<Expression>

The right-hand value.

§

Sequence

A comma expression (a, b, c). Evaluates all in order and yields the last value.

Fields

§expressions: Vec<Expression>

Sub-expressions in source order.

§

Spread

A spread element (...expr).

Fields

§argument: Box<Expression>

The expression being spread.

§

ArrowFunction(Box<ArrowFunction>)

An arrow function expression.

§

FunctionExpression(Box<Function>)

A function expression (named or anonymous).

§

ClassExpression(Box<Class>)

A class expression.

§

Yield

yield or yield* in a generator.

Fields

§argument: Option<Box<Expression>>

Optional argument; yield; with no value gives None.

§delegate: bool

True for yield*, false for plain yield.

§

Await

await expr in an async function.

Fields

§argument: Box<Expression>

The promise-valued expression to await.

§

Chain

Optional-chaining wrapper ((obj?.a.b)). ESTree wraps the chain root so consumers can detect optional-chain shortcircuiting cheaply.

Fields

§expression: Box<Expression>

The optional-chain expression (a Member or Call with optional: true at some point in its descent).

§

ImportExpression

Dynamic import(source, options?).

Fields

§source: Box<Expression>

The module specifier expression.

§options: Option<Box<Expression>>

Optional second-argument options bag.

§

MetaProperty

A meta property: new.target or import.meta.

Fields

§meta: Identifier

The meta keyword (new or import).

§property: Identifier

The property name (target or meta).

§

Parenthesized

A parenthesised expression. Some tools care about whether the user wrote parens; for those, this variant preserves the distinction.

Fields

§expression: Box<Expression>

The inner expression.

Trait Implementations§

Source§

impl Clone for ExpressionKind

Source§

fn clone(&self) -> ExpressionKind

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 ExpressionKind

Source§

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

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

impl Display for ExpressionKind

Source§

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

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

impl Eq for ExpressionKind

Source§

impl PartialEq for ExpressionKind

Source§

fn eq(&self, other: &ExpressionKind) -> 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 ExpressionKind

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