1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 * SourceMapConsumer for WebAssembly source maps. It transposes columns with
9 * lines, which allows mapping data to be used with SpiderMonkey Debugger API.
13 * @param map SourceMapConsumer
17 this.version = map.version;
19 this._computeColumnSpans = false;
23 return this._map.sources;
27 return this._map.sourceRoot;
34 // important, since sources are using this.
35 this._map.sourceRoot = url;
39 return this._map.names;
42 get sourcesContent() {
43 return this._map.sourcesContent;
47 throw new Error("not supported");
50 computeColumnSpans() {
51 this._computeColumnSpans = true;
54 originalPositionFor(generatedPosition) {
55 const result = this._map.originalPositionFor({
57 column: generatedPosition.line,
58 bias: generatedPosition.bias,
63 _remapGeneratedPosition(position) {
64 const generatedPosition = {
65 line: position.column,
68 if (this._computeColumnSpans) {
69 generatedPosition.lastColumn = Infinity;
71 return generatedPosition;
74 generatedPositionFor(originalPosition) {
75 const position = this._map.generatedPositionFor(originalPosition);
76 return this._remapGeneratedPosition(position);
79 allGeneratedPositionsFor(originalPosition) {
80 const positions = this._map.allGeneratedPositionsFor(originalPosition);
81 return positions.map(position => {
82 return this._remapGeneratedPosition(position);
86 hasContentsOfAllSources() {
87 return this._map.hasContentsOfAllSources();
90 sourceContentFor(source, returnNullOnMissing) {
91 return this._map.sourceContentFor(source, returnNullOnMissing);
94 eachMapping(callback, context, order) {
95 this._map.eachMapping(
97 const { source, generatedColumn, originalLine, originalColumn, name } =
101 generatedLine: generatedColumn,
114 exports.WasmRemap = WasmRemap;