Merge e47ffc6e57 into 601780acc1
This commit is contained in:
commit
f4e588afcb
|
|
@ -308,7 +308,7 @@ function OutputStream(options) {
|
||||||
var add_mapping = options.source_map ? function(token, name) {
|
var add_mapping = options.source_map ? function(token, name) {
|
||||||
try {
|
try {
|
||||||
if (token) options.source_map.add(
|
if (token) options.source_map.add(
|
||||||
token.file || "?",
|
token.file,
|
||||||
current_line, current_col,
|
current_line, current_col,
|
||||||
token.line, token.col,
|
token.line, token.col,
|
||||||
(!name && token.type == "name") ? token.value : name
|
(!name && token.type == "name") ? token.value : name
|
||||||
|
|
|
||||||
|
|
@ -53,19 +53,33 @@ function SourceMap(options) {
|
||||||
orig_line_diff : 0,
|
orig_line_diff : 0,
|
||||||
dest_line_diff : 0,
|
dest_line_diff : 0,
|
||||||
});
|
});
|
||||||
|
var orig_maps = Object.create(null);
|
||||||
var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig);
|
var orig_map = options.orig && new MOZ_SourceMap.SourceMapConsumer(options.orig);
|
||||||
var generator;
|
var generator;
|
||||||
if (orig_map) {
|
if (orig_map) {
|
||||||
generator = MOZ_SourceMap.SourceMapGenerator.fromSourceMap(orig_map);
|
generator = MOZ_SourceMap.SourceMapGenerator.fromSourceMap(orig_map);
|
||||||
} else {
|
} else {
|
||||||
generator = new MOZ_SourceMap.SourceMapGenerator({
|
generator = new MOZ_SourceMap.SourceMapGenerator({
|
||||||
file : options.file,
|
file : options.file,
|
||||||
sourceRoot : options.root
|
sourceRoot : options.root
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function addInput(rawSourceMap) {
|
||||||
|
var consumer = new MOZ_SourceMap.SourceMapConsumer(rawSourceMap);
|
||||||
|
orig_maps[consumer.file] = consumer;
|
||||||
|
}
|
||||||
function add(source, gen_line, gen_col, orig_line, orig_col, name) {
|
function add(source, gen_line, gen_col, orig_line, orig_col, name) {
|
||||||
if (orig_map) {
|
var originalMap;
|
||||||
var info = orig_map.originalPositionFor({
|
if (source) {
|
||||||
|
originalMap = orig_maps[source] || orig_map;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
source = "?";
|
||||||
|
originalMap = orig_map;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (originalMap) {
|
||||||
|
var info = originalMap.originalPositionFor({
|
||||||
line: orig_line,
|
line: orig_line,
|
||||||
column: orig_col
|
column: orig_col
|
||||||
});
|
});
|
||||||
|
|
@ -77,6 +91,7 @@ function SourceMap(options) {
|
||||||
orig_col = info.column;
|
orig_col = info.column;
|
||||||
name = info.name || name;
|
name = info.name || name;
|
||||||
}
|
}
|
||||||
|
|
||||||
generator.addMapping({
|
generator.addMapping({
|
||||||
generated : { line: gen_line + options.dest_line_diff, column: gen_col },
|
generated : { line: gen_line + options.dest_line_diff, column: gen_col },
|
||||||
original : { line: orig_line + options.orig_line_diff, column: orig_col },
|
original : { line: orig_line + options.orig_line_diff, column: orig_col },
|
||||||
|
|
@ -85,6 +100,7 @@ function SourceMap(options) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
|
addInput : addInput,
|
||||||
add : add,
|
add : add,
|
||||||
get : function() { return generator },
|
get : function() { return generator },
|
||||||
toString : function() { return JSON.stringify(generator.toJSON()); }
|
toString : function() { return JSON.stringify(generator.toJSON()); }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user