pub struct ConstantEvaluator<'gcx> {
pub gcx: Gcx<'gcx>,
/* private fields */
}Expand description
Evaluates Solidity constant expressions.
This supports the source-level constants needed by semantic analysis and codegen’s HIR lowering pre-folds. It does not evaluate runtime-dependent expressions such as function calls or memory allocation.
Fields§
§gcx: Gcx<'gcx>Implementations§
Source§impl<'gcx> ConstantEvaluator<'gcx>
impl<'gcx> ConstantEvaluator<'gcx>
Sourcepub fn new(gcx: Gcx<'gcx>) -> ConstantEvaluator<'gcx>
pub fn new(gcx: Gcx<'gcx>) -> ConstantEvaluator<'gcx>
Creates a new constant evaluator.
Sourcepub fn eval(&mut self, expr: &Expr<'_>) -> Result<IntScalar, ErrorGuaranteed>
pub fn eval(&mut self, expr: &Expr<'_>) -> Result<IntScalar, ErrorGuaranteed>
Evaluates the given expression, emitting an error diagnostic if it fails.
Sourcepub fn try_eval(&mut self, expr: &Expr<'_>) -> Result<IntScalar, EvalError>
pub fn try_eval(&mut self, expr: &Expr<'_>) -> Result<IntScalar, EvalError>
Evaluates the given expression, returning an error if it fails.
Sourcepub fn eval_value(
&mut self,
expr: &Expr<'_>,
) -> Result<ConstValue, ErrorGuaranteed>
pub fn eval_value( &mut self, expr: &Expr<'_>, ) -> Result<ConstValue, ErrorGuaranteed>
Evaluates the given expression to a typed constant value, emitting an error diagnostic if it fails.
Sourcepub fn try_eval_value(
&mut self,
expr: &Expr<'_>,
) -> Result<ConstValue, EvalError>
pub fn try_eval_value( &mut self, expr: &Expr<'_>, ) -> Result<ConstValue, EvalError>
Evaluates the given expression to a typed constant value, returning an error if it fails.
Sourcepub fn emit_eval_error(
&self,
expr: &Expr<'_>,
err: EvalError,
) -> ErrorGuaranteed
pub fn emit_eval_error( &self, expr: &Expr<'_>, err: EvalError, ) -> ErrorGuaranteed
Emits a diagnostic for the given evaluation error.
Auto Trait Implementations§
impl<'gcx> !RefUnwindSafe for ConstantEvaluator<'gcx>
impl<'gcx> !UnwindSafe for ConstantEvaluator<'gcx>
impl<'gcx> Freeze for ConstantEvaluator<'gcx>
impl<'gcx> Send for ConstantEvaluator<'gcx>
impl<'gcx> Sync for ConstantEvaluator<'gcx>
impl<'gcx> Unpin for ConstantEvaluator<'gcx>
impl<'gcx> UnsafeUnpin for ConstantEvaluator<'gcx>
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
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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> ⓘ
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 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> ⓘ
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