diff options
author | Mihai Bazon <mihai@bazon.net> | 2012-10-08 12:52:25 +0300 |
---|---|---|
committer | Mihai Bazon <mihai@bazon.net> | 2012-10-08 12:52:25 +0300 |
commit | 80a18fe2fa60d8a689516b921a386839d30b6abe (patch) | |
tree | a56df417df488b29cc7fbc957ef1d8b0439f54da /lib/output.js | |
parent | fe1411bba1368c4e3c1fe92459e956ec4a4c5ee6 (diff) | |
download | tracifyjs-80a18fe2fa60d8a689516b921a386839d30b6abe.tar.gz tracifyjs-80a18fe2fa60d8a689516b921a386839d30b6abe.zip |
for certain nodes that we invent we might not have a original source file to
map from, so just use "?". and in any case, don't fail hard when addMapping throws.
Diffstat (limited to 'lib/output.js')
-rw-r--r-- | lib/output.js | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/output.js b/lib/output.js index 09721625..b0a01613 100644 --- a/lib/output.js +++ b/lib/output.js @@ -248,12 +248,23 @@ function OutputStream(options) { }; var add_mapping = options.source_map ? function(token, name) { - options.source_map.add( - token.file, - current_line, current_col, - token.line, token.col, - (!name && token.type == "name") ? token.value : name - ); + try { + if (token) options.source_map.add( + token.file || "?", + current_line, current_col, + token.line, token.col, + (!name && token.type == "name") ? token.value : name + ); + } catch(ex) { + AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", { + file: token.file, + line: token.line, + col: token.col, + cline: current_line, + ccol: current_col, + name: name || "" + }) + } } : noop; function get() { |