Last change
on this file since 8d391a1 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
972 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | /*
|
---|
| 2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
| 3 | Author Tobias Koppers @sokra
|
---|
| 4 | */
|
---|
| 5 | "use strict";
|
---|
| 6 |
|
---|
| 7 | class MappingsContext {
|
---|
| 8 | constructor() {
|
---|
| 9 | this.sourcesIndices = new Map();
|
---|
| 10 | this.sourcesContent = new Map();
|
---|
| 11 | this.hasSourceContent = false;
|
---|
| 12 | this.currentOriginalLine = 1;
|
---|
| 13 | this.currentSource = 0;
|
---|
| 14 | this.unfinishedGeneratedLine = false;
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | ensureSource(source, originalSource) {
|
---|
| 18 | let idx = this.sourcesIndices.get(source);
|
---|
| 19 | if(typeof idx === "number") {
|
---|
| 20 | return idx;
|
---|
| 21 | }
|
---|
| 22 | idx = this.sourcesIndices.size;
|
---|
| 23 | this.sourcesIndices.set(source, idx);
|
---|
| 24 | this.sourcesContent.set(source, originalSource)
|
---|
| 25 | if(typeof originalSource === "string")
|
---|
| 26 | this.hasSourceContent = true;
|
---|
| 27 | return idx;
|
---|
| 28 | }
|
---|
| 29 |
|
---|
| 30 | getArrays() {
|
---|
| 31 | const sources = [];
|
---|
| 32 | const sourcesContent = [];
|
---|
| 33 |
|
---|
| 34 | for(const pair of this.sourcesContent) {
|
---|
| 35 | sources.push(pair[0]);
|
---|
| 36 | sourcesContent.push(pair[1]);
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | return {
|
---|
| 40 | sources,
|
---|
| 41 | sourcesContent
|
---|
| 42 | };
|
---|
| 43 | }
|
---|
| 44 | }
|
---|
| 45 | module.exports = MappingsContext;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.