Module source_map

Source
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.
ByteToCharPosState
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.
DefaultSourceMapGenConfig
DistinctSources
FileLines
A struct to represent lines of a source file.
FilePathMapping
FilePos
Globals
LineCol
Used to create a .map file.
LineInfo
Loc
A source code location used for error reporting.
LocWithOpt
A source code location used as the result of lookup_char_pos_adj
MalformedSourceMapPositions
Mark
A mark is a unique id associated with a macro expansion.
MultiByteChar
Identifies an offset of a multi-byte character in a SourceFile
MultiSpan
A collection of spans. Spans have two orthogonal attributes:
PartialFileLines
A struct to exchange FileLines with omitting SourceFile as needed. This is internal struct between plugins to the host, not a public interface.
PartialLoc
A struct to exchange Loc with omitting SourceFile as needed. This is internal struct between plugins to the host, not a public interface.
PrimarySpanLabel
RealFileLoader
A FileLoader that uses std::fs to load real files.
SourceFile
A single source in the SourceMap.
SourceFileAnalysis
SourceFileAndBytePos
SourceFileAndLine
SourceMap
The interner for spans.
Span
Spans represent a region of code, used for error reporting.
SpanLabel
StableSourceFileId
SyntaxContext
A SyntaxContext represents a chain of macro expansions (represented by marks).

Enums§

FileName
NonNarrowChar
Identifies an offset of a non-narrow character in a SourceFile
SourceMapLookupError
An error type for looking up source maps.
SpanLinesError
SpanSnippetError

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§

FileLoader
An abstraction over the fs operations used by the Parser.
SmallPos
SourceMapGenConfig

Type Aliases§

FileLinesResult