react / wstein / node_modules / jest-cli / node_modules / coffee-script / lib / coffee-script / sourcemap.js
80677 views// Generated by CoffeeScript 1.9.31(function() {2var LineMap, SourceMap;34LineMap = (function() {5function LineMap(line1) {6this.line = line1;7this.columns = [];8}910LineMap.prototype.add = function(column, arg, options) {11var sourceColumn, sourceLine;12sourceLine = arg[0], sourceColumn = arg[1];13if (options == null) {14options = {};15}16if (this.columns[column] && options.noReplace) {17return;18}19return this.columns[column] = {20line: this.line,21column: column,22sourceLine: sourceLine,23sourceColumn: sourceColumn24};25};2627LineMap.prototype.sourceLocation = function(column) {28var mapping;29while (!((mapping = this.columns[column]) || (column <= 0))) {30column--;31}32return mapping && [mapping.sourceLine, mapping.sourceColumn];33};3435return LineMap;3637})();3839SourceMap = (function() {40var BASE64_CHARS, VLQ_CONTINUATION_BIT, VLQ_SHIFT, VLQ_VALUE_MASK;4142function SourceMap() {43this.lines = [];44}4546SourceMap.prototype.add = function(sourceLocation, generatedLocation, options) {47var base, column, line, lineMap;48if (options == null) {49options = {};50}51line = generatedLocation[0], column = generatedLocation[1];52lineMap = ((base = this.lines)[line] || (base[line] = new LineMap(line)));53return lineMap.add(column, sourceLocation, options);54};5556SourceMap.prototype.sourceLocation = function(arg) {57var column, line, lineMap;58line = arg[0], column = arg[1];59while (!((lineMap = this.lines[line]) || (line <= 0))) {60line--;61}62return lineMap && lineMap.sourceLocation(column);63};6465SourceMap.prototype.generate = function(options, code) {66var buffer, i, j, lastColumn, lastSourceColumn, lastSourceLine, len, len1, lineMap, lineNumber, mapping, needComma, ref, ref1, v3, writingline;67if (options == null) {68options = {};69}70if (code == null) {71code = null;72}73writingline = 0;74lastColumn = 0;75lastSourceLine = 0;76lastSourceColumn = 0;77needComma = false;78buffer = "";79ref = this.lines;80for (lineNumber = i = 0, len = ref.length; i < len; lineNumber = ++i) {81lineMap = ref[lineNumber];82if (lineMap) {83ref1 = lineMap.columns;84for (j = 0, len1 = ref1.length; j < len1; j++) {85mapping = ref1[j];86if (!(mapping)) {87continue;88}89while (writingline < mapping.line) {90lastColumn = 0;91needComma = false;92buffer += ";";93writingline++;94}95if (needComma) {96buffer += ",";97needComma = false;98}99buffer += this.encodeVlq(mapping.column - lastColumn);100lastColumn = mapping.column;101buffer += this.encodeVlq(0);102buffer += this.encodeVlq(mapping.sourceLine - lastSourceLine);103lastSourceLine = mapping.sourceLine;104buffer += this.encodeVlq(mapping.sourceColumn - lastSourceColumn);105lastSourceColumn = mapping.sourceColumn;106needComma = true;107}108}109}110v3 = {111version: 3,112file: options.generatedFile || '',113sourceRoot: options.sourceRoot || '',114sources: options.sourceFiles || [''],115names: [],116mappings: buffer117};118if (options.inline) {119v3.sourcesContent = [code];120}121return JSON.stringify(v3, null, 2);122};123124VLQ_SHIFT = 5;125126VLQ_CONTINUATION_BIT = 1 << VLQ_SHIFT;127128VLQ_VALUE_MASK = VLQ_CONTINUATION_BIT - 1;129130SourceMap.prototype.encodeVlq = function(value) {131var answer, nextChunk, signBit, valueToEncode;132answer = '';133signBit = value < 0 ? 1 : 0;134valueToEncode = (Math.abs(value) << 1) + signBit;135while (valueToEncode || !answer) {136nextChunk = valueToEncode & VLQ_VALUE_MASK;137valueToEncode = valueToEncode >> VLQ_SHIFT;138if (valueToEncode) {139nextChunk |= VLQ_CONTINUATION_BIT;140}141answer += this.encodeBase64(nextChunk);142}143return answer;144};145146BASE64_CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';147148SourceMap.prototype.encodeBase64 = function(value) {149return BASE64_CHARS[value] || (function() {150throw new Error("Cannot Base64 encode value: " + value);151})();152};153154return SourceMap;155156})();157158module.exports = SourceMap;159160}).call(this);161162163