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§

ArchivedBytePos
An archived BytePos
ArchivedCharPos
An archived CharPos
ArchivedDistinctSources
An archived DistinctSources
ArchivedFilePos
An archived FilePos
ArchivedLineInfo
An archived LineInfo
ArchivedMalformedSourceMapPositions
An archived MalformedSourceMapPositions
ArchivedMultiByteChar
An archived MultiByteChar
ArchivedMultiSpan
An archived MultiSpan
ArchivedPartialFileLines
An archived PartialFileLines
ArchivedPartialLoc
An archived PartialLoc
ArchivedPrimarySpanLabel
An archived PrimarySpanLabel
ArchivedSourceFile
An archived SourceFile
ArchivedSourceFileAnalysis
An archived SourceFileAnalysis
ArchivedSourceFileAndBytePos
An archived SourceFileAndBytePos
ArchivedSpan
An archived Span
BytePos
A byte offset. Keep this small (currently 32-bits), as AST contains a lot of them.
BytePosResolver
The resolver for an archived BytePos
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.
CharPosResolver
The resolver for an archived CharPos
DefaultSourceMapGenConfig
DistinctSources
DistinctSourcesResolver
The resolver for an archived DistinctSources
EncodePathBuf
A wrapper that attempts to convert a type to and from UTF-8.
EncodeUrl
A wrapper that attempts to convert a Url to and from String.
FileLines
A struct to represent lines of a source file.
FilePathMapping
FilePos
FilePosResolver
The resolver for an archived FilePos
Globals
LineCol
Used to create a .map file.
LineInfo
LineInfoResolver
The resolver for an archived 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
MalformedSourceMapPositionsResolver
The resolver for an archived 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
MultiByteCharResolver
The resolver for an archived MultiByteChar
MultiSpan
A collection of spans. Spans have two orthogonal attributes:
MultiSpanResolver
The resolver for an archived MultiSpan
PartialFileLines
A struct to exchange FileLines with omitting SourceFile as needed. This is internal struct between plugins to the host, not a public interface.
PartialFileLinesResolver
The resolver for an archived PartialFileLines
PartialLoc
A struct to exchange Loc with omitting SourceFile as needed. This is internal struct between plugins to the host, not a public interface.
PartialLocResolver
The resolver for an archived PartialLoc
PrimarySpanLabel
PrimarySpanLabelResolver
The resolver for an archived PrimarySpanLabel
RealFileLoader
A FileLoader that uses std::fs to load real files.
SourceFile
A single source in the SourceMap.
SourceFileAnalysis
SourceFileAnalysisResolver
The resolver for an archived SourceFileAnalysis
SourceFileAndBytePos
SourceFileAndBytePosResolver
The resolver for an archived SourceFileAndBytePos
SourceFileAndLine
SourceFileResolver
The resolver for an archived SourceFile
SourceMap
The interner for spans.
Span
Spans represent a region of code, used for error reporting.
SpanLabel
SpanResolver
The resolver for an archived Span
StableSourceFileId
SyntaxContext
A SyntaxContext represents a chain of macro expansions (represented by marks).

Enums§

ArchivedFileName
An archived FileName
ArchivedNonNarrowChar
An archived NonNarrowChar
ArchivedSourceMapLookupError
An archived SourceMapLookupError
ArchivedSpanLinesError
An archived SpanLinesError
ArchivedSpanSnippetError
An archived SpanSnippetError
FileName
FileNameResolver
The resolver for an archived FileName
NonNarrowChar
Identifies an offset of a non-narrow character in a SourceFile
NonNarrowCharResolver
The resolver for an archived NonNarrowChar
SourceMapLookupError
An error type for looking up source maps.
SourceMapLookupErrorResolver
The resolver for an archived SourceMapLookupError
SpanLinesError
SpanLinesErrorResolver
The resolver for an archived SpanLinesError
SpanSnippetError
SpanSnippetErrorResolver
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§

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

Functions§

build_source_map

Type Aliases§

FileLinesResult
PartialFileLinesResult