Expand description
The SourceMap tracks all the source code used within a single crate.
The mapping from integer byte positions to the original source code location
is stored in spans
.
Each bit of source parsed during crate parsing (typically files, in-memory
strings, or various bits of macro expansion) cover a continuous range of
bytes in the SourceMap and are represented by SourceFiles. Byte positions
are stored in spans
and used pervasively in the compiler. They are
absolute positions within the SourceMap, which upon request can be converted
to line and column information, source code snippets, etc.
Modules§
- hygiene
- Machinery for hygienic macros, inspired by the
MTWT[1]
paper.
Structs§
- BytePos
- A byte offset. Keep this small (currently 32-bits), as AST contains a lot of them.
- Byte
ToChar PosState - Stores the state of the last conversion between BytePos and CharPos.
- CharPos
- A character offset. Because of multibyte utf8 characters, a byte offset is not equivalent to a character offset. The SourceMap will convert BytePos values to CharPos values as necessary.
- Default
Source MapGen Config - Distinct
Sources - File
Lines - A struct to represent lines of a source file.
- File
Path Mapping - FilePos
- Globals
- LineCol
- Used to create a
.map
file. - Line
Info - Loc
- A source code location used for error reporting.
- LocWith
Opt - A source code location used as the result of
lookup_char_pos_adj
- Malformed
Source MapPositions - Mark
- A mark is a unique id associated with a macro expansion.
- Multi
Byte Char - Identifies an offset of a multi-byte character in a SourceFile
- Multi
Span - A collection of spans. Spans have two orthogonal attributes:
- Partial
File Lines - A struct to exchange
FileLines
with omitting SourceFile as needed. This is internal struct between plugins to the host, not a public interface. - Partial
Loc - A struct to exchange
Loc
with omitting SourceFile as needed. This is internal struct between plugins to the host, not a public interface. - Primary
Span Label - Real
File Loader - A FileLoader that uses std::fs to load real files.
- Source
File - A single source in the SourceMap.
- Source
File Analysis - Source
File AndByte Pos - Source
File AndLine - Source
Map - The interner for spans.
- Span
- Spans represent a region of code, used for error reporting.
- Span
Label - Stable
Source File Id - Syntax
Context - A SyntaxContext represents a chain of macro expansions (represented by marks).
Enums§
- File
Name - NonNarrow
Char - Identifies an offset of a non-narrow character in a SourceFile
- Source
MapLookup Error - An error type for looking up source maps.
- Span
Lines Error - Span
Snippet Error
Constants§
- DUMMY_
SP - Dummy span, both position and length are zero, syntax context is zero as well.
- NO_
EXPANSION - PLACEHOLDER_
SP - Used for some special cases. e.g. mark the generated AST.
- PURE_SP
- PURE span, will emit
/* #__PURE__ */
comment in codegen.
Statics§
- GLOBALS
- Storage for span hygiene data.
Traits§
- File
Loader - An abstraction over the fs operations used by the Parser.
- Small
Pos - Source
MapGen Config