Expand description
Source positions, source files, and interned identifiers.
Five vocabularies that every later phase speaks, and nothing else:
IdxandIndexVec, the typed indices and index-keyed vectors every phase artifact stores its nodes in; theindexmodule says why.Span, a byte extent that carries itsFileId. Everything a diagnostic points at is one of these, and because the file travels inside the span, oneSourceMapreads 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.SymbolandInterner, so a name is a four-byte integer comparison rather than a string comparison.RunId,TaskPath,CallRefandMoment, the places in a run, as a span is a place in source. Theplacemodule 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, writtenroot/1#4in the first segment andp1:root/1#4in the second. - FileId
- One source file within a
SourceMap. - Index
Vec - A vector keyed by
Iinstead of byusize. - 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, writtenroot/2#4+17orp1:root#4+5. - Parse
Place Error - 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 isCopyand lends them as text without allocating. - Source
File - One source file, with the line index a caret needs.
- Source
Map - Every source file one compilation reads.
- Span
- A half-open byte range
[lo, lo + len)within one source file. - Symbol
- An interned identifier.
- Task
Path - 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§
- Place
Kind - What a text was read as.
- Source
Name - 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
u32offset, index or count tousize.