aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMihai Bazon <mihai@bazon.net>2012-10-08 12:52:25 +0300
committerMihai Bazon <mihai@bazon.net>2012-10-08 12:52:25 +0300
commit80a18fe2fa60d8a689516b921a386839d30b6abe (patch)
treea56df417df488b29cc7fbc957ef1d8b0439f54da
parentfe1411bba1368c4e3c1fe92459e956ec4a4c5ee6 (diff)
downloadtracifyjs-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.
-rw-r--r--lib/output.js23
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() {