diff options
Diffstat (limited to 'lib/sourcemap.js')
-rw-r--r-- | lib/sourcemap.js | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/sourcemap.js b/lib/sourcemap.js index 6cf63d1b..6cbce5e1 100644 --- a/lib/sourcemap.js +++ b/lib/sourcemap.js @@ -51,27 +51,29 @@ function SourceMap(options) { file : options.file, sourceRoot : options.root }); - var current_source = null; - function add(gen_line, gen_col, orig_line, orig_col, name) { - // AST_Node.warn("Mapping in {file}: {orig_line},{orig_col} → {gen_line},{gen_col} ({name})", { - // orig_line : orig_line, - // orig_col : orig_col, - // gen_line : gen_line, - // gen_col : gen_col, - // file : current_source, - // name : name - // }); + function add(source, gen_line, gen_col, orig_line, orig_col, name) { generator.addMapping({ generated : { line: gen_line + 1, column: gen_col }, original : { line: orig_line + 1, column: orig_col }, - source : current_source, + source : source, name : name }); }; return { add : add, - set_source : function(filename) { current_source = filename }, get : function() { return generator }, toString : function() { return generator.toString() } - } + }; +}; + +function SourceMapInput(map) { + map = new MOZ_SourceMap.SourceMapConsumer(map); + return { + info: function(line, col) { + return map.originalPositionFor({ + line: line, + column: col + }); + } + }; }; |