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:
- The call is the top-level expression of a constraint, and is to an evaluator function
- 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
impl ScalarExpr
Sourcepub fn is_constant(&self) -> bool
pub fn is_constant(&self) -> bool
Returns true if this is a constant value
Sourcepub fn has_block_like_expansion(&self) -> bool
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.
Sourcepub fn ty(&self) -> Result<Option<Type>, SourceSpan>
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
impl Clone for ScalarExpr
Source§fn clone(&self) -> ScalarExpr
fn clone(&self) -> ScalarExpr
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ScalarExpr
impl Debug for ScalarExpr
Source§impl Display for ScalarExpr
impl Display for ScalarExpr
Source§impl From<u64> for ScalarExpr
impl From<u64> for ScalarExpr
Source§impl PartialEq for ScalarExpr
impl PartialEq for ScalarExpr
Source§impl Spanned for ScalarExpr
impl Spanned for ScalarExpr
fn span(&self) -> SourceSpan
Source§impl TryFrom<Expr> for ScalarExpr
impl TryFrom<Expr> for ScalarExpr
Source§impl TryFrom<ScalarExpr> for Expr
impl TryFrom<ScalarExpr> for Expr
Source§type Error = InvalidExprError
type Error = InvalidExprError
Source§impl TryFrom<ScalarExpr> for Statement
impl TryFrom<ScalarExpr> for Statement
Source§impl TryFrom<Statement> for ScalarExpr
impl TryFrom<Statement> for ScalarExpr
impl Eq for ScalarExpr
impl StructuralPartialEq for ScalarExpr
Auto Trait Implementations§
impl Freeze for ScalarExpr
impl RefUnwindSafe for ScalarExpr
impl Send for ScalarExpr
impl Sync for ScalarExpr
impl Unpin for ScalarExpr
impl UnwindSafe for ScalarExpr
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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