Skip to main content

Crate flow_span

Crate flow_span 

Source
Expand description

Source positions, source files, and interned identifiers.

Five vocabularies that every later phase speaks, and nothing else:

  • Idx and IndexVec, the typed indices and index-keyed vectors every phase artifact stores its nodes in; the index module says why.
  • Span, a byte extent that carries its FileId. Everything a diagnostic points at is one of these, and because the file travels inside the span, one SourceMap reads back a span from any file of a compilation.
  • SourceMap, the append-only owner of the text those spans index into, plus the line index a caret needs.
  • Symbol and Interner, so a name is a four-byte integer comparison rather than a string comparison.
  • RunId, TaskPath, CallRef and Moment, the places in a run, as a span is a place in source. The place module holds the one grammar they are written in, so a frame, a history, a diagnostic and a command line all read and write them the same way.

§What is deliberately absent

No file loading. This crate never reads a path. Turning a path into text is an operating-system act, and one crate in this workspace owns those.

No Symbol serialization. A symbol index means nothing without the interner that produced it; a serialized one would be a number that reads like a name. Code that persists an identifier persists its text.

No reserved-word table. flow-lexer owns the reserved words and turns those spellings into distinct token kinds before any interning happens.

Macros§

newtype_index
Mints one or more index types.
spelled
Declares an enum’s cases once, and tables that give each case one value.

Structs§

CallRef
A Tool call’s id (history.md, Identity): the segment it was first recorded in, its task and the task’s count of Tool calls, written root/1#4 in the first segment and p1:root/1#4 in the second.
FileId
One source file within a SourceMap.
IndexVec
A vector keyed by I instead of by usize.
Interner
The owner of every Symbol.
LineCol
A one-based line and column, for rendering only.
Moment
A place in one task’s evaluation (runs.md, Places in a run): the segment whose program is evaluating, the task, the count of its calls whose answers were handed to it, and the steps it has taken since, written root/2#4+17 or p1:root#4+5.
ParsePlaceError
Text that is not the place it was read as, as it was given.
RunId
A run’s id: 128 bits, written as exactly 32 lowercase hexadecimal digits. Text becomes one only through RunId::parse, so an id read from a history, a frame or a command line that has any other form is refused where it is read. Ids order as their written digits do. It keeps its digits beside its bits, so it is Copy and lends them as text without allocating.
SourceFile
One source file, with the line index a caret needs.
SourceMap
Every source file one compilation reads.
Span
A half-open byte range [lo, lo + len) within one source file.
Symbol
An interned identifier.
TaskPath
Which task a call came from: its parent’s path plus the parent’s count of spawns at the moment it was spawned (history.md, Identity).

Enums§

PlaceKind
What a text was read as.
SourceName
Where a source file came from.

Constants§

MAX_INDEX
The largest value a generated index may hold.

Traits§

Idx
A dense, positional name for one element of one domain.

Functions§

widen
Widens a u32 offset, index or count to usize.