Don't search orig_maps if the source filename is unknown.

When the AST is not associated with a filename, only orig_map can be queried to get the original filename. If that wasn't provided, then the best we can do is add a mapping literally for "?"
This commit is contained in:
Arnavion 2015-08-04 10:59:15 -07:00
parent 87f31ed488
commit e47ffc6e57
2 changed files with 9 additions and 2 deletions

View File

@ -303,7 +303,7 @@ function OutputStream(options) {
var add_mapping = options.source_map ? function(token, name) {
try {
if (token) options.source_map.add(
token.file || "?",
token.file,
current_line, current_col,
token.line, token.col,
(!name && token.type == "name") ? token.value : name

View File

@ -69,7 +69,14 @@ function SourceMap(options) {
orig_maps[consumer.file] = consumer;
}
function add(source, gen_line, gen_col, orig_line, orig_col, name) {
var originalMap = orig_maps[source] || orig_map;
var originalMap;
if (source) {
originalMap = orig_maps[source] || orig_map;
}
else {
source = "?";
originalMap = orig_map;
}
if (originalMap) {
var info = originalMap.originalPositionFor({