pub struct Evaluator<'a> { /* private fields */ }Expand description
Stateful evaluator that tracks recursion depth and circular references.
Unqualified references resolve against the evaluator’s current sheet. That is the provider’s sheet for the top-level formula and the owning sheet of any referenced formula cell while that cell’s formula is being evaluated.
Implementations§
Source§impl<'a> Evaluator<'a>
impl<'a> Evaluator<'a>
Sourcepub fn new(provider: &'a dyn CellDataProvider) -> Self
pub fn new(provider: &'a dyn CellDataProvider) -> Self
Create a new evaluator backed by the given data provider.
Sourcepub fn with_budget(
provider: &'a dyn CellDataProvider,
budget: FormulaBudget,
) -> Self
pub fn with_budget( provider: &'a dyn CellDataProvider, budget: FormulaBudget, ) -> Self
Create an evaluator that shares an existing calculation budget.
Sourcepub fn set_position(&mut self, col: u32, row: u32)
pub fn set_position(&mut self, col: u32, row: u32)
Set the 1-based (column, row) coordinate of the formula being evaluated.
Sourcepub fn position(&self) -> (u32, u32)
pub fn position(&self) -> (u32, u32)
Return the 1-based (column, row) coordinate of the formula being evaluated.
Sourcepub fn eval_arg(&mut self, args: &[Expr], index: usize) -> Result<CellValue>
pub fn eval_arg(&mut self, args: &[Expr], index: usize) -> Result<CellValue>
Evaluate a single argument expression at index, returning an error if
the index is out of bounds.
Sourcepub fn collect_numbers(&mut self, args: &[Expr]) -> Result<Vec<f64>>
pub fn collect_numbers(&mut self, args: &[Expr]) -> Result<Vec<f64>>
Collect numeric values for aggregate functions such as SUM or AVERAGE.
Reference arguments (ranges and single-cell references) contribute only
numeric cells (see reference_number); empty, boolean, and text cells
are skipped, and an error cell aborts with that error. Other arguments
are direct values and use coerce_to_number, so TRUE counts as 1
and numeric text is parsed.
Sourcepub fn flatten_args_to_values(
&mut self,
args: &[Expr],
) -> Result<Vec<CellValue>>
pub fn flatten_args_to_values( &mut self, args: &[Expr], ) -> Result<Vec<CellValue>>
Flatten all arguments into a Vec of CellValues, expanding ranges.
Sourcepub fn expand_range(
&mut self,
start: &CellReference,
end: &CellReference,
) -> Result<Vec<CellValue>>
pub fn expand_range( &mut self, start: &CellReference, end: &CellReference, ) -> Result<Vec<CellValue>>
Expand a rectangular cell range into individual CellValues (row-major).
Sourcepub fn current_sheet(&self) -> &str
pub fn current_sheet(&self) -> &str
Return the sheet that unqualified references currently resolve against.
Sourcepub fn charge_match_work(&self, amount: u64) -> Result<()>
pub fn charge_match_work(&self, amount: u64) -> Result<()>
Charge wildcard or criteria matching work before performing it.
Sourcepub fn charge_evaluation_work(&self, amount: u64) -> Result<()>
pub fn charge_evaluation_work(&self, amount: u64) -> Result<()>
Charge analytically known loop or helper work before executing it.
Sourcepub fn check_output_bytes(&self, amount: u64) -> Result<()>
pub fn check_output_bytes(&self, amount: u64) -> Result<()>
Check analytically known string output before reserving it.