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.
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
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
IncDec
++place, place++, --place or place--.
Fields
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.
PtrOffset
ptr + index or ptr - index: pointer arithmetic in units of the
pointee, which is what <*mut T>::offset does.
Fields
PtrDiff
lhs - rhs between two pointers, whose value has type ptrdiff_t.
Compare
A comparison. Both operands already have a common type; the result has
type int and is 0 or 1.
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.
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
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
StmtExpr
GNU’s statement expression, ({ …; e; }).
Fields
Builtin
A builtin lowered to a fixed piece of Rust; see BuiltinOp.
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.
Call
A call, with every argument already converted to its parameter’s type (or promoted, for the variable part of a variadic call).
RecordLit
A struct value: one expression per member, in declaration order.
UnionLit
A union value, which initialises exactly one member.
Fields
ArrayLit(Vec<Expr>)
An array value: one expression per element.
ArrayRepeat
An array value whose elements are all the same: [value; len].
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
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.