pub struct Eval<'a> { /* private fields */ }Expand description
The constant folder, over one typed tree.
Implementations§
Source§impl<'a> Eval<'a>
impl<'a> Eval<'a>
Sourcepub fn new(
tast: &'a Tast,
types: &'a Types,
target: &'a TargetInfo,
names: &'a Interner,
) -> Eval<'a>
pub fn new( tast: &'a Tast, types: &'a Types, target: &'a TargetInfo, names: &'a Interner, ) -> Eval<'a>
A folder over a tree, the types it points into, and the target it is being compiled for.
Sourcepub fn constant(&mut self, expr: ExprId) -> Result<Const, NotConstant>
pub fn constant(&mut self, expr: ExprId) -> Result<Const, NotConstant>
The value of an expression.
§Errors
NotConstant when the expression is not one, which is an ordinary answer rather than a
failure: whether it is a diagnostic depends on where the expression was.
Sourcepub fn integer(&mut self, expr: ExprId) -> Result<i128, NotConstant>
pub fn integer(&mut self, expr: ExprId) -> Result<i128, NotConstant>
The value of an expression that has to be an integer constant expression, 6.6p6.
The type has to be an integer type as well as the value being one, which is what rejects
enum { a = nullptr };: the value folds to zero and the expression is still not an
integer constant expression.
§Errors
NotConstant when the expression is not one, or is a constant of some other type.
Sourcepub fn finish(self) -> Vec<Diagnostic>
pub fn finish(self) -> Vec<Diagnostic>
What the folding reported, in the order it was found.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Eval<'a>
impl<'a> RefUnwindSafe for Eval<'a>
impl<'a> Send for Eval<'a>
impl<'a> Sync for Eval<'a>
impl<'a> Unpin for Eval<'a>
impl<'a> UnsafeUnpin for Eval<'a>
impl<'a> UnwindSafe for Eval<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more