Skip to main content

ExprKind

Enum ExprKind 

Source
pub enum ExprKind {
Show 34 variants Int(i128), Float(f64), ComplexOf { re: Box<Expr>, im: Box<Expr>, }, Zeroed, Load(Place), AddrOf(Place), FuncAddr(FuncId), LabelAddr(LabelId), Assign { place: Place, value: Box<Expr>, }, CompoundAssign { place: Place, op: BinOp, value: Box<Expr>, compute: Ty, }, IncDec { place: Place, dec: bool, postfix: bool, }, Neg(Box<Expr>), BitNot(Box<Expr>), Binary { op: BinOp, lhs: Box<Expr>, rhs: Box<Expr>, }, PtrOffset { ptr: Box<Expr>, index: Box<Expr>, sub: bool, }, PtrDiff { lhs: Box<Expr>, rhs: Box<Expr>, }, Compare { op: CmpOp, lhs: Box<Expr>, rhs: Box<Expr>, }, Logical { op: LogicalOp, lhs: Box<Expr>, rhs: Box<Expr>, }, Cast(Box<Expr>), Cond { cond: Box<Expr>, then_expr: Box<Expr>, else_expr: Box<Expr>, }, CondDefault { value: Box<Expr>, else_expr: Box<Expr>, }, StmtExpr { stmts: Vec<Stmt>, value: Option<Box<Expr>>, }, Builtin { op: BuiltinOp, args: Vec<Expr>, }, Atomic(Box<AtomicExpr>), Comma { lhs: Box<Expr>, rhs: Box<Expr>, }, Call { callee: Callee, args: Vec<Expr>, }, RecordLit { record: RecordId, fields: Vec<Expr>, }, UnionLit { record: RecordId, index: usize, value: Box<Expr>, }, ArrayLit(Vec<Expr>), ArrayRepeat { value: Box<Expr>, len: u64, }, VaListPristine, VaArg { ap: Place, record: Option<Vec<Eightbyte>>, }, Unreachable, VaEnd,
}
Expand description

The shape of an Expr.

Variants§

§

Int(i128)

An integer constant, already reduced to the range of its type.

§

Float(f64)

A floating constant.

§

ComplexOf

A complex value built from its two parts, which have the corresponding real type.

It is what __builtin_complex(x, y) — and therefore CMPLX — makes, what an imaginary constant such as 2.0i is, and what a folded complex constant comes back as.

Fields

§re: Box<Expr>

The real part.

§im: Box<Expr>

The imaginary part.

§

Zeroed

The all-bits-zero value of the expression’s type: 0, 0.0, false, a null pointer, or a zeroed aggregate.

§

Load(Place)

Reading a place.

§

AddrOf(Place)

The address of a place. The expression’s type says what pointer type is wanted, which is what turns an array place into a pointer to its first element.

§

FuncAddr(FuncId)

The address of a function, whose type is a pointer to it.

§

LabelAddr(LabelId)

GNU’s &&label: the address of a label of the enclosing function, of type void *.

A function that takes one is lowered through a control-flow graph, and the value is the label’s number among the function’s labels whose address is taken, from 1, cast to a pointer — which is what goto *e’s switch matches on. It is an address constant, so a static void *table[] = { &&a, &&b }; holds a table of them.

§

Assign

place = value, whose value is the value stored.

Fields

§place: Place

The assigned-to location.

§value: Box<Expr>

The value, already converted to the place’s type.

§

CompoundAssign

place op= value, whose value is the value stored.

For a pointer place compute is the pointer type and value keeps its integer type: p += n is pointer arithmetic, not an addition.

Fields

§place: Place

The assigned-to location, evaluated exactly once.

§op: BinOp

The operator.

§value: Box<Expr>

The right operand, already converted for compute.

§compute: Ty

The type the operation is carried out in, before the result is converted back to the place’s type.

§

IncDec

++place, place++, --place or place--.

Fields

§place: Place

The affected location.

§dec: bool

Whether this decrements.

§postfix: bool

Whether the value is the one from before the update.

§

Neg(Box<Expr>)

Arithmetic negation, on an already promoted operand.

§

BitNot(Box<Expr>)

~x, on an already promoted operand.

§

Binary

A binary operation. Both operands already have the result type, except for shifts, whose operands are promoted separately.

Fields

§op: BinOp

The operator.

§lhs: Box<Expr>

Left operand.

§rhs: Box<Expr>

Right operand.

§

PtrOffset

ptr + index or ptr - index: pointer arithmetic in units of the pointee, which is what <*mut T>::offset does.

Fields

§ptr: Box<Expr>

The pointer, which is also the type of the result.

§index: Box<Expr>

The offset, of integer type.

§sub: bool

Whether the offset is subtracted.

§

PtrDiff

lhs - rhs between two pointers, whose value has type ptrdiff_t.

Fields

§lhs: Box<Expr>

Left operand.

§rhs: Box<Expr>

Right operand.

§

Compare

A comparison. Both operands already have a common type; the result has type int and is 0 or 1.

Fields

§op: CmpOp

The operator.

§lhs: Box<Expr>

Left operand.

§rhs: Box<Expr>

Right operand.

§

Logical

&& or ||: each operand is tested against zero, the right one only if the left does not already decide the result. The result has type int and is 0 or 1.

Fields

§op: LogicalOp

The operator.

§lhs: Box<Expr>

Left operand.

§rhs: Box<Expr>

Right operand.

§

Cast(Box<Expr>)

A conversion to the expression’s own type.

§

Cond

cond ? then_expr : else_expr, with both arms already converted to the expression’s type.

Fields

§cond: Box<Expr>

The controlling expression.

§then_expr: Box<Expr>

The value when the condition is true.

§else_expr: Box<Expr>

The value otherwise.

§

CondDefault

GNU’s a ?: b: a if it is non-zero and b otherwise, with a evaluated exactly once. Both operands already have the result type.

Fields

§value: Box<Expr>

The value that is both the condition and the first result.

§else_expr: Box<Expr>

The value when it is zero.

§

StmtExpr

GNU’s statement expression, ({ …; e; }).

Fields

§stmts: Vec<Stmt>

The statements, in order.

§value: Option<Box<Expr>>

The value of the last expression statement, if there was one.

§

Builtin

A builtin lowered to a fixed piece of Rust; see BuiltinOp.

Fields

§op: BuiltinOp

Which builtin.

§args: Vec<Expr>

Its operands, already converted.

§

Atomic(Box<AtomicExpr>)

One of the atomic builtins; see AtomicExpr.

Boxed because it is much the largest thing an expression can hold and every other node would grow to its size.

§

Comma

lhs, rhs: lhs is evaluated for its side effects only.

Fields

§lhs: Box<Expr>

Evaluated and discarded.

§rhs: Box<Expr>

The result.

§

Call

A call, with every argument already converted to its parameter’s type (or promoted, for the variable part of a variadic call).

Fields

§callee: Callee

What is called.

§args: Vec<Expr>

The arguments.

§

RecordLit

A struct value: one expression per member, in declaration order.

Fields

§record: RecordId

The record’s identity.

§fields: Vec<Expr>

The member values.

§

UnionLit

A union value, which initialises exactly one member.

Fields

§record: RecordId

The record’s identity.

§index: usize

The index of the initialised member.

§value: Box<Expr>

Its value.

§

ArrayLit(Vec<Expr>)

An array value: one expression per element.

§

ArrayRepeat

An array value whose elements are all the same: [value; len].

Fields

§value: Box<Expr>

The repeated element.

§len: u64

How many times it is repeated.

§

VaListPristine

A fresh copy of the argument list the function was called with.

It is what va_start stores and what a va_list local starts out as; the list it copies is the ... parameter of a variadic definition, or the function’s own va_list parameter. Its type is Ty::VaList.

§

VaArg

va_arg(ap, T): reads the next argument and advances ap. The expression’s own type is T.

Fields

§ap: Place

The list to read from and advance.

§record: Option<Vec<Eightbyte>>

How a struct or union is taken apart to be read: one entry per eightbyte of it, in order. None for every other type, which is read in one next_arg at the type itself.

§

Unreachable

C23’s unreachable(), which promises control never gets here.

§

VaEnd

va_end(ap), whose type is void.

Rust ends a list when it goes out of scope, so this does nothing; it is a node of its own so that the expansion does not have to pretend the call happened.

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

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