ScalarExpr

Enum ScalarExpr 

Source
pub enum ScalarExpr {
    Const(Span<u64>),
    SymbolAccess(SymbolAccess),
    BoundedSymbolAccess(BoundedSymbolAccess),
    Binary(BinaryExpr),
    Call(Call),
    Let(Box<Let>),
    BusOperation(BusOperation),
    Null(Span<()>),
    Unconstrained(Span<()>),
}
Expand description

Scalar expressions are expressions which evaluate to a single scalar value, i.e. they have no vector or matrix elements. Only scalar expressions are valid in a constraint statement.

Variants§

§

Const(Span<u64>)

A constant scalar value, i.e. integer

§

SymbolAccess(SymbolAccess)

A reference to a named value

NOTE: Symbol accesses in a ScalarExpr context must produce scalar values.

§

BoundedSymbolAccess(BoundedSymbolAccess)

A reference to a trace column on a particular boundary of the trace, which must produce a scalar

NOTE: This is only a valid expression in boundary constraints

§

Binary(BinaryExpr)

A binary operator over scalar values

§

Call(Call)

A call to a pure function or evaluator

NOTE: This is only a valid scalar expression when one of the following hold:

  1. The call is the top-level expression of a constraint, and is to an evaluator function
  2. The call is not the top-level expression of a constraint, and is to a pure function that produces a scalar value type.

If neither of the above are true, the call is invalid in a ScalarExpr context

§

Let(Box<Let>)

An expression that binds a local variable to a temporary value during evaluation.

NOTE: This is only a valid scalar expression during the inlining phase, when we expand binary expressions or function calls to a block of statements, and only when the result of evaluating the let produces a valid scalar expression.

§

BusOperation(BusOperation)

A bus operation

§

Null(Span<()>)

An empty bus

§

Unconstrained(Span<()>)

An unconstrained bus

Implementations§

Source§

impl ScalarExpr

Source

pub fn is_constant(&self) -> bool

Returns true if this is a constant value

Source

pub fn has_block_like_expansion(&self) -> bool

Returns true if this scalar expression could expand to a block, e.g. due to a function call being inlined.

Source

pub fn ty(&self) -> Result<Option<Type>, SourceSpan>

Returns the resolved type of this expression, if known.

Returns Ok(Some) if the type could be resolved without conflict. Returns Ok(None) if type information was missing. Returns Err if the type could not be resolved due to a conflict, with a span covering the source of the conflict.

Trait Implementations§

Source§

impl Clone for ScalarExpr

Source§

fn clone(&self) -> ScalarExpr

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScalarExpr

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Display for ScalarExpr

Source§

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

Formats the value using the given formatter. Read more
Source§

impl From<u64> for ScalarExpr

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for ScalarExpr

Source§

fn eq(&self, other: &ScalarExpr) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Spanned for ScalarExpr

Source§

impl TryFrom<Expr> for ScalarExpr

Source§

type Error = InvalidExprError

The type returned in the event of a conversion error.
Source§

fn try_from(expr: Expr) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ScalarExpr> for Expr

Source§

type Error = InvalidExprError

The type returned in the event of a conversion error.
Source§

fn try_from(expr: ScalarExpr) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<ScalarExpr> for Statement

Source§

type Error = ()

The type returned in the event of a conversion error.
Source§

fn try_from(expr: ScalarExpr) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<Statement> for ScalarExpr

Source§

type Error = InvalidExprError

The type returned in the event of a conversion error.
Source§

fn try_from(stmt: Statement) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl Eq for ScalarExpr

Source§

impl StructuralPartialEq for ScalarExpr

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.