aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJez Ng <me@jezng.com>2013-06-21 16:01:38 -0700
committerJez Ng <me@jezng.com>2013-06-22 01:23:22 -0700
commit88feddf045882bbddd29d9286eae4e6a9086e286 (patch)
treece60c87bf58117ff6e4d3e092c394da255762a57 /tools
parentd50e7b4f7de07df53f820051dac85e79f8aa6e84 (diff)
Get test_source_map passing again.
Diffstat (limited to 'tools')
-rw-r--r--tools/eliminator/node_modules/uglify-js/lib/process.js13
-rw-r--r--tools/js-optimizer.js4
2 files changed, 12 insertions, 5 deletions
diff --git a/tools/eliminator/node_modules/uglify-js/lib/process.js b/tools/eliminator/node_modules/uglify-js/lib/process.js
index da38caa7..3fd99b79 100644
--- a/tools/eliminator/node_modules/uglify-js/lib/process.js
+++ b/tools/eliminator/node_modules/uglify-js/lib/process.js
@@ -72,7 +72,7 @@ function NodeWithLine(str, line) {
NodeWithLine.prototype = new String();
NodeWithLine.prototype.toString = function() { return this.str; }
NodeWithLine.prototype.valueOf = function() { return this.str; }
-NodeWithLine.prototype.lineComment = function() { return " // @line " + this.line; }
+NodeWithLine.prototype.lineComment = function() { return " //@line " + this.line; }
// XXX ugly hack
String.prototype.lineComment = function() { return ""; }
@@ -1686,10 +1686,15 @@ function gen_code(ast, options) {
&& rvalue[0] == "regexp" && /^script/i.test(rvalue[1])) {
right = " " + right;
}
- var tok = this[0];
var str = add_spaces([ left, operator, right ]);
- if (options.debug && tok.start)
- return new NodeWithLine(str, tok.start.line);
+ 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);
+ }
return str;
},
"unary-prefix": function(operator, expr) {
diff --git a/tools/js-optimizer.js b/tools/js-optimizer.js
index 07092513..94c10ebc 100644
--- a/tools/js-optimizer.js
+++ b/tools/js-optimizer.js
@@ -442,7 +442,9 @@ function simplifyExpressionsPre(ast) {
traverse(ast, function process(node, type, stack) {
if (type == 'binary' && node[1] == '|') {
if (node[2][0] == 'num' && node[3][0] == 'num') {
- return ['num', node[2][1] | node[3][1]];
+ // pass node[2][0] instead of 'num' because it might be a token
+ // object with line numbers attached.
+ return [node[2][0], node[2][1] | node[3][1]];
} else if (jsonCompare(node[2], ZERO) || jsonCompare(node[3], ZERO)) {
// We might be able to remove this correction
for (var i = stack.length-1; i >= 0; i--) {