Skip to main content

Eval

Struct Eval 

Source
pub struct Eval<'a> { /* private fields */ }
Expand description

The constant folder, over one typed tree.

Implementations§

Source§

impl<'a> Eval<'a>

Source

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.

Source

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.

Source

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.

Source

pub fn finish(self) -> Vec<Diagnostic>

What the folding reported, in the order it was found.

Trait Implementations§

Source§

impl<'a> Debug for Eval<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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> 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, 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, <T as TryFrom<U>>::Error>

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.