|
489 | 489 |
|
490 | 490 | <emu-clause id="sec-position-record-type"> |
491 | 491 | <h1>Position Record</h1> |
492 | | - <p>A <dfn>Position Record</dfn> is a tuple of a non-negative line and non-negative column number:</p> |
| 492 | + <p>A <dfn variants="Position Records">Position Record</dfn> is a tuple of a non-negative line and non-negative column number:</p> |
493 | 493 | <emu-table id="table-position-record-fields" caption="Position Record Fields"> |
494 | 494 | <table> |
495 | 495 | <thead> |
|
683 | 683 | 1. Let _sources_ be DecodeSourceMapSources(_baseURL_, _sourceRootField_, _sourcesField_, _sourcesContentField_, _ignoreListField_). |
684 | 684 | 1. Let _namesField_ be GetOptionalListOfStrings(_json_, *"names"*). |
685 | 685 | 1. Let _mappings_ be DecodeMappings(_mappingsField_, _namesField_, _sources_). |
| 686 | + 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~. |
686 | 687 | 1. Return the Decoded Source Map Record { [[File]]: _fileField_, [[Sources]]: _sources_, [[Mappings]]: _mappings_ }. |
687 | 688 | </emu-alg> |
688 | 689 |
|
|
1264 | 1265 | 1. Append _mapping_ to _offsetMappings_. |
1265 | 1266 | 1. Set _sourceMap_.[[Mappings]] to the list-concatenation of _sourceMap_.[[Mappings]] and _offsetMappings_. |
1266 | 1267 | 1. Set _previousOffsetPosition_ to _offsetPosition_. |
1267 | | - 1. [declared="a,b"] Let _sortedMappings_ be a copy of _offsetMappings_, sorted 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~. |
1268 | | - 1. If _sortedMappings_ is not empty, set _previousLastMapping_ to the last element of _sortedMappings_. |
| 1268 | + 1. If _offsetMappings_ is not empty, set _previousLastMapping_ to the last element of _offsetMappings_. |
1269 | 1269 | 1. Return _sourceMap_. |
1270 | 1270 | </emu-alg> |
1271 | 1271 |
|
@@ -1539,6 +1539,33 @@ return lastURL;</code></pre> |
1539 | 1539 | </emu-clause> |
1540 | 1540 | </emu-clause> |
1541 | 1541 |
|
| 1542 | +<emu-clause id="sec-operations-on-source-map-records"> |
| 1543 | + <h1>Operations on source map records</h1> |
| 1544 | + |
| 1545 | + <p>After decoding a source map, source map consumers can use the resulting Decoded Source Map Records to look up position information for debugging or other use cases. This section describes the behaviour of typical operations that may be supported by source map consumers.</p> |
| 1546 | + <p>The GetOriginalPosition operation may be used to query the position in an original source that corresponds to a position in the generated code. For example, this can be used in a debugger to navigate from the generated code to the original source based on a user's mouse click.</p> |
| 1547 | + |
| 1548 | + <emu-clause id="sec-GetOriginalPosition" type="abstract operation"> |
| 1549 | + <h1> |
| 1550 | + GetOriginalPosition ( |
| 1551 | + _sourceMapRecord_: a Decoded Source Map Record, |
| 1552 | + _generatedPosition_: a Position Record, |
| 1553 | + ): a Decoded Mapping Record or *null* |
| 1554 | + </h1> |
| 1555 | + <dl class="header"></dl> |
| 1556 | + <emu-alg> |
| 1557 | + 1. Let _mappings_ be _sourceMapRecord_.[[Mappings]]. |
| 1558 | + 1. Let _closest_ be *null*. |
| 1559 | + 1. For each element _mapping_ of _mappings_, do |
| 1560 | + 1. If the result of performing ComparePositions(_mapping_.[[GeneratedPosition]], _generatedPosition_) is ~greater~, then |
| 1561 | + 1. Return _closest_. |
| 1562 | + 1. Else, |
| 1563 | + 1. Set _closest_ to _mapping_. |
| 1564 | + 1. Return _closest_. |
| 1565 | + </emu-alg> |
| 1566 | + </emu-clause> |
| 1567 | +</emu-clause> |
| 1568 | + |
1542 | 1569 | <emu-annex id="sec-conventions"> |
1543 | 1570 | <h1>Conventions</h1> |
1544 | 1571 |
|
|
0 commit comments