Module source_map
Available on crate features
__ecma
and __utils
only.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§
- Archived
Byte Pos - An archived
BytePos
- Archived
Char Pos - An archived
CharPos
- Archived
Distinct Sources - An archived
DistinctSources
- Archived
File Pos - An archived
FilePos
- Archived
Line Info - An archived
LineInfo
- Archived
Malformed Source MapPositions - An archived
MalformedSourceMapPositions
- Archived
Multi Byte Char - An archived
MultiByteChar
- Archived
Multi Span - An archived
MultiSpan
- Archived
Partial File Lines - An archived
PartialFileLines
- Archived
Partial Loc - An archived
PartialLoc
- Archived
Primary Span Label - An archived
PrimarySpanLabel
- Archived
Source File - An archived
SourceFile
- Archived
Source File Analysis - An archived
SourceFileAnalysis
- Archived
Source File AndByte Pos - An archived
SourceFileAndBytePos
- Archived
Span - An archived
Span
- BytePos
- A byte offset. Keep this small (currently 32-bits), as AST contains a lot of them.
- Byte
PosResolver - The resolver for an archived
BytePos
- 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.
- Char
PosResolver - The resolver for an archived
CharPos
- Default
Source MapGen Config - Distinct
Sources - Distinct
Sources Resolver - The resolver for an archived
DistinctSources
- Encode
Path Buf - A wrapper that attempts to convert a type to and from UTF-8.
- Encode
Url - A wrapper that attempts to convert a Url to and from String.
- File
Lines - A struct to represent lines of a source file.
- File
Path Mapping - FilePos
- File
PosResolver - The resolver for an archived
FilePos
- Globals
- LineCol
- Used to create a
.map
file. - Line
Info - Line
Info Resolver - The resolver for an archived
LineInfo
- 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 - Malformed
Source MapPositions Resolver - The resolver for an archived
MalformedSourceMapPositions
- 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
Byte Char Resolver - The resolver for an archived
MultiByteChar
- Multi
Span - A collection of spans. Spans have two orthogonal attributes:
- Multi
Span Resolver - The resolver for an archived
MultiSpan
- 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
File Lines Resolver - The resolver for an archived
PartialFileLines
- 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. - Partial
LocResolver - The resolver for an archived
PartialLoc
- Primary
Span Label - Primary
Span Label Resolver - The resolver for an archived
PrimarySpanLabel
- 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 Analysis Resolver - The resolver for an archived
SourceFileAnalysis
- Source
File AndByte Pos - Source
File AndByte PosResolver - The resolver for an archived
SourceFileAndBytePos
- Source
File AndLine - Source
File Resolver - The resolver for an archived
SourceFile
- Source
Map - The interner for spans.
- Span
- Spans represent a region of code, used for error reporting.
- Span
Label - Span
Resolver - The resolver for an archived
Span
- Stable
Source File Id - Syntax
Context - A SyntaxContext represents a chain of macro expansions (represented by marks).
Enums§
- Archived
File Name - An archived
FileName
- Archived
NonNarrow Char - An archived
NonNarrowChar
- Archived
Source MapLookup Error - An archived
SourceMapLookupError
- Archived
Span Lines Error - An archived
SpanLinesError
- Archived
Span Snippet Error - An archived
SpanSnippetError
- File
Name - File
Name Resolver - The resolver for an archived
FileName
- NonNarrow
Char - Identifies an offset of a non-narrow character in a SourceFile
- NonNarrow
Char Resolver - The resolver for an archived
NonNarrowChar
- Source
MapLookup Error - An error type for looking up source maps.
- Source
MapLookup Error Resolver - The resolver for an archived
SourceMapLookupError
- Span
Lines Error - Span
Lines Error Resolver - The resolver for an archived
SpanLinesError
- Span
Snippet Error - Span
Snippet Error Resolver - The resolver for an archived
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§
- File
Loader - An abstraction over the fs operations used by the Parser.
- Files
- Small
Pos - Source
MapGen Config