Enum naga::front::wgsl::parse::ast::Expression

source ·
pub enum Expression<'a> {
    Literal(Literal),
    Ident(IdentExpr<'a>),
    Construct {
        ty: ConstructorType<'a>,
        ty_span: Span,
        components: Vec<Handle<Expression<'a>>>,
    },
    Unary {
        op: UnaryOperator,
        expr: Handle<Expression<'a>>,
    },
    AddrOf(Handle<Expression<'a>>),
    Deref(Handle<Expression<'a>>),
    Binary {
        op: BinaryOperator,
        left: Handle<Expression<'a>>,
        right: Handle<Expression<'a>>,
    },
    Call {
        function: Ident<'a>,
        arguments: Vec<Handle<Expression<'a>>>,
    },
    Index {
        base: Handle<Expression<'a>>,
        index: Handle<Expression<'a>>,
    },
    Member {
        base: Handle<Expression<'a>>,
        field: Ident<'a>,
    },
    Bitcast {
        expr: Handle<Expression<'a>>,
        to: Handle<Type<'a>>,
        ty_span: Span,
    },
}

Variants§

§

Literal(Literal)

§

Ident(IdentExpr<'a>)

§

Construct

A type constructor expression.

This is only used for expressions like KEYWORD(EXPR...) and KEYWORD<PARAM>(EXPR...), where KEYWORD is a type-defining keyword like vec3. These keywords cannot be shadowed by user definitions, so we can tell that such an expression is a construction immediately.

For ordinary identifiers, we can’t tell whether an expression like IDENTIFIER(EXPR, ...) is a construction expression or a function call until we know IDENTIFIER’s definition, so we represent those as Call expressions.

Fields

§ty_span: Span
§components: Vec<Handle<Expression<'a>>>
§

Unary

Fields

§expr: Handle<Expression<'a>>
§

AddrOf(Handle<Expression<'a>>)

§

Deref(Handle<Expression<'a>>)

§

Binary

Fields

§left: Handle<Expression<'a>>
§right: Handle<Expression<'a>>
§

Call

A function call or type constructor expression.

We can’t tell whether an expression like IDENTIFIER(EXPR, ...) is a construction expression or a function call until we know IDENTIFIER’s definition, so we represent everything of that form as one of these expressions until lowering. At that point, Lowerer::call has everything’s definition in hand, and can decide whether to emit a Naga Constant, As, Splat, or Compose expression.

Fields

§function: Ident<'a>
§arguments: Vec<Handle<Expression<'a>>>
§

Index

Fields

§base: Handle<Expression<'a>>
§index: Handle<Expression<'a>>
§

Member

Fields

§base: Handle<Expression<'a>>
§field: Ident<'a>
§

Bitcast

Fields

§expr: Handle<Expression<'a>>
§to: Handle<Type<'a>>
§ty_span: Span

Trait Implementations§

source§

impl<'a> Debug for Expression<'a>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Expression<'a>

§

impl<'a> RefUnwindSafe for Expression<'a>

§

impl<'a> Send for Expression<'a>

§

impl<'a> Sync for Expression<'a>

§

impl<'a> Unpin for Expression<'a>

§

impl<'a> UnwindSafe for Expression<'a>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.