James change to use original source for mapping

This commit is contained in:
startswithaj 2015-10-15 16:48:31 +10:00
parent d5138f7467
commit e32c1308e8
2 changed files with 7 additions and 1 deletions

View File

@ -306,11 +306,13 @@ function OutputStream(options) {
var add_mapping = options.source_map ? function(token, name) { var add_mapping = options.source_map ? function(token, name) {
try { try {
var originalSource = token.__HACK_CODE__.substring(token.pos, token.endpos)
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 originalSource // (!name && token.type == "name") ? token.value : name
); );
} catch(ex) { } catch(ex) {
AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", { AST_Node.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]", {

View File

@ -684,6 +684,10 @@ function parse($TEXT, options) {
S.in_directives = S.in_directives && ( S.in_directives = S.in_directives && (
S.token.type == "string" || is("punc", ";") S.token.type == "string" || is("punc", ";")
); );
// Hacks in the source code
S.token.__HACK_CODE__ = $TEXT
return S.token; return S.token;
}; };