pub struct Expr {
pub kind: ExprKind,
pub ty: Ty,
pub bits: Option<u32>,
pub range: SourceRange,
}Expand description
A typed expression.
Fields§
§kind: ExprKindWhat the expression computes.
ty: TyThe type of its value.
bits: Option<u32>The number of bits the value is reduced to, when that is narrower than
Expr::ty.
A bit-field wider than int keeps its declared type through the
integer promotions (6.3.1.1p2 has nothing to say about it), but its
value still ranges over the declared width only, and C99 6.7.2.1p10
makes that width the type the arithmetic happens in: unsigned long long b : 40 multiplies, adds and shifts in forty bits, exactly as an
unsigned int does in thirty-two. Nothing else in the type model can
say that, so the width rides along on the expression and code
generation reduces the result to it.
range: SourceRangeWhere it was written.
Implementations§
Source§impl Expr
impl Expr
Sourcepub fn new(kind: ExprKind, ty: Ty, range: SourceRange) -> Self
pub fn new(kind: ExprKind, ty: Ty, range: SourceRange) -> Self
Builds an expression.
Sourcepub fn narrowed(self, bits: Option<u32>) -> Self
pub fn narrowed(self, bits: Option<u32>) -> Self
The same expression, computed in bits bits; see Expr::bits.
Sourcepub fn int(value: i128, ty: Ty, range: SourceRange) -> Self
pub fn int(value: i128, ty: Ty, range: SourceRange) -> Self
An integer constant of type ty.