Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion spec.emu
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,9 @@
1. <ins>Let _sources_ be DecodeSourceMapSources(_baseURL_, _sourceRootField_, _sourcesField_, _sourcesContentField_, _ignoreListField_, _scopesAndRanges_.[[Scopes]]).</ins>
1. Let _mappings_ be DecodeMappings(_mappingsField_, _namesField_, _sources_).
1. [declared="a,b"] Sort _mappings_ in ascending order, with a Decoded Mapping Record _a_ being less than a Decoded Mapping Record _b_ if ComparePositions(_a_.[[GeneratedPosition]], _b_.[[GeneratedPosition]]) is ~lesser~.
1. <ins>Return the Decoded Source Map Record { [[File]]: _fileField_, [[Sources]]: _sources_, [[Mappings]]: _mappings_, [[Ranges]]: _scopesAndRanges_.[[Ranges]] }.</ins>
1. <ins>Let _sourceMap_ be the Decoded Source Map Record { [[File]]: _fileField_, [[Sources]]: _sources_, [[Mappings]]: _mappings_, [[Ranges]]: _scopesAndRanges_.[[Ranges]] }.</ins>
1. <ins>If MappingsConsistentWithScopes(_sourceMap_) is *false*, optionally report an error.</ins>
1. <ins>Return _sourceMap_.</ins>
</emu-alg>

<emu-clause id="sec-GetOptionalString" type="abstract operation">
Expand Down Expand Up @@ -2232,6 +2234,43 @@
</emu-clause>
</emu-clause>
</emu-clause>

<emu-clause id="sec-mappings-relationship">
<h1>Relationship with mappings</h1>
<p>The Decoded Mapping Records of a Decoded Source Map Record must be consistent with respect to the Generated Range Records and Original Scope Records of the same Decoded Source Map Record. Informally, mappings and scopes information must not disagree on how they map from generated code to original code.</p>

<emu-clause id="op-mappings-consistent-with-scopes" type="abstract operation">
<h1>
MappingsConsistentWithScopes (
_sourceMap_: a Decoded Source Map Record,
): a Boolean
</h1>
<dl class="header">
<dt>description</dt>
<dd>It returns *true*, iff the original position of any mapping lies within the definition scope of the inner-most range.</dd>
</dl>
<emu-alg>
1. For each Decoded Mapping Record _mapping_ of _sourceMap_.[[Mappings]], do
1. Let _originalPosition_ be _mapping_.[[OriginalPosition]].
1. If _originalPosition_ is not *null*, then
1. Let _range_ be the inner-most Generated Range Record of _sourceMap_.[[Ranges]] containing _mapping_.[[GeneratedPosition]].
1. If _range_ is not *null* and _range_.[[Definition]] is not *null*, then
1. Let _definition_ be _range_.[[Definition]].
1. Let _sourceRootScope_ be _originalPosition_.[[Source]].[[Scope]].
1. If _sourceRootScope_ is *null*, return *false*.
1. If _definition_ is not _sourceRootScope_ and _definition_ is not a descendant of _sourceRootScope_, return *false*.
1. If ComparePositions(_definition_.[[Start]], _originalPosition_) is ~greater~, return *false*.
1. If ComparePositions(_originalPosition_, _definition_.[[End]]) is not ~lesser~, return *false*.
1. Return *true*.
</emu-alg>
</emu-clause>
<emu-note>
TODO: Specify abstract operations for "inner-most Generated Range Record" and "IsDescendant".
</emu-note>
<emu-note>
The specification allows either the mapping or the generated range to be "unmapped", but if both map to original code, they need to do so consistently.
</emu-note>
</emu-clause>
</emu-clause>

<emu-clause id="sec-sources">
Expand Down
Loading