diff options
author | Jez Ng <me@jezng.com> | 2013-06-26 01:15:35 -0700 |
---|---|---|
committer | Jez Ng <me@jezng.com> | 2013-06-26 01:15:35 -0700 |
commit | 566447048806a59eb6e102fc364191ce292d7045 (patch) | |
tree | db472534dc0d8bf4c560348afd849f3563ef0253 /tools/eliminator | |
parent | 0c19e4051e497c9bd61459617768b9e3eaad5a44 (diff) |
Move line numbers to the AST node itself.
This allows us to use strict comparisons on the node type.
Diffstat (limited to 'tools/eliminator')
-rw-r--r-- | tools/eliminator/node_modules/uglify-js/lib/parse-js.js | 7 | ||||
-rw-r--r-- | tools/eliminator/node_modules/uglify-js/lib/process.js | 28 |
2 files changed, 16 insertions, 19 deletions
diff --git a/tools/eliminator/node_modules/uglify-js/lib/parse-js.js b/tools/eliminator/node_modules/uglify-js/lib/parse-js.js index 2dc2ef70..c7c2025f 100644 --- a/tools/eliminator/node_modules/uglify-js/lib/parse-js.js +++ b/tools/eliminator/node_modules/uglify-js/lib/parse-js.js @@ -786,15 +786,12 @@ function parse($TEXT, exigent_mode, embed_tokens) { return ex; }; - function add_tokens(str, start, end) { - return str instanceof NodeWithToken ? str : new NodeWithToken(str, start, end); - }; - function maybe_embed_tokens(parser) { if (embed_tokens) return function() { var start = S.token; var ast = parser.apply(this, arguments); - ast[0] = add_tokens(ast[0], start, prev()); + ast.start = start; + ast.end = prev; return ast; }; else return parser; diff --git a/tools/eliminator/node_modules/uglify-js/lib/process.js b/tools/eliminator/node_modules/uglify-js/lib/process.js index 3fd99b79..e1d692b2 100644 --- a/tools/eliminator/node_modules/uglify-js/lib/process.js +++ b/tools/eliminator/node_modules/uglify-js/lib/process.js @@ -1511,8 +1511,8 @@ function gen_code(ast, options) { str.substr(str.indexOf("."))); } var best = best_of(a); - if (options.debug && this[0].start) - return new NodeWithLine(best, this[0].start.line); + if (options.debug && this.start) + return new NodeWithLine(best, this.start.line); return best; }; @@ -1546,8 +1546,8 @@ function gen_code(ast, options) { // hack: we don't support mapping one optimized line to more than one // generated line, so in case of multiple comma-separated var definitions, // just take the first - if (defs[0][1] && defs[0][1][0] && defs[0][1][0].start) - return s + (new NodeWithLine(s, defs[0][1][0].start.line)).lineComment(); + if (defs[0][1] && defs[0][1].start) + return s + (new NodeWithLine(s, defs[0][1].start.line)).lineComment(); } return s; }, @@ -1605,8 +1605,8 @@ function gen_code(ast, options) { if (op && op !== true) op += "="; else op = "="; var s = add_spaces([ make(lvalue), op, parenthesize(rvalue, "seq") ]); - if (options.debug && this[0].start) - return new NodeWithLine(s, this[0].start.line); + if (options.debug && this.start) + return new NodeWithLine(s, this.start.line); return s; }, "dot": function(expr) { @@ -1627,8 +1627,8 @@ function gen_code(ast, options) { var str = f + "(" + add_commas(MAP(args, function(expr){ return parenthesize(expr, "seq"); })) + ")"; - if (options.debug && this[0].start) - return new NodeWithLine(str, this[0].start.line) + if (options.debug && this.start) + return new NodeWithLine(str, this.start.line) return str; }, "function": make_function, @@ -1688,12 +1688,12 @@ function gen_code(ast, options) { } var str = add_spaces([ left, operator, right ]); if (options.debug) { - if (this[0].start) - return new NodeWithLine(str, this[0].start.line); - else if (lvalue[0].start) - return new NodeWithLine(str, lvalue[0].start.line); - else if (rvalue[0].start) - return new NodeWithLine(str, rvalue[0].start.line); + if (this.start) + return new NodeWithLine(str, this.start.line); + else if (lvalue.start) + return new NodeWithLine(str, lvalue.start.line); + else if (rvalue.start) + return new NodeWithLine(str, rvalue.start.line); } return str; }, |