Shared Rust kernels
eval/refops
All modules · quoted at commit 9e1884369a67 of DnaCalc/DnaCalc. Comments are the source's own.
reference · 8 lines · calc-fml/src/eval/refops.rs on GitHub/// An operand of a reference operator: its reference, or the error value that is the result.
fn reference(operand: &CalcValue) -> Result<&ReferenceLike, CalcValue> {
match operand.core_ref() {
CoreRef::Reference(reference) => Ok(reference),
CoreRef::Error(_) if operand.callable_value().is_none() => Err(operand.clone()),
_ => Err(CalcValue::error(WorksheetErrorCode::Value)),
}
}
Used by 4 functions.
references · 17 lines · calc-fml/src/eval/refops.rs on GitHub/// The references of `operands`, all on one sheet, or the value that is the result.
fn references(operands: &[CalcValue]) -> Result<Vec<&ReferenceLike>, CalcValue> {
let mut out = Vec::with_capacity(operands.len());
for operand in operands {
out.push(reference(operand)?);
}
let sheet = out[0].sheet();
// A 3-D reference meets none of the operators (Excel 16.0, 2026-10-23:
// `=SUM(Ja:Ma!A1:A2 Ja:Ma!A1)` is #VALUE!).
if out
.iter()
.any(|reference| reference.sheet() != sheet || reference.spans_sheets())
{
return Err(CalcValue::error(WorksheetErrorCode::Value));
}
Ok(out)
}
Used by 3 functions.
bounds · 8 lines · calc-fml/src/eval/refops.rs on GitHubfn bounds(area: GridArea) -> (u32, u32, u32, u32) {
(
area.first().row(),
area.first().column(),
area.last().row(),
area.last().column(),
)
}
Used by 3 functions.
area · 9 lines · calc-fml/src/eval/refops.rs on GitHub/// The area of `like`'s sheet between the given rows and columns, which lie on the grid.
fn area(like: GridArea, top: u32, left: u32, bottom: u32, right: u32) -> GridArea {
let sheet = like.sheet();
GridArea::new(
CellKey::new(sheet, top, left).expect("a corner of areas on the grid"),
CellKey::new(sheet, bottom, right).expect("a corner of areas on the grid"),
)
.expect("both corners lie on one sheet")
}
Used by 3 functions.