pub enum ExprKind {
Show 32 variants
Ident(Ident),
Int(IntLit),
Float(FloatLit),
Char(CharLit),
Str(StrLit),
Unary {
op: UnaryOp,
operand: Box<Expr>,
},
Binary {
op: BinaryOp,
lhs: Box<Expr>,
rhs: Box<Expr>,
},
Assign {
op: Option<BinaryOp>,
lhs: Box<Expr>,
rhs: Box<Expr>,
},
Conditional {
cond: Box<Expr>,
then_expr: Option<Box<Expr>>,
else_expr: Box<Expr>,
},
Comma {
lhs: Box<Expr>,
rhs: Box<Expr>,
},
Call {
callee: Box<Expr>,
args: Vec<Expr>,
},
Member {
base: Box<Expr>,
arrow: bool,
field: Ident,
},
Index {
base: Box<Expr>,
index: Box<Expr>,
},
PostIncDec {
op: IncDec,
operand: Box<Expr>,
},
PreIncDec {
op: IncDec,
operand: Box<Expr>,
},
Cast {
ty: Box<TypeName>,
expr: Box<Expr>,
},
LabelAddr(Ident),
SizeofExpr(Box<Expr>),
SizeofType(Box<TypeName>),
AlignofExpr(Box<Expr>),
AlignofType(Box<TypeName>),
Generic {
controlling: Box<Expr>,
assocs: Vec<GenericAssoc>,
},
Bool(bool),
Nullptr,
VaArg {
ap: Box<Expr>,
ty: Box<TypeName>,
},
OffsetOf {
ty: Box<TypeName>,
member: Ident,
path: Vec<Designator>,
},
CompoundLiteral {
ty: Box<TypeName>,
init: Vec<InitItem>,
},
StmtExpr(Box<Block>),
TypesCompatible {
lhs: Box<TypeName>,
rhs: Box<TypeName>,
},
ChooseExpr {
cond: Box<Expr>,
then_expr: Box<Expr>,
else_expr: Box<Expr>,
},
ComplexPart {
real: bool,
operand: Box<Expr>,
},
Error,
}Expand description
The shape of an Expr.
Variants§
Ident(Ident)
An identifier reference.
Int(IntLit)
An integer constant.
Float(FloatLit)
A floating constant.
Char(CharLit)
A character constant.
Str(StrLit)
A string literal, after adjacent-literal concatenation.
Unary
A unary operator application.
Binary
A binary operator application.
Assign
An assignment; op is None for = and Some(op) for op=.
Fields
Conditional
cond ? then_expr : else_expr, and GNU’s cond ?: else_expr.
Fields
Comma
lhs, rhs
Call
callee(args…)
Member
base.field or base->field
Fields
Index
base[index]
PostIncDec
x++ / x--
PreIncDec
++x / --x
Cast
(T)expr
LabelAddr(Ident)
GNU’s &&label: the address of a label of the enclosing function, of
type void *, which goto * jumps to.
SizeofExpr(Box<Expr>)
sizeof expr
SizeofType(Box<TypeName>)
sizeof(T)
AlignofExpr(Box<Expr>)
_Alignof expr — a GNU extension C never standardised.
AlignofType(Box<TypeName>)
_Alignof(T) / alignof(T) — C11.
Generic
_Generic(controlling, T: value, …) — C11.
Fields
assocs: Vec<GenericAssoc>The associations, in the order written.
Bool(bool)
true / false — C23.
Nullptr
nullptr — C23.
VaArg
va_arg(ap, T).
It looks like a call but takes a type name, so — like sizeof — the
parser has to know about it.
Fields
OffsetOf
__builtin_offsetof(T, member), which <stddef.h>’s offsetof is.
Another one that takes a type name where an expression would go.
Fields
path: Vec<Designator>The steps after it — offsetof(struct S, a.b) and
offsetof(struct S, a[2].b) are both member designators
(C99 7.17p3). A Designator::Range never appears here.
CompoundLiteral
(T){ … } — a C99 compound literal.
StmtExpr(Box<Block>)
({ … }) — GNU’s statement expression, whose value is the value of the
last expression statement in the block.
TypesCompatible
__builtin_types_compatible_p(T1, T2), an integer constant.
ChooseExpr
__builtin_choose_expr(c, a, b).
Only the operand the constant condition picks is type checked, which is the whole point of the builtin.
Fields
ComplexPart
__real__ e / __imag__ e, which need complex arithmetic.
Error
Produced by error recovery.