diff options
-rwxr-xr-x | emcc | 1 | ||||
-rw-r--r-- | tools/eliminator/node_modules/uglify-js/lib/process.js | 13 | ||||
-rw-r--r-- | tools/js-optimizer.js | 4 |
3 files changed, 13 insertions, 5 deletions
@@ -1524,6 +1524,7 @@ try: if DEBUG == '2': # Clean up the syntax a bit final = shared.Building.js_optimizer(final, [], jcache, make_source_map) + js_transform_tempfiles.append(final) if DEBUG: save_intermediate('pretty') def get_eliminate(): 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--) { |