Skip to main content

Module addr

Module addr 

Source
Expand description

Vertex address space.

The graph holds two disjoint kinds of vertex.

  • Grid vertices — cells, formulas, empty placeholders. Their address is their identity: a (SheetId, row, col) position that users can see, reference, and shift with structural edits.
  • Symbol vertices — defined names, tables, and external sources. They are identified by name and have no position at all.

Before this module existed, both kinds shared one address space: symbols were handed fabricated (row, col) coordinates on a real user-visible sheet, and the only thing that kept them from behaving like cells was their deliberate absence from cell_to_vertex — a convention any code path could break. Issues #302 and #304 are two paths that broke it.

GridAddr and SymbolAddr make the distinction a type. VertexAddr is the tagged union actually stored in the vertex store and the edge coordinate arrays. Structures that are keyed by grid position take a GridAddr, which a symbol cannot produce, so inserting a symbol into a grid structure is a compile error rather than a runtime guard.

§Representation

VertexAddr is exactly 8 bytes — the same width as the AbsCoord it replaces. The coordinate encoding saturates rows (20 bits) and columns (14 bits) at Excel’s limits but leaves the top 20 bits (0xFFFFF000_00000000) reserved and always zero for a real position, with u64::MAX already reserved as the invalid sentinel. Symbols live in that niche: bit 63 set with the rest of the reserved field clear. The edge coordinate arrays are Vec parallel to adjacency, so widening them to Option<AbsCoord> (16 bytes) would double hot memory; using the existing niche keeps the address free.

Structs§

GridAddr
A real grid position.
SymbolAddr
A dense symbol identity.
VertexAddr
The address of a vertex: a grid position or a symbol identity, in 8 bytes.