Remove unnecessary semi-colons

This commit is contained in:
Xotic750 2016-01-07 21:23:29 +01:00
parent 1cd9a2df9a
commit 35ecb38c48
13 changed files with 181 additions and 182 deletions

View File

@ -83,7 +83,7 @@ function DEFNODE(type, props, methods, base) {
}; };
exports["AST_" + type] = ctor; exports["AST_" + type] = ctor;
return ctor; return ctor;
}; }
var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before file raw", { var AST_Token = DEFNODE("Token", "type value line col pos endline endcol endpos nlb comments_before file raw", {
}, null); }, null);
@ -149,7 +149,7 @@ function walk_body(node, visitor) {
else node.body.forEach(function(stat){ else node.body.forEach(function(stat){
stat._walk(visitor); stat._walk(visitor);
}); });
}; }
var AST_Block = DEFNODE("Block", "body", { var AST_Block = DEFNODE("Block", "body", {
$documentation: "A body of statements (usually bracketed)", $documentation: "A body of statements (usually bracketed)",
@ -1171,7 +1171,7 @@ function TreeWalker(callback) {
this.visit = callback; this.visit = callback;
this.stack = []; this.stack = [];
this.directives = Object.create(null); this.directives = Object.create(null);
}; }
TreeWalker.prototype = { TreeWalker.prototype = {
_visit: function(node, descend) { _visit: function(node, descend) {
this.push(node); this.push(node);

View File

@ -78,7 +78,7 @@ function Compressor(options, false_by_default) {
warnings : true, warnings : true,
global_defs : {} global_defs : {}
}, true); }, true);
}; }
Compressor.prototype = new TreeTransformer; Compressor.prototype = new TreeTransformer;
merge(Compressor.prototype, { merge(Compressor.prototype, {
@ -117,7 +117,7 @@ merge(Compressor.prototype, {
if (opt === self) return opt; if (opt === self) return opt;
return opt.transform(compressor); return opt.transform(compressor);
}); });
}; }
OPT(AST_Node, function(self, compressor){ OPT(AST_Node, function(self, compressor){
return self; return self;
@ -135,7 +135,7 @@ merge(Compressor.prototype, {
if (!props.end) props.end = orig.end; if (!props.end) props.end = orig.end;
} }
return new ctor(props); return new ctor(props);
}; }
function make_node_from_constant(compressor, val, orig) { function make_node_from_constant(compressor, val, orig) {
// XXX: WIP. // XXX: WIP.
@ -173,7 +173,7 @@ merge(Compressor.prototype, {
type: typeof val type: typeof val
})); }));
} }
}; }
function as_statement_array(thing) { function as_statement_array(thing) {
if (thing === null) return []; if (thing === null) return [];
@ -181,14 +181,14 @@ merge(Compressor.prototype, {
if (thing instanceof AST_EmptyStatement) return []; if (thing instanceof AST_EmptyStatement) return [];
if (thing instanceof AST_Statement) return [ thing ]; if (thing instanceof AST_Statement) return [ thing ];
throw new Error("Can't convert thing to statement array"); throw new Error("Can't convert thing to statement array");
}; }
function is_empty(thing) { function is_empty(thing) {
if (thing === null) return true; if (thing === null) return true;
if (thing instanceof AST_EmptyStatement) return true; if (thing instanceof AST_EmptyStatement) return true;
if (thing instanceof AST_BlockStatement) return thing.body.length == 0; if (thing instanceof AST_BlockStatement) return thing.body.length == 0;
return false; return false;
}; }
function loop_body(x) { function loop_body(x) {
if (x instanceof AST_Switch) return x; if (x instanceof AST_Switch) return x;
@ -196,7 +196,7 @@ merge(Compressor.prototype, {
return (x.body instanceof AST_BlockStatement ? x.body : x); return (x.body instanceof AST_BlockStatement ? x.body : x);
} }
return x; return x;
}; }
function tighten_body(statements, compressor) { function tighten_body(statements, compressor) {
var CHANGED, max_iter = 10; var CHANGED, max_iter = 10;
@ -328,7 +328,7 @@ merge(Compressor.prototype, {
} }
return a; return a;
}, []); }, []);
}; }
function handle_if_return(statements, compressor) { function handle_if_return(statements, compressor) {
var self = compressor.self(); var self = compressor.self();
@ -459,7 +459,7 @@ merge(Compressor.prototype, {
} }
} }
return ret; return ret;
}; }
function eliminate_dead_code(statements, compressor) { function eliminate_dead_code(statements, compressor) {
var has_quit = false; var has_quit = false;
@ -490,7 +490,7 @@ merge(Compressor.prototype, {
}, []); }, []);
CHANGED = statements.length != orig; CHANGED = statements.length != orig;
return statements; return statements;
}; }
function sequencesize(statements, compressor) { function sequencesize(statements, compressor) {
if (statements.length < 2) return statements; if (statements.length < 2) return statements;
@ -501,7 +501,7 @@ merge(Compressor.prototype, {
body: seq body: seq
})); }));
seq = []; seq = [];
}; }
statements.forEach(function(stat){ statements.forEach(function(stat){
if (stat instanceof AST_SimpleStatement && seq.length < 2000) seq.push(stat.body); if (stat instanceof AST_SimpleStatement && seq.length < 2000) seq.push(stat.body);
else push_seq(), ret.push(stat); else push_seq(), ret.push(stat);
@ -510,7 +510,7 @@ merge(Compressor.prototype, {
ret = sequencesize_2(ret, compressor); ret = sequencesize_2(ret, compressor);
CHANGED = ret.length != statements.length; CHANGED = ret.length != statements.length;
return ret; return ret;
}; }
function sequencesize_2(statements, compressor) { function sequencesize_2(statements, compressor) {
function cons_seq(right) { function cons_seq(right) {
@ -522,7 +522,7 @@ merge(Compressor.prototype, {
left = AST_Seq.cons(left, right); left = AST_Seq.cons(left, right);
} }
return left.transform(compressor); return left.transform(compressor);
}; }
var ret = [], prev = null; var ret = [], prev = null;
statements.forEach(function(stat){ statements.forEach(function(stat){
if (prev) { if (prev) {
@ -564,7 +564,7 @@ merge(Compressor.prototype, {
prev = stat instanceof AST_SimpleStatement ? stat : null; prev = stat instanceof AST_SimpleStatement ? stat : null;
}); });
return ret; return ret;
}; }
function join_consecutive_vars(statements, compressor) { function join_consecutive_vars(statements, compressor) {
var prev = null; var prev = null;
@ -592,7 +592,7 @@ merge(Compressor.prototype, {
} }
return a; return a;
}, []); }, []);
}; }
function negate_iifes(statements, compressor) { function negate_iifes(statements, compressor) {
statements.forEach(function(stat){ statements.forEach(function(stat){
@ -626,9 +626,9 @@ merge(Compressor.prototype, {
})(stat.body); })(stat.body);
} }
}); });
}; }
}; }
function extract_declarations_from_unreachable_code(compressor, stat, target) { function extract_declarations_from_unreachable_code(compressor, stat, target) {
compressor.warn("Dropping unreachable code [{file}:{line},{col}]", stat.start); compressor.warn("Dropping unreachable code [{file}:{line},{col}]", stat.start);
@ -647,7 +647,7 @@ merge(Compressor.prototype, {
return true; return true;
} }
})); }));
}; }
/* -----[ boolean/negation helpers ]----- */ /* -----[ boolean/negation helpers ]----- */
@ -713,7 +713,7 @@ merge(Compressor.prototype, {
return ast1.print_to_string().length > return ast1.print_to_string().length >
ast2.print_to_string().length ast2.print_to_string().length
? ast2 : ast1; ? ast2 : ast1;
}; }
// methods to evaluate a constant expression // methods to evaluate a constant expression
(function (def){ (function (def){
@ -777,7 +777,7 @@ merge(Compressor.prototype, {
if (!compressor) throw new Error("Compressor must be passed"); if (!compressor) throw new Error("Compressor must be passed");
return node._eval(compressor); return node._eval(compressor);
}; }
def(AST_Node, function(){ def(AST_Node, function(){
throw def; // not constant throw def; // not constant
}); });
@ -869,7 +869,7 @@ merge(Compressor.prototype, {
operator: "!", operator: "!",
expression: exp expression: exp
}); });
}; }
def(AST_Node, function(){ def(AST_Node, function(){
return basic_negation(this); return basic_negation(this);
}); });
@ -1017,14 +1017,14 @@ merge(Compressor.prototype, {
// tell me if a statement aborts // tell me if a statement aborts
function aborts(thing) { function aborts(thing) {
return thing && thing.aborts(); return thing && thing.aborts();
}; }
(function(def){ (function(def){
def(AST_Statement, function(){ return null }); def(AST_Statement, function(){ return null });
def(AST_Jump, function(){ return this }); def(AST_Jump, function(){ return this });
function block_aborts(){ function block_aborts(){
var n = this.body.length; var n = this.body.length;
return n > 0 && aborts(this.body[n - 1]); return n > 0 && aborts(this.body[n - 1]);
}; }
def(AST_BlockStatement, block_aborts); def(AST_BlockStatement, block_aborts);
def(AST_SwitchBranch, block_aborts); def(AST_SwitchBranch, block_aborts);
def(AST_If, function(){ def(AST_If, function(){
@ -1391,7 +1391,7 @@ merge(Compressor.prototype, {
definitions: defs definitions: defs
}); });
hoisted.push(defs); hoisted.push(defs);
}; }
} }
self.body = dirs.concat(hoisted, self.body); self.body = dirs.concat(hoisted, self.body);
} }
@ -1471,7 +1471,7 @@ merge(Compressor.prototype, {
drop_it(first.body); drop_it(first.body);
} }
} }
}; }
OPT(AST_While, function(self, compressor) { OPT(AST_While, function(self, compressor) {
if (!compressor.option("loops")) return self; if (!compressor.option("loops")) return self;
@ -1862,7 +1862,7 @@ merge(Compressor.prototype, {
})); }));
} catch(ex) { } catch(ex) {
if (ex !== ast) throw ex; if (ex !== ast) throw ex;
}; }
if (!fun) return self; if (!fun) return self;
var args = fun.argnames.map(function(arg, i){ var args = fun.argnames.map(function(arg, i){
return make_node(AST_String, self.args[i], { return make_node(AST_String, self.args[i], {
@ -2611,7 +2611,7 @@ merge(Compressor.prototype, {
return make_node(AST_True, self); return make_node(AST_True, self);
} }
return self; return self;
}; }
OPT(AST_Array, literals_in_boolean_context); OPT(AST_Array, literals_in_boolean_context);
OPT(AST_Object, literals_in_boolean_context); OPT(AST_Object, literals_in_boolean_context);
OPT(AST_RegExp, literals_in_boolean_context); OPT(AST_RegExp, literals_in_boolean_context);

View File

@ -410,7 +410,7 @@
endpos : range ? range[0] : moznode.start, endpos : range ? range[0] : moznode.start,
raw : raw_token(moznode), raw : raw_token(moznode),
}); });
}; }
function my_end_token(moznode) { function my_end_token(moznode) {
var loc = moznode.loc, end = loc && loc.end; var loc = moznode.loc, end = loc && loc.end;
@ -425,7 +425,7 @@
endpos : range ? range[1] : moznode.end, endpos : range ? range[1] : moznode.end,
raw : raw_token(moznode), raw : raw_token(moznode),
}); });
}; }
function map(moztype, mytype, propmap) { function map(moztype, mytype, propmap) {
var moz_to_me = "function From_Moz_" + moztype + "(M){\n"; var moz_to_me = "function From_Moz_" + moztype + "(M){\n";
@ -480,7 +480,7 @@
); );
MOZ_TO_ME[moztype] = moz_to_me; MOZ_TO_ME[moztype] = moz_to_me;
def_to_moz(mytype, me_to_moz); def_to_moz(mytype, me_to_moz);
}; }
var FROM_MOZ_STACK = null; var FROM_MOZ_STACK = null;
@ -489,7 +489,7 @@
var ret = node != null ? MOZ_TO_ME[node.type](node) : null; var ret = node != null ? MOZ_TO_ME[node.type](node) : null;
FROM_MOZ_STACK.pop(); FROM_MOZ_STACK.pop();
return ret; return ret;
}; }
AST_Node.from_mozilla_ast = function(node){ AST_Node.from_mozilla_ast = function(node){
var save_stack = FROM_MOZ_STACK; var save_stack = FROM_MOZ_STACK;
@ -515,23 +515,23 @@
} }
} }
return moznode; return moznode;
}; }
function def_to_moz(mytype, handler) { function def_to_moz(mytype, handler) {
mytype.DEFMETHOD("to_mozilla_ast", function() { mytype.DEFMETHOD("to_mozilla_ast", function() {
return set_moz_loc(this, handler(this)); return set_moz_loc(this, handler(this));
}); });
}; }
function to_moz(node) { function to_moz(node) {
return node != null ? node.to_mozilla_ast() : null; return node != null ? node.to_mozilla_ast() : null;
}; }
function to_moz_block(node) { function to_moz_block(node) {
return { return {
type: "BlockStatement", type: "BlockStatement",
body: node.body.map(to_moz) body: node.body.map(to_moz)
}; };
}; }
})(); })();

View File

@ -84,7 +84,7 @@ function OutputStream(options) {
return "\\u" + code; return "\\u" + code;
} }
}); });
}; }
function make_string(str, quote) { function make_string(str, quote) {
var dq = 0, sq = 0; var dq = 0, sq = 0;
@ -122,7 +122,7 @@ function OutputStream(options) {
default: default:
return dq > sq ? quote_single() : quote_double(); return dq > sq ? quote_single() : quote_double();
} }
}; }
function encode_string(str, quote) { function encode_string(str, quote) {
var ret = make_string(str, quote); var ret = make_string(str, quote);
@ -132,18 +132,18 @@ function OutputStream(options) {
ret = ret.replace(/--\x3e/g, "--\\x3e"); ret = ret.replace(/--\x3e/g, "--\\x3e");
} }
return ret; return ret;
}; }
function make_name(name) { function make_name(name) {
name = name.toString(); name = name.toString();
if (options.ascii_only) if (options.ascii_only)
name = to_ascii(name, true); name = to_ascii(name, true);
return name; return name;
}; }
function make_indent(back) { function make_indent(back) {
return repeat_string(" ", options.indent_start + indentation - back * options.indent_level); return repeat_string(" ", options.indent_start + indentation - back * options.indent_level);
}; }
/* -----[ beautification/minification ]----- */ /* -----[ beautification/minification ]----- */
@ -153,12 +153,12 @@ function OutputStream(options) {
function last_char() { function last_char() {
return last.charAt(last.length - 1); return last.charAt(last.length - 1);
}; }
function maybe_newline() { function maybe_newline() {
if (options.max_line_len && current_col > options.max_line_len) if (options.max_line_len && current_col > options.max_line_len)
print("\n"); print("\n");
}; }
var requireSemicolonChars = makePredicate("( [ + * / - , ."); var requireSemicolonChars = makePredicate("( [ + * / - , .");
@ -224,7 +224,7 @@ function OutputStream(options) {
current_pos += str.length; current_pos += str.length;
last = str; last = str;
OUTPUT += str; OUTPUT += str;
}; }
var space = options.beautify ? function() { var space = options.beautify ? function() {
print(" "); print(" ");
@ -260,11 +260,11 @@ function OutputStream(options) {
function force_semicolon() { function force_semicolon() {
might_need_semicolon = false; might_need_semicolon = false;
print(";"); print(";");
}; }
function next_indent() { function next_indent() {
return indentation + options.indent_level; return indentation + options.indent_level;
}; }
function with_block(cont) { function with_block(cont) {
var ret; var ret;
@ -276,7 +276,7 @@ function OutputStream(options) {
indent(); indent();
print("}"); print("}");
return ret; return ret;
}; }
function with_parens(cont) { function with_parens(cont) {
print("("); print("(");
@ -285,7 +285,7 @@ function OutputStream(options) {
var ret = cont(); var ret = cont();
print(")"); print(")");
return ret; return ret;
}; }
function with_square(cont) { function with_square(cont) {
print("["); print("[");
@ -293,17 +293,17 @@ function OutputStream(options) {
var ret = cont(); var ret = cont();
print("]"); print("]");
return ret; return ret;
}; }
function comma() { function comma() {
print(","); print(",");
space(); space();
}; }
function colon() { function colon() {
print(":"); print(":");
if (options.space_colon) space(); if (options.space_colon) space();
}; }
var add_mapping = options.source_map ? function(token, name) { var add_mapping = options.source_map ? function(token, name) {
try { try {
@ -327,7 +327,7 @@ function OutputStream(options) {
function get() { function get() {
return OUTPUT; return OUTPUT;
}; }
if (options.preamble) { if (options.preamble) {
print(options.preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n")); print(options.preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g, "\n"));
@ -370,7 +370,7 @@ function OutputStream(options) {
} }
}; };
}; }
/* -----[ code generators ]----- */ /* -----[ code generators ]----- */
@ -380,7 +380,7 @@ function OutputStream(options) {
function DEFPRINT(nodetype, generator) { function DEFPRINT(nodetype, generator) {
nodetype.DEFMETHOD("_codegen", generator); nodetype.DEFMETHOD("_codegen", generator);
}; }
var use_asm = false; var use_asm = false;
@ -492,7 +492,7 @@ function OutputStream(options) {
} else { } else {
nodetype.DEFMETHOD("needs_parens", func); nodetype.DEFMETHOD("needs_parens", func);
} }
}; }
PARENS(AST_Node, function(){ PARENS(AST_Node, function(){
return false; return false;
@ -666,7 +666,7 @@ function OutputStream(options) {
} }
} }
}); });
}; }
AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output){ AST_StatementWithBody.DEFMETHOD("_do_print_body", function(output){
force_statement(this.body, output); force_statement(this.body, output);
@ -694,7 +694,7 @@ function OutputStream(options) {
display_body(body, false, output); display_body(body, false, output);
}); });
else output.print("{}"); else output.print("{}");
}; }
DEFPRINT(AST_BlockStatement, function(self, output){ DEFPRINT(AST_BlockStatement, function(self, output){
print_bracketed(self.body, output); print_bracketed(self.body, output);
}); });
@ -927,7 +927,7 @@ function OutputStream(options) {
else break; else break;
} }
force_statement(self.body, output); force_statement(self.body, output);
}; }
DEFPRINT(AST_If, function(self, output){ DEFPRINT(AST_If, function(self, output){
output.print("if"); output.print("if");
output.space(); output.space();
@ -1052,7 +1052,7 @@ function OutputStream(options) {
if (ex !== output) throw ex; if (ex !== output) throw ex;
node.print(output, true); node.print(output, true);
} }
}; }
DEFPRINT(AST_VarDef, function(self, output){ DEFPRINT(AST_VarDef, function(self, output){
self.name.print(output); self.name.print(output);
@ -1370,7 +1370,7 @@ function OutputStream(options) {
0x2028 , // unicode "line separator" 0x2028 , // unicode "line separator"
0x2029 , // unicode "paragraph separator" 0x2029 , // unicode "paragraph separator"
].indexOf(code) < 0; ].indexOf(code) < 0;
}; }
DEFPRINT(AST_RegExp, function(self, output){ DEFPRINT(AST_RegExp, function(self, output){
var str = self.getValue().toString(); var str = self.getValue().toString();
@ -1407,7 +1407,7 @@ function OutputStream(options) {
else else
stat.print(output); stat.print(output);
} }
}; }
// return true if the node at the top of the stack (that means the // return true if the node at the top of the stack (that means the
// innermost node in the current output) is lexically the first in // innermost node in the current output) is lexically the first in
@ -1431,12 +1431,12 @@ function OutputStream(options) {
return false; return false;
} }
} }
}; }
// self should be AST_New. decide if we want to show parens or not. // self should be AST_New. decide if we want to show parens or not.
function no_constructor_parens(self, output) { function no_constructor_parens(self, output) {
return self.args.length == 0 && !output.option("beautify"); return self.args.length == 0 && !output.option("beautify");
}; }
function best_of(a) { function best_of(a) {
var best = a[0], len = best.length; var best = a[0], len = best.length;
@ -1447,7 +1447,7 @@ function OutputStream(options) {
} }
} }
return best; return best;
}; }
function make_num(num) { function make_num(num) {
var str = num.toString(10), a = [ str.replace(/^0\./, ".").replace('e+', 'e') ], m; var str = num.toString(10), a = [ str.replace(/^0\./, ".").replace('e+', 'e') ], m;
@ -1467,7 +1467,7 @@ function OutputStream(options) {
str.substr(str.indexOf("."))); str.substr(str.indexOf(".")));
} }
return best_of(a); return best_of(a);
}; }
function make_block(stmt, output) { function make_block(stmt, output) {
if (stmt instanceof AST_BlockStatement) { if (stmt instanceof AST_BlockStatement) {
@ -1479,7 +1479,7 @@ function OutputStream(options) {
stmt.print(output); stmt.print(output);
output.newline(); output.newline();
}); });
}; }
/* -----[ source map generators ]----- */ /* -----[ source map generators ]----- */
@ -1487,7 +1487,7 @@ function OutputStream(options) {
nodetype.DEFMETHOD("add_source_map", function(stream){ nodetype.DEFMETHOD("add_source_map", function(stream){
generator(this, stream); generator(this, stream);
}); });
}; }
// We could easily add info for ALL nodes, but it seems to me that // We could easily add info for ALL nodes, but it seems to me that
// would be quite wasteful, hence this noop in the base class. // would be quite wasteful, hence this noop in the base class.
@ -1495,7 +1495,7 @@ function OutputStream(options) {
function basic_sourcemap_gen(self, output) { function basic_sourcemap_gen(self, output) {
output.add_mapping(self.start); output.add_mapping(self.start);
}; }
// XXX: I'm not exactly sure if we need it for all of these nodes, // XXX: I'm not exactly sure if we need it for all of these nodes,
// or if we should add even more. // or if we should add even more.

View File

@ -133,15 +133,15 @@ function is_letter(code) {
return (code >= 97 && code <= 122) return (code >= 97 && code <= 122)
|| (code >= 65 && code <= 90) || (code >= 65 && code <= 90)
|| (code >= 0xaa && UNICODE.letter.test(String.fromCharCode(code))); || (code >= 0xaa && UNICODE.letter.test(String.fromCharCode(code)));
}; }
function is_digit(code) { function is_digit(code) {
return code >= 48 && code <= 57; return code >= 48 && code <= 57;
}; }
function is_alphanumeric_char(code) { function is_alphanumeric_char(code) {
return is_digit(code) || is_letter(code); return is_digit(code) || is_letter(code);
}; }
function is_unicode_digit(code) { function is_unicode_digit(code) {
return UNICODE.digit.test(String.fromCharCode(code)); return UNICODE.digit.test(String.fromCharCode(code));
@ -149,19 +149,19 @@ function is_unicode_digit(code) {
function is_unicode_combining_mark(ch) { function is_unicode_combining_mark(ch) {
return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch); return UNICODE.non_spacing_mark.test(ch) || UNICODE.space_combining_mark.test(ch);
}; }
function is_unicode_connector_punctuation(ch) { function is_unicode_connector_punctuation(ch) {
return UNICODE.connector_punctuation.test(ch); return UNICODE.connector_punctuation.test(ch);
}; }
function is_identifier(name) { function is_identifier(name) {
return !RESERVED_WORDS(name) && /^[a-z_$][a-z0-9_$]*$/i.test(name); return !RESERVED_WORDS(name) && /^[a-z_$][a-z0-9_$]*$/i.test(name);
}; }
function is_identifier_start(code) { function is_identifier_start(code) {
return code == 36 || code == 95 || is_letter(code); return code == 36 || code == 95 || is_letter(code);
}; }
function is_identifier_char(ch) { function is_identifier_char(ch) {
var code = ch.charCodeAt(0); var code = ch.charCodeAt(0);
@ -173,11 +173,11 @@ function is_identifier_char(ch) {
|| is_unicode_connector_punctuation(ch) || is_unicode_connector_punctuation(ch)
|| is_unicode_digit(code) || is_unicode_digit(code)
; ;
}; }
function is_identifier_string(str){ function is_identifier_string(str){
return /^[a-z_$][a-z0-9_$]*$/i.test(str); return /^[a-z_$][a-z0-9_$]*$/i.test(str);
}; }
function parse_js_number(num) { function parse_js_number(num) {
if (RE_HEX_NUMBER.test(num)) { if (RE_HEX_NUMBER.test(num)) {
@ -194,7 +194,7 @@ function parse_js_number(num) {
var val = parseFloat(num); var val = parseFloat(num);
if (val == num) return val; if (val == num) return val;
} }
}; }
function JS_Parse_Error(message, filename, line, col, pos) { function JS_Parse_Error(message, filename, line, col, pos) {
this.message = message; this.message = message;
@ -203,7 +203,7 @@ function JS_Parse_Error(message, filename, line, col, pos) {
this.col = col; this.col = col;
this.pos = pos; this.pos = pos;
this.stack = new Error().stack; this.stack = new Error().stack;
}; }
JS_Parse_Error.prototype.toString = function() { JS_Parse_Error.prototype.toString = function() {
return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack; return this.message + " (line: " + this.line + ", col: " + this.col + ", pos: " + this.pos + ")" + "\n\n" + this.stack;
@ -211,11 +211,11 @@ JS_Parse_Error.prototype.toString = function() {
function js_error(message, filename, line, col, pos) { function js_error(message, filename, line, col, pos) {
throw new JS_Parse_Error(message, filename, line, col, pos); throw new JS_Parse_Error(message, filename, line, col, pos);
}; }
function is_token(token, type, val) { function is_token(token, type, val) {
return token.type == type && (val == null || token.value == val); return token.type == type && (val == null || token.value == val);
}; }
var EX_EOF = {}; var EX_EOF = {};
@ -235,7 +235,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
comments_before : [] comments_before : []
}; };
function peek() { return S.text.charAt(S.pos); }; function peek() { return S.text.charAt(S.pos); }
function next(signal_eof, in_string) { function next(signal_eof, in_string) {
var ch = S.text.charAt(S.pos++); var ch = S.text.charAt(S.pos++);
@ -254,27 +254,27 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
++S.col; ++S.col;
} }
return ch; return ch;
}; }
function forward(i) { function forward(i) {
while (i-- > 0) next(); while (i-- > 0) next();
}; }
function looking_at(str) { function looking_at(str) {
return S.text.substr(S.pos, str.length) == str; return S.text.substr(S.pos, str.length) == str;
}; }
function find(what, signal_eof) { function find(what, signal_eof) {
var pos = S.text.indexOf(what, S.pos); var pos = S.text.indexOf(what, S.pos);
if (signal_eof && pos == -1) throw EX_EOF; if (signal_eof && pos == -1) throw EX_EOF;
return pos; return pos;
}; }
function start_token() { function start_token() {
S.tokline = S.line; S.tokline = S.line;
S.tokcol = S.col; S.tokcol = S.col;
S.tokpos = S.pos; S.tokpos = S.pos;
}; }
var prev_was_dot = false; var prev_was_dot = false;
function token(type, value, is_comment) { function token(type, value, is_comment) {
@ -307,24 +307,24 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
} }
S.newline_before = false; S.newline_before = false;
return new AST_Token(ret); return new AST_Token(ret);
}; }
function skip_whitespace() { function skip_whitespace() {
var ch; var ch;
while (WHITESPACE_CHARS(ch = peek()) || ch == "\u2028" || ch == "\u2029") while (WHITESPACE_CHARS(ch = peek()) || ch == "\u2028" || ch == "\u2029")
next(); next();
}; }
function read_while(pred) { function read_while(pred) {
var ret = "", ch, i = 0; var ret = "", ch, i = 0;
while ((ch = peek()) && pred(ch, i++)) while ((ch = peek()) && pred(ch, i++))
ret += next(); ret += next();
return ret; return ret;
}; }
function parse_error(err) { function parse_error(err) {
js_error(err, filename, S.tokline, S.tokcol, S.tokpos); js_error(err, filename, S.tokline, S.tokcol, S.tokpos);
}; }
function read_num(prefix) { function read_num(prefix) {
var has_e = false, after_e = false, has_x = false, has_dot = prefix == "."; var has_e = false, after_e = false, has_x = false, has_dot = prefix == ".";
@ -351,7 +351,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
} else { } else {
parse_error("Invalid syntax: " + num); parse_error("Invalid syntax: " + num);
} }
}; }
function read_escaped_char(in_string) { function read_escaped_char(in_string) {
var ch = next(true, in_string); var ch = next(true, in_string);
@ -373,7 +373,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
} }
} }
return ch; return ch;
}; }
function hex_bytes(n) { function hex_bytes(n) {
var num = 0; var num = 0;
@ -384,7 +384,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
num = (num << 4) | digit; num = (num << 4) | digit;
} }
return num; return num;
}; }
var read_string = with_eof_error("Unterminated string constant", function(quote_char){ var read_string = with_eof_error("Unterminated string constant", function(quote_char){
var quote = next(), ret = ""; var quote = next(), ret = "";
@ -431,7 +431,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
S.comments_before.push(token(type, ret, true)); S.comments_before.push(token(type, ret, true));
S.regex_allowed = regex_allowed; S.regex_allowed = regex_allowed;
return next_token(); return next_token();
}; }
var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function(){ var skip_multiline_comment = with_eof_error("Unterminated multiline comment", function(){
var regex_allowed = S.regex_allowed; var regex_allowed = S.regex_allowed;
@ -472,7 +472,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
name = "\\u" + "0000".substr(hex.length) + hex + name.slice(1); name = "\\u" + "0000".substr(hex.length) + hex + name.slice(1);
} }
return name; return name;
}; }
var read_regexp = with_eof_error("Unterminated regular expression", function(regexp){ var read_regexp = with_eof_error("Unterminated regular expression", function(regexp){
var prev_backslash = false, ch, in_class = false; var prev_backslash = false, ch, in_class = false;
@ -510,9 +510,9 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
} else { } else {
return op; return op;
} }
}; }
return token("operator", grow(prefix || next())); return token("operator", grow(prefix || next()));
}; }
function handle_slash() { function handle_slash() {
next(); next();
@ -525,7 +525,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
return skip_multiline_comment(); return skip_multiline_comment();
} }
return S.regex_allowed ? read_regexp("") : read_operator("/"); return S.regex_allowed ? read_regexp("") : read_operator("/");
}; }
function handle_eq_sign() { function handle_eq_sign() {
next(); next();
@ -535,7 +535,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
} else { } else {
return read_operator("="); return read_operator("=");
} }
}; }
function handle_dot() { function handle_dot() {
next(); next();
@ -549,7 +549,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
} }
return token("punc", "."); return token("punc", ".");
}; }
function read_word() { function read_word() {
var word = read_name(); var word = read_name();
@ -558,7 +558,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
: !KEYWORDS(word) ? token("name", word) : !KEYWORDS(word) ? token("name", word)
: OPERATORS(word) ? token("operator", word) : OPERATORS(word) ? token("operator", word)
: token("keyword", word); : token("keyword", word);
}; }
function with_eof_error(eof_error, cont) { function with_eof_error(eof_error, cont) {
return function(x) { return function(x) {
@ -569,7 +569,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
else throw ex; else throw ex;
} }
}; };
}; }
function next_token(force_regexp) { function next_token(force_regexp) {
if (force_regexp != null) if (force_regexp != null)
@ -607,7 +607,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
} }
} }
parse_error("Unexpected character '" + ch + "'"); parse_error("Unexpected character '" + ch + "'");
}; }
next_token.next = next; next_token.next = next;
next_token.peek = peek; next_token.peek = peek;
@ -619,7 +619,7 @@ function tokenizer($TEXT, filename, html5_comments, shebang) {
return next_token; return next_token;
}; }
/* -----[ Parser (constants) ]----- */ /* -----[ Parser (constants) ]----- */
@ -699,9 +699,9 @@ function parse($TEXT, options) {
function is(type, value) { function is(type, value) {
return is_token(S.token, type, value); return is_token(S.token, type, value);
}; }
function peek() { return S.peeked || (S.peeked = S.input()); }; function peek() { return S.peeked || (S.peeked = S.input()); }
function next() { function next() {
S.prev = S.token; S.prev = S.token;
@ -715,11 +715,11 @@ function parse($TEXT, options) {
S.token.type == "string" || is("punc", ";") S.token.type == "string" || is("punc", ";")
); );
return S.token; return S.token;
}; }
function prev() { function prev() {
return S.prev; return S.prev;
}; }
function croak(msg, line, col, pos) { function croak(msg, line, col, pos) {
var ctx = S.input.context(); var ctx = S.input.context();
@ -728,44 +728,44 @@ function parse($TEXT, options) {
line != null ? line : ctx.tokline, line != null ? line : ctx.tokline,
col != null ? col : ctx.tokcol, col != null ? col : ctx.tokcol,
pos != null ? pos : ctx.tokpos); pos != null ? pos : ctx.tokpos);
}; }
function token_error(token, msg) { function token_error(token, msg) {
croak(msg, token.line, token.col); croak(msg, token.line, token.col);
}; }
function unexpected(token) { function unexpected(token) {
if (token == null) if (token == null)
token = S.token; token = S.token;
token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")"); token_error(token, "Unexpected token: " + token.type + " (" + token.value + ")");
}; }
function expect_token(type, val) { function expect_token(type, val) {
if (is(type, val)) { if (is(type, val)) {
return next(); return next();
} }
token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»"); token_error(S.token, "Unexpected token " + S.token.type + " «" + S.token.value + "»" + ", expected " + type + " «" + val + "»");
}; }
function expect(punc) { return expect_token("punc", punc); }; function expect(punc) { return expect_token("punc", punc); }
function can_insert_semicolon() { function can_insert_semicolon() {
return !options.strict && ( return !options.strict && (
S.token.nlb || is("eof") || is("punc", "}") S.token.nlb || is("eof") || is("punc", "}")
); );
}; }
function semicolon(optional) { function semicolon(optional) {
if (is("punc", ";")) next(); if (is("punc", ";")) next();
else if (!optional && !can_insert_semicolon()) unexpected(); else if (!optional && !can_insert_semicolon()) unexpected();
}; }
function parenthesised() { function parenthesised() {
expect("("); expect("(");
var exp = expression(true); var exp = expression(true);
expect(")"); expect(")");
return exp; return exp;
}; }
function embed_tokens(parser) { function embed_tokens(parser) {
return function() { return function() {
@ -776,14 +776,14 @@ function parse($TEXT, options) {
expr.end = end; expr.end = end;
return expr; return expr;
}; };
}; }
function handle_regexp() { function handle_regexp() {
if (is("operator", "/") || is("operator", "/=")) { if (is("operator", "/") || is("operator", "/=")) {
S.peeked = null; S.peeked = null;
S.token = S.input(S.token.value.substr(1)); // force regexp S.token = S.input(S.token.value.substr(1)); // force regexp
} }
}; }
var statement = embed_tokens(function() { var statement = embed_tokens(function() {
var tmp; var tmp;
@ -941,11 +941,11 @@ function parse($TEXT, options) {
}); });
} }
return new AST_LabeledStatement({ body: stat, label: label }); return new AST_LabeledStatement({ body: stat, label: label });
}; }
function simple_statement(tmp) { function simple_statement(tmp) {
return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) }); return new AST_SimpleStatement({ body: (tmp = expression(true), semicolon(), tmp) });
}; }
function break_cont(type) { function break_cont(type) {
var label = null, ldef; var label = null, ldef;
@ -964,7 +964,7 @@ function parse($TEXT, options) {
var stat = new type({ label: label }); var stat = new type({ label: label });
if (ldef) ldef.references.push(stat); if (ldef) ldef.references.push(stat);
return stat; return stat;
}; }
function for_() { function for_() {
expect("("); expect("(");
@ -989,7 +989,7 @@ function parse($TEXT, options) {
} }
} }
return regular_for(init); return regular_for(init);
}; }
function regular_for(init) { function regular_for(init) {
expect(";"); expect(";");
@ -1003,7 +1003,7 @@ function parse($TEXT, options) {
step : step, step : step,
body : in_loop(statement) body : in_loop(statement)
}); });
}; }
function for_of(init) { function for_of(init) {
var lhs = init instanceof AST_Var ? init.definitions[0].name : null; var lhs = init instanceof AST_Var ? init.definitions[0].name : null;
@ -1015,7 +1015,7 @@ function parse($TEXT, options) {
object : obj, object : obj,
body : in_loop(statement) body : in_loop(statement)
}); });
}; }
function for_in(init) { function for_in(init) {
var lhs = init instanceof AST_Var ? init.definitions[0].name : null; var lhs = init instanceof AST_Var ? init.definitions[0].name : null;
@ -1027,7 +1027,7 @@ function parse($TEXT, options) {
object : obj, object : obj,
body : in_loop(statement) body : in_loop(statement)
}); });
}; }
var arrow_function = function(args) { var arrow_function = function(args) {
expect_token("arrow", "=>"); expect_token("arrow", "=>");
@ -1121,7 +1121,7 @@ function parse($TEXT, options) {
body : body, body : body,
alternative : belse alternative : belse
}); });
}; }
function block_() { function block_() {
expect("{"); expect("{");
@ -1132,7 +1132,7 @@ function parse($TEXT, options) {
} }
next(); next();
return a; return a;
}; }
function switch_body_() { function switch_body_() {
expect("{"); expect("{");
@ -1167,7 +1167,7 @@ function parse($TEXT, options) {
if (branch) branch.end = prev(); if (branch) branch.end = prev();
next(); next();
return a; return a;
}; }
function try_() { function try_() {
var body = block_(), bcatch = null, bfinally = null; var body = block_(), bcatch = null, bfinally = null;
@ -1200,7 +1200,7 @@ function parse($TEXT, options) {
bcatch : bcatch, bcatch : bcatch,
bfinally : bfinally bfinally : bfinally
}); });
}; }
function vardefs(no_in, in_const) { function vardefs(no_in, in_const) {
var a = []; var a = [];
@ -1228,7 +1228,7 @@ function parse($TEXT, options) {
next(); next();
} }
return a; return a;
}; }
var destructuring_ = embed_tokens(function (sym_type) { var destructuring_ = embed_tokens(function (sym_type) {
var is_array = is("punc", "["); var is_array = is("punc", "[");
@ -1359,7 +1359,7 @@ function parse($TEXT, options) {
} }
next(); next();
return ret; return ret;
}; }
var expr_atom = function(allow_calls) { var expr_atom = function(allow_calls) {
if (is("operator", "new")) { if (is("operator", "new")) {
@ -1450,7 +1450,7 @@ function parse($TEXT, options) {
} }
next(); next();
return a; return a;
}; }
var array_ = embed_tokens(function() { var array_ = embed_tokens(function() {
expect("["); expect("[");
@ -1622,7 +1622,7 @@ function parse($TEXT, options) {
default: default:
unexpected(); unexpected();
} }
}; }
function as_name() { function as_name() {
var tmp = S.token; var tmp = S.token;
@ -1636,7 +1636,7 @@ function parse($TEXT, options) {
default: default:
unexpected(); unexpected();
} }
}; }
function _make_symbol(type) { function _make_symbol(type) {
var name = S.token.value; var name = S.token.value;
@ -1647,7 +1647,7 @@ function parse($TEXT, options) {
start : S.token, start : S.token,
end : S.token end : S.token
}); });
}; }
function as_symbol(type, noerror) { function as_symbol(type, noerror) {
if (!is("name")) { if (!is("name")) {
@ -1657,7 +1657,7 @@ function parse($TEXT, options) {
var sym = _make_symbol(type); var sym = _make_symbol(type);
next(); next();
return sym; return sym;
}; }
var subscripts = function(expr, allow_calls) { var subscripts = function(expr, allow_calls) {
var start = expr.start; var start = expr.start;
@ -1736,7 +1736,7 @@ function parse($TEXT, options) {
if ((op == "++" || op == "--") && !is_assignable(expr)) if ((op == "++" || op == "--") && !is_assignable(expr))
croak("Invalid use of " + op + " operator"); croak("Invalid use of " + op + " operator");
return new ctor({ operator: op, expression: expr }); return new ctor({ operator: op, expression: expr });
}; }
var expr_op = function(left, min_prec, no_in) { var expr_op = function(left, min_prec, no_in) {
var op = is("operator") ? S.token.value : null; var op = is("operator") ? S.token.value : null;
@ -1758,7 +1758,7 @@ function parse($TEXT, options) {
function expr_ops(no_in) { function expr_ops(no_in) {
return expr_op(maybe_unary(true), 0, no_in); return expr_op(maybe_unary(true), 0, no_in);
}; }
var maybe_conditional = function(no_in) { var maybe_conditional = function(no_in) {
var start = S.token; var start = S.token;
@ -1783,7 +1783,7 @@ function parse($TEXT, options) {
if (expr instanceof AST_This) return false; if (expr instanceof AST_This) return false;
if (expr instanceof AST_Super) return false; if (expr instanceof AST_Super) return false;
return (expr instanceof AST_PropAccess || expr instanceof AST_Symbol); return (expr instanceof AST_PropAccess || expr instanceof AST_Symbol);
}; }
// In ES6, AssignmentExpression can also be an ArrowFunction // In ES6, AssignmentExpression can also be an ArrowFunction
var maybe_assign = function(no_in) { var maybe_assign = function(no_in) {
@ -1843,7 +1843,7 @@ function parse($TEXT, options) {
var ret = cont(); var ret = cont();
--S.in_loop; --S.in_loop;
return ret; return ret;
}; }
if (options.expression) { if (options.expression) {
return expression(true); return expression(true);
@ -1865,4 +1865,4 @@ function parse($TEXT, options) {
return toplevel; return toplevel;
})(); })();
}; }

View File

@ -54,7 +54,7 @@ function SymbolDef(scope, index, orig) {
this.undeclared = false; this.undeclared = false;
this.constant = false; this.constant = false;
this.index = index; this.index = index;
}; }
SymbolDef.prototype = { SymbolDef.prototype = {
unmangleable: function(options) { unmangleable: function(options) {
@ -567,7 +567,7 @@ var base54 = (function() {
base = 64; base = 64;
} while (num > 0); } while (num > 0);
return ret; return ret;
}; }
return base54; return base54;
})(); })();

View File

@ -89,4 +89,4 @@ function SourceMap(options) {
get : function() { return generator }, get : function() { return generator },
toString : function() { return JSON.stringify(generator.toJSON()); } toString : function() { return JSON.stringify(generator.toJSON()); }
}; };
}; }

View File

@ -73,13 +73,13 @@ TreeTransformer.prototype = new TreeWalker;
tw.pop(this); tw.pop(this);
return x; return x;
}); });
}; }
function do_list(list, tw) { function do_list(list, tw) {
return MAP(list, function(node){ return MAP(list, function(node){
return node.transform(tw, true); return node.transform(tw, true);
}); });
}; }
_(AST_Node, noop); _(AST_Node, noop);

View File

@ -48,29 +48,29 @@ function array_to_hash(a) {
for (var i = 0; i < a.length; ++i) for (var i = 0; i < a.length; ++i)
ret[a[i]] = true; ret[a[i]] = true;
return ret; return ret;
}; }
function slice(a, start) { function slice(a, start) {
return Array.prototype.slice.call(a, start || 0); return Array.prototype.slice.call(a, start || 0);
}; }
function characters(str) { function characters(str) {
return str.split(""); return str.split("");
}; }
function member(name, array) { function member(name, array) {
for (var i = array.length; --i >= 0;) for (var i = array.length; --i >= 0;)
if (array[i] == name) if (array[i] == name)
return true; return true;
return false; return false;
}; }
function find_if(func, array) { function find_if(func, array) {
for (var i = 0, n = array.length; i < n; ++i) { for (var i = 0, n = array.length; i < n; ++i) {
if (func(array[i])) if (func(array[i]))
return array[i]; return array[i];
} }
}; }
function repeat_string(str, i) { function repeat_string(str, i) {
if (i <= 0) return ""; if (i <= 0) return "";
@ -79,13 +79,13 @@ function repeat_string(str, i) {
d += d; d += d;
if (i & 1) d += str; if (i & 1) d += str;
return d; return d;
}; }
function DefaultsError(msg, defs) { function DefaultsError(msg, defs) {
Error.call(this, msg); Error.call(this, msg);
this.msg = msg; this.msg = msg;
this.defs = defs; this.defs = defs;
}; }
DefaultsError.prototype = Object.create(Error.prototype); DefaultsError.prototype = Object.create(Error.prototype);
DefaultsError.prototype.constructor = DefaultsError; DefaultsError.prototype.constructor = DefaultsError;
@ -103,7 +103,7 @@ function defaults(args, defs, croak) {
ret[i] = (args && args.hasOwnProperty(i)) ? args[i] : defs[i]; ret[i] = (args && args.hasOwnProperty(i)) ? args[i] : defs[i];
} }
return ret; return ret;
}; }
function merge(obj, ext) { function merge(obj, ext) {
var count = 0; var count = 0;
@ -112,9 +112,9 @@ function merge(obj, ext) {
count++; count++;
} }
return count; return count;
}; }
function noop() {}; function noop() {}
var MAP = (function(){ var MAP = (function(){
function MAP(a, f, backwards) { function MAP(a, f, backwards) {
@ -139,7 +139,7 @@ var MAP = (function(){
} }
} }
return is_last; return is_last;
}; }
if (a instanceof Array) { if (a instanceof Array) {
if (backwards) { if (backwards) {
for (i = a.length; --i >= 0;) if (doit()) break; for (i = a.length; --i >= 0;) if (doit()) break;
@ -153,33 +153,33 @@ var MAP = (function(){
for (i in a) if (a.hasOwnProperty(i)) if (doit()) break; for (i in a) if (a.hasOwnProperty(i)) if (doit()) break;
} }
return top.concat(ret); return top.concat(ret);
}; }
MAP.at_top = function(val) { return new AtTop(val) }; MAP.at_top = function(val) { return new AtTop(val) };
MAP.splice = function(val) { return new Splice(val) }; MAP.splice = function(val) { return new Splice(val) };
MAP.last = function(val) { return new Last(val) }; MAP.last = function(val) { return new Last(val) };
var skip = MAP.skip = {}; var skip = MAP.skip = {};
function AtTop(val) { this.v = val }; function AtTop(val) { this.v = val }
function Splice(val) { this.v = val }; function Splice(val) { this.v = val }
function Last(val) { this.v = val }; function Last(val) { this.v = val }
return MAP; return MAP;
})(); })();
function push_uniq(array, el) { function push_uniq(array, el) {
if (array.indexOf(el) < 0) if (array.indexOf(el) < 0)
array.push(el); array.push(el);
}; }
function string_template(text, props) { function string_template(text, props) {
return text.replace(/\{(.+?)\}/g, function(str, p){ return text.replace(/\{(.+?)\}/g, function(str, p){
return props[p]; return props[p];
}); });
}; }
function remove(array, el) { function remove(array, el) {
for (var i = array.length; --i >= 0;) { for (var i = array.length; --i >= 0;) {
if (array[i] === el) array.splice(i, 1); if (array[i] === el) array.splice(i, 1);
} }
}; }
function mergeSort(array, cmp) { function mergeSort(array, cmp) {
if (array.length < 2) return array.slice(); if (array.length < 2) return array.slice();
@ -193,7 +193,7 @@ function mergeSort(array, cmp) {
if (ai < a.length) r.push.apply(r, a.slice(ai)); if (ai < a.length) r.push.apply(r, a.slice(ai));
if (bi < b.length) r.push.apply(r, b.slice(bi)); if (bi < b.length) r.push.apply(r, b.slice(bi));
return r; return r;
}; }
function _ms(a) { function _ms(a) {
if (a.length <= 1) if (a.length <= 1)
return a; return a;
@ -201,21 +201,21 @@ function mergeSort(array, cmp) {
left = _ms(left); left = _ms(left);
right = _ms(right); right = _ms(right);
return merge(left, right); return merge(left, right);
}; }
return _ms(array); return _ms(array);
}; }
function set_difference(a, b) { function set_difference(a, b) {
return a.filter(function(el){ return a.filter(function(el){
return b.indexOf(el) < 0; return b.indexOf(el) < 0;
}); });
}; }
function set_intersection(a, b) { function set_intersection(a, b) {
return a.filter(function(el){ return a.filter(function(el){
return b.indexOf(el) >= 0; return b.indexOf(el) >= 0;
}); });
}; }
// this function is taken from Acorn [1], written by Marijn Haverbeke // this function is taken from Acorn [1], written by Marijn Haverbeke
// [1] https://github.com/marijnh/acorn // [1] https://github.com/marijnh/acorn
@ -252,19 +252,19 @@ function makePredicate(words) {
compareTo(words); compareTo(words);
} }
return new Function("str", f); return new Function("str", f);
}; }
function all(array, predicate) { function all(array, predicate) {
for (var i = array.length; --i >= 0;) for (var i = array.length; --i >= 0;)
if (!predicate(array[i])) if (!predicate(array[i]))
return false; return false;
return true; return true;
}; }
function Dictionary() { function Dictionary() {
this._values = Object.create(null); this._values = Object.create(null);
this._size = 0; this._size = 0;
}; }
Dictionary.prototype = { Dictionary.prototype = {
set: function(key, val) { set: function(key, val) {
if (!this.has(key)) ++this._size; if (!this.has(key)) ++this._size;

View File

@ -124,4 +124,3 @@ module.exports = function () {
if (module.parent === null) { if (module.parent === null) {
module.exports(); module.exports();
} }

View File

@ -195,7 +195,7 @@ function parse_test(file) {
}); });
block.walk(tw); block.walk(tw);
return test; return test;
}; }
} }
function make_code(ast, options) { function make_code(ast, options) {

View File

@ -170,7 +170,7 @@ exports.describe_ast = function() {
}); });
}); });
} }
}; }
doitem(UglifyJS.AST_Node); doitem(UglifyJS.AST_Node);
return out + ""; return out + "";
}; };