1 // Generated by CoffeeScript 1.8.0
3 var LineMap, SourceMap;
5 LineMap = (function() {
6 function LineMap(line) {
11 LineMap.prototype.add = function(column, _arg, options) {
12 var sourceColumn, sourceLine;
13 sourceLine = _arg[0], sourceColumn = _arg[1];
14 if (options == null) {
17 if (this.columns[column] && options.noReplace) {
20 return this.columns[column] = {
23 sourceLine: sourceLine,
24 sourceColumn: sourceColumn
28 LineMap.prototype.sourceLocation = function(column) {
30 while (!((mapping = this.columns[column]) || (column <= 0))) {
33 return mapping && [mapping.sourceLine, mapping.sourceColumn];
40 SourceMap = (function() {
41 var BASE64_CHARS, VLQ_CONTINUATION_BIT, VLQ_SHIFT, VLQ_VALUE_MASK;
43 function SourceMap() {
47 SourceMap.prototype.add = function(sourceLocation, generatedLocation, options) {
48 var column, line, lineMap, _base;
49 if (options == null) {
52 line = generatedLocation[0], column = generatedLocation[1];
53 lineMap = ((_base = this.lines)[line] || (_base[line] = new LineMap(line)));
54 return lineMap.add(column, sourceLocation, options);
57 SourceMap.prototype.sourceLocation = function(_arg) {
58 var column, line, lineMap;
59 line = _arg[0], column = _arg[1];
60 while (!((lineMap = this.lines[line]) || (line <= 0))) {
63 return lineMap && lineMap.sourceLocation(column);
66 SourceMap.prototype.generate = function(options, code) {
67 var buffer, lastColumn, lastSourceColumn, lastSourceLine, lineMap, lineNumber, mapping, needComma, v3, writingline, _i, _j, _len, _len1, _ref, _ref1;
68 if (options == null) {
81 for (lineNumber = _i = 0, _len = _ref.length; _i < _len; lineNumber = ++_i) {
82 lineMap = _ref[lineNumber];
84 _ref1 = lineMap.columns;
85 for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {
90 while (writingline < mapping.line) {
100 buffer += this.encodeVlq(mapping.column - lastColumn);
101 lastColumn = mapping.column;
102 buffer += this.encodeVlq(0);
103 buffer += this.encodeVlq(mapping.sourceLine - lastSourceLine);
104 lastSourceLine = mapping.sourceLine;
105 buffer += this.encodeVlq(mapping.sourceColumn - lastSourceColumn);
106 lastSourceColumn = mapping.sourceColumn;
113 file: options.generatedFile || '',
114 sourceRoot: options.sourceRoot || '',
115 sources: options.sourceFiles || [''],
119 if (options.inline) {
120 v3.sourcesContent = [code];
122 return JSON.stringify(v3, null, 2);
127 VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;
129 VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;
131 SourceMap.prototype.encodeVlq = function(value) {
132 var answer, nextChunk, signBit, valueToEncode;
134 signBit = value < 0 ? 1 : 0;
135 valueToEncode = (Math.abs(value) << 1) + signBit;
136 while (valueToEncode || !answer) {
137 nextChunk = valueToEncode & VLQ_VALUE_MASK;
138 valueToEncode = valueToEncode >> VLQ_SHIFT;
140 nextChunk |= VLQ_CONTINUATION_BIT;
142 answer += this.encodeBase64(nextChunk);
147 BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
149 SourceMap.prototype.encodeBase64 = function(value) {
150 return BASE64_CHARS[value] || (function() {
151 throw new Error("Cannot Base64 encode value: " + value);
159 module.exports = SourceMap;