uglifier 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of uglifier might be problematic. Click here for more details.
- data/.gitmodules +1 -1
- data/.travis.yml +15 -0
- data/VERSION +1 -1
- data/lib/uglify.js +132 -68
- data/uglifier.gemspec +8 -9
- metadata +28 -13
data/.gitmodules
CHANGED
data/.travis.yml
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
rvm:
|
2
2
|
- 1.8.7
|
3
3
|
- 1.9.2
|
4
|
+
- jruby
|
4
5
|
before_script: "git submodule update --init --recursive"
|
6
|
+
env:
|
7
|
+
- EXECJS_RUNTIME=RubyRacer
|
8
|
+
- EXECJS_RUNTIME=Mustang
|
9
|
+
- EXECJS_RUNTIME=RubyRhino
|
10
|
+
matrix:
|
11
|
+
exclude:
|
12
|
+
- rvm: 1.8.7
|
13
|
+
env: EXECJS_RUNTIME=RubyRhino
|
14
|
+
- rvm: 1.9.2
|
15
|
+
env: EXECJS_RUNTIME=RubyRhino
|
16
|
+
- rvm: jruby
|
17
|
+
env: EXECJS_RUNTIME=RubyRacer
|
18
|
+
- rvm: jruby
|
19
|
+
env: EXECJS_RUNTIME=Mustang
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.4
|
data/lib/uglify.js
CHANGED
@@ -239,7 +239,7 @@ var OPERATORS = array_to_hash([
|
|
239
239
|
"||"
|
240
240
|
]);
|
241
241
|
|
242
|
-
var WHITESPACE_CHARS = array_to_hash(characters(" \u00a0\n\r\t\f\u000b\u200b"));
|
242
|
+
var WHITESPACE_CHARS = array_to_hash(characters(" \u00a0\n\r\t\f\u000b\u200b\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000"));
|
243
243
|
|
244
244
|
var PUNC_BEFORE_EXPRESSION = array_to_hash(characters("[{}(,.;:"));
|
245
245
|
|
@@ -307,11 +307,7 @@ function JS_Parse_Error(message, line, col, pos) {
|
|
307
307
|
this.line = line;
|
308
308
|
this.col = col;
|
309
309
|
this.pos = pos;
|
310
|
-
|
311
|
-
({})();
|
312
|
-
} catch(ex) {
|
313
|
-
this.stack = ex.stack;
|
314
|
-
};
|
310
|
+
this.stack = new Error().stack;
|
315
311
|
};
|
316
312
|
|
317
313
|
JS_Parse_Error.prototype.toString = function() {
|
@@ -345,12 +341,12 @@ function tokenizer($TEXT) {
|
|
345
341
|
|
346
342
|
function peek() { return S.text.charAt(S.pos); };
|
347
343
|
|
348
|
-
function next(signal_eof) {
|
344
|
+
function next(signal_eof, in_string) {
|
349
345
|
var ch = S.text.charAt(S.pos++);
|
350
346
|
if (signal_eof && !ch)
|
351
347
|
throw EX_EOF;
|
352
348
|
if (ch == "\n") {
|
353
|
-
S.newline_before =
|
349
|
+
S.newline_before = S.newline_before || !in_string;
|
354
350
|
++S.line;
|
355
351
|
S.col = 0;
|
356
352
|
} else {
|
@@ -447,8 +443,8 @@ function tokenizer($TEXT) {
|
|
447
443
|
}
|
448
444
|
};
|
449
445
|
|
450
|
-
function read_escaped_char() {
|
451
|
-
var ch = next(true);
|
446
|
+
function read_escaped_char(in_string) {
|
447
|
+
var ch = next(true, in_string);
|
452
448
|
switch (ch) {
|
453
449
|
case "n" : return "\n";
|
454
450
|
case "r" : return "\r";
|
@@ -496,7 +492,7 @@ function tokenizer($TEXT) {
|
|
496
492
|
return false;
|
497
493
|
});
|
498
494
|
if (octal_len > 0) ch = String.fromCharCode(parseInt(ch, 8));
|
499
|
-
else ch = read_escaped_char();
|
495
|
+
else ch = read_escaped_char(true);
|
500
496
|
}
|
501
497
|
else if (ch == quote) break;
|
502
498
|
ret += ch;
|
@@ -558,9 +554,9 @@ function tokenizer($TEXT) {
|
|
558
554
|
return name;
|
559
555
|
};
|
560
556
|
|
561
|
-
function read_regexp() {
|
557
|
+
function read_regexp(regexp) {
|
562
558
|
return with_eof_error("Unterminated regular expression", function(){
|
563
|
-
var prev_backslash = false,
|
559
|
+
var prev_backslash = false, ch, in_class = false;
|
564
560
|
while ((ch = next(true))) if (prev_backslash) {
|
565
561
|
regexp += "\\" + ch;
|
566
562
|
prev_backslash = false;
|
@@ -609,7 +605,7 @@ function tokenizer($TEXT) {
|
|
609
605
|
S.regex_allowed = regex_allowed;
|
610
606
|
return next_token();
|
611
607
|
}
|
612
|
-
return S.regex_allowed ? read_regexp() : read_operator("/");
|
608
|
+
return S.regex_allowed ? read_regexp("") : read_operator("/");
|
613
609
|
};
|
614
610
|
|
615
611
|
function handle_dot() {
|
@@ -640,8 +636,8 @@ function tokenizer($TEXT) {
|
|
640
636
|
};
|
641
637
|
|
642
638
|
function next_token(force_regexp) {
|
643
|
-
if (force_regexp)
|
644
|
-
return read_regexp();
|
639
|
+
if (force_regexp != null)
|
640
|
+
return read_regexp(force_regexp);
|
645
641
|
skip_whitespace();
|
646
642
|
start_token();
|
647
643
|
var ch = peek();
|
@@ -830,9 +826,9 @@ function parse($TEXT, exigent_mode, embed_tokens) {
|
|
830
826
|
};
|
831
827
|
|
832
828
|
var statement = maybe_embed_tokens(function() {
|
833
|
-
if (is("operator", "/")) {
|
829
|
+
if (is("operator", "/") || is("operator", "/=")) {
|
834
830
|
S.peeked = null;
|
835
|
-
S.token = S.input(
|
831
|
+
S.token = S.input(S.token.value.substr(1)); // force regexp
|
836
832
|
}
|
837
833
|
switch (S.token.type) {
|
838
834
|
case "num":
|
@@ -902,6 +898,8 @@ function parse($TEXT, exigent_mode, embed_tokens) {
|
|
902
898
|
return as("switch", parenthesised(), switch_block_());
|
903
899
|
|
904
900
|
case "throw":
|
901
|
+
if (S.token.nlb)
|
902
|
+
croak("Illegal newline after 'throw'");
|
905
903
|
return as("throw", prog1(expression, semicolon));
|
906
904
|
|
907
905
|
case "try":
|
@@ -1277,7 +1275,7 @@ function parse($TEXT, exigent_mode, embed_tokens) {
|
|
1277
1275
|
|
1278
1276
|
function is_assignable(expr) {
|
1279
1277
|
if (!exigent_mode) return true;
|
1280
|
-
switch (expr[0]) {
|
1278
|
+
switch (expr[0]+"") {
|
1281
1279
|
case "dot":
|
1282
1280
|
case "sub":
|
1283
1281
|
case "new":
|
@@ -1351,7 +1349,7 @@ function array_to_hash(a) {
|
|
1351
1349
|
};
|
1352
1350
|
|
1353
1351
|
function slice(a, start) {
|
1354
|
-
return Array.prototype.slice.call(a, start
|
1352
|
+
return Array.prototype.slice.call(a, start || 0);
|
1355
1353
|
};
|
1356
1354
|
|
1357
1355
|
function characters(str) {
|
@@ -1457,7 +1455,7 @@ var jsp = require("./parse-js"),
|
|
1457
1455
|
|
1458
1456
|
/* -----[ helper for AST traversal ]----- */
|
1459
1457
|
|
1460
|
-
function ast_walker(
|
1458
|
+
function ast_walker() {
|
1461
1459
|
function _vardefs(defs) {
|
1462
1460
|
return [ this[0], MAP(defs, function(def){
|
1463
1461
|
var a = [ def[0] ];
|
@@ -1614,6 +1612,17 @@ function ast_walker(ast) {
|
|
1614
1612
|
}
|
1615
1613
|
};
|
1616
1614
|
|
1615
|
+
function dive(ast) {
|
1616
|
+
if (ast == null)
|
1617
|
+
return null;
|
1618
|
+
try {
|
1619
|
+
stack.push(ast);
|
1620
|
+
return walkers[ast[0]].apply(ast, ast.slice(1));
|
1621
|
+
} finally {
|
1622
|
+
stack.pop();
|
1623
|
+
}
|
1624
|
+
};
|
1625
|
+
|
1617
1626
|
function with_walkers(walkers, cont){
|
1618
1627
|
var save = {}, i;
|
1619
1628
|
for (i in walkers) if (HOP(walkers, i)) {
|
@@ -1630,6 +1639,7 @@ function ast_walker(ast) {
|
|
1630
1639
|
|
1631
1640
|
return {
|
1632
1641
|
walk: walk,
|
1642
|
+
dive: dive,
|
1633
1643
|
with_walkers: with_walkers,
|
1634
1644
|
parent: function() {
|
1635
1645
|
return stack[stack.length - 2]; // last one is current node
|
@@ -2023,21 +2033,6 @@ function boolean_expr(expr) {
|
|
2023
2033
|
);
|
2024
2034
|
};
|
2025
2035
|
|
2026
|
-
function make_conditional(c, t, e) {
|
2027
|
-
var make_real_conditional = function() {
|
2028
|
-
if (c[0] == "unary-prefix" && c[1] == "!") {
|
2029
|
-
return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ];
|
2030
|
-
} else {
|
2031
|
-
return e ? [ "conditional", c, t, e ] : [ "binary", "&&", c, t ];
|
2032
|
-
}
|
2033
|
-
};
|
2034
|
-
// shortcut the conditional if the expression has a constant value
|
2035
|
-
return when_constant(c, function(ast, val){
|
2036
|
-
warn_unreachable(val ? e : t);
|
2037
|
-
return (val ? t : e);
|
2038
|
-
}, make_real_conditional);
|
2039
|
-
};
|
2040
|
-
|
2041
2036
|
function empty(b) {
|
2042
2037
|
return !b || (b[0] == "block" && (!b[1] || b[1].length == 0));
|
2043
2038
|
};
|
@@ -2065,6 +2060,7 @@ var when_constant = (function(){
|
|
2065
2060
|
switch (expr[1]) {
|
2066
2061
|
case "true": return true;
|
2067
2062
|
case "false": return false;
|
2063
|
+
case "null": return null;
|
2068
2064
|
}
|
2069
2065
|
break;
|
2070
2066
|
case "unary-prefix":
|
@@ -2087,6 +2083,7 @@ var when_constant = (function(){
|
|
2087
2083
|
case "+" : return evaluate(left) + evaluate(right);
|
2088
2084
|
case "*" : return evaluate(left) * evaluate(right);
|
2089
2085
|
case "/" : return evaluate(left) / evaluate(right);
|
2086
|
+
case "%" : return evaluate(left) % evaluate(right);
|
2090
2087
|
case "-" : return evaluate(left) - evaluate(right);
|
2091
2088
|
case "<<" : return evaluate(left) << evaluate(right);
|
2092
2089
|
case ">>" : return evaluate(left) >> evaluate(right);
|
@@ -2365,8 +2362,8 @@ function ast_squeeze(ast, options) {
|
|
2365
2362
|
options = defaults(options, {
|
2366
2363
|
make_seqs : true,
|
2367
2364
|
dead_code : true,
|
2368
|
-
|
2369
|
-
|
2365
|
+
no_warnings : false,
|
2366
|
+
keep_comps : true
|
2370
2367
|
});
|
2371
2368
|
|
2372
2369
|
var w = ast_walker(), walk = w.walk, scope;
|
@@ -2403,6 +2400,24 @@ function ast_squeeze(ast, options) {
|
|
2403
2400
|
return not_c;
|
2404
2401
|
};
|
2405
2402
|
|
2403
|
+
function make_conditional(c, t, e) {
|
2404
|
+
var make_real_conditional = function() {
|
2405
|
+
if (c[0] == "unary-prefix" && c[1] == "!") {
|
2406
|
+
return e ? [ "conditional", c[2], e, t ] : [ "binary", "||", c[2], t ];
|
2407
|
+
} else {
|
2408
|
+
return e ? best_of(
|
2409
|
+
[ "conditional", c, t, e ],
|
2410
|
+
[ "conditional", negate(c), e, t ]
|
2411
|
+
) : [ "binary", "&&", c, t ];
|
2412
|
+
}
|
2413
|
+
};
|
2414
|
+
// shortcut the conditional if the expression has a constant value
|
2415
|
+
return when_constant(c, function(ast, val){
|
2416
|
+
warn_unreachable(val ? e : t);
|
2417
|
+
return (val ? t : e);
|
2418
|
+
}, make_real_conditional);
|
2419
|
+
};
|
2420
|
+
|
2406
2421
|
function with_scope(s, cont) {
|
2407
2422
|
var _scope = scope;
|
2408
2423
|
scope = s;
|
@@ -2542,11 +2557,13 @@ function ast_squeeze(ast, options) {
|
|
2542
2557
|
function make_if(c, t, e) {
|
2543
2558
|
return when_constant(c, function(ast, val){
|
2544
2559
|
if (val) {
|
2560
|
+
t = walk(t);
|
2545
2561
|
warn_unreachable(e);
|
2546
|
-
return t;
|
2562
|
+
return t || [ "block" ];
|
2547
2563
|
} else {
|
2564
|
+
e = walk(e);
|
2548
2565
|
warn_unreachable(t);
|
2549
|
-
return e;
|
2566
|
+
return e || [ "block" ];
|
2550
2567
|
}
|
2551
2568
|
}, function() {
|
2552
2569
|
return make_real_if(c, t, e);
|
@@ -2667,7 +2684,15 @@ function ast_squeeze(ast, options) {
|
|
2667
2684
|
return when_constant([ "binary", op, walk(left), walk(right) ], function yes(c){
|
2668
2685
|
return best_of(walk(c), this);
|
2669
2686
|
}, function no() {
|
2670
|
-
return
|
2687
|
+
return function(){
|
2688
|
+
if(op != "==" && op != "!=") return;
|
2689
|
+
var l = walk(left), r = walk(right);
|
2690
|
+
if(l && l[0] == "unary-prefix" && l[1] == "!" && l[2][0] == "num")
|
2691
|
+
left = ['num', +!l[2][1]];
|
2692
|
+
else if (r && r[0] == "unary-prefix" && r[1] == "!" && r[2][0] == "num")
|
2693
|
+
right = ['num', +!r[2][1]];
|
2694
|
+
return ["binary", op, left, right];
|
2695
|
+
}() || this;
|
2671
2696
|
});
|
2672
2697
|
},
|
2673
2698
|
"conditional": function(c, t, e) {
|
@@ -2696,21 +2721,18 @@ function ast_squeeze(ast, options) {
|
|
2696
2721
|
case "false": return [ "unary-prefix", "!", [ "num", 1 ]];
|
2697
2722
|
}
|
2698
2723
|
},
|
2699
|
-
"
|
2700
|
-
|
2701
|
-
|
2702
|
-
|
2703
|
-
|
2704
|
-
|
2705
|
-
|
2706
|
-
|
2707
|
-
|
2708
|
-
"call": function(expr, args) {
|
2709
|
-
if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
|
2710
|
-
return [ "array", args ];
|
2724
|
+
"while": _do_while,
|
2725
|
+
"assign": function(op, lvalue, rvalue) {
|
2726
|
+
lvalue = walk(lvalue);
|
2727
|
+
rvalue = walk(rvalue);
|
2728
|
+
var okOps = [ '+', '-', '/', '*', '%', '>>', '<<', '>>>', '|', '^', '&' ];
|
2729
|
+
if (op === true && lvalue[0] === "name" && rvalue[0] === "binary" &&
|
2730
|
+
~okOps.indexOf(rvalue[1]) && rvalue[2][0] === "name" &&
|
2731
|
+
rvalue[2][1] === lvalue[1]) {
|
2732
|
+
return [ this[0], rvalue[1], lvalue, rvalue[3] ]
|
2711
2733
|
}
|
2712
|
-
|
2713
|
-
|
2734
|
+
return [ this[0], op, lvalue, rvalue ];
|
2735
|
+
}
|
2714
2736
|
}, function() {
|
2715
2737
|
for (var i = 0; i < 2; ++i) {
|
2716
2738
|
ast = prepare_ifs(ast);
|
@@ -2731,7 +2753,8 @@ var DOT_CALL_NO_PARENS = jsp.array_to_hash([
|
|
2731
2753
|
"dot",
|
2732
2754
|
"sub",
|
2733
2755
|
"call",
|
2734
|
-
"regexp"
|
2756
|
+
"regexp",
|
2757
|
+
"defun"
|
2735
2758
|
]);
|
2736
2759
|
|
2737
2760
|
function make_string(str, ascii_only) {
|
@@ -2881,8 +2904,13 @@ function gen_code(ast, options) {
|
|
2881
2904
|
function make_num(num) {
|
2882
2905
|
var str = num.toString(10), a = [ str.replace(/^0\./, ".") ], m;
|
2883
2906
|
if (Math.floor(num) === num) {
|
2884
|
-
|
2885
|
-
|
2907
|
+
if (num >= 0) {
|
2908
|
+
a.push("0x" + num.toString(16).toLowerCase(), // probably pointless
|
2909
|
+
"0" + num.toString(8)); // same.
|
2910
|
+
} else {
|
2911
|
+
a.push("-0x" + (-num).toString(16).toLowerCase(), // probably pointless
|
2912
|
+
"-0" + (-num).toString(8)); // same.
|
2913
|
+
}
|
2886
2914
|
if ((m = /^(.*?)(0+)$/.exec(num))) {
|
2887
2915
|
a.push(m[1] + "e" + m[2].length);
|
2888
2916
|
}
|
@@ -2933,7 +2961,9 @@ function gen_code(ast, options) {
|
|
2933
2961
|
return add_spaces([ "throw", make(expr) ]) + ";";
|
2934
2962
|
},
|
2935
2963
|
"new": function(ctor, args) {
|
2936
|
-
args = args.length > 0 ? "(" + add_commas(MAP(args,
|
2964
|
+
args = args.length > 0 ? "(" + add_commas(MAP(args, function(expr){
|
2965
|
+
return parenthesize(expr, "seq");
|
2966
|
+
})) + ")" : "";
|
2937
2967
|
return add_spaces([ "new", parenthesize(ctor, "seq", "binary", "conditional", "assign", function(expr){
|
2938
2968
|
var w = ast_walker(), has_call = {};
|
2939
2969
|
try {
|
@@ -2988,7 +3018,7 @@ function gen_code(ast, options) {
|
|
2988
3018
|
},
|
2989
3019
|
"call": function(func, args) {
|
2990
3020
|
var f = make(func);
|
2991
|
-
if (needs_parens(func))
|
3021
|
+
if (f.charAt(0) != "(" && needs_parens(func))
|
2992
3022
|
f = "(" + f + ")";
|
2993
3023
|
return f + "(" + add_commas(MAP(args, function(expr){
|
2994
3024
|
return parenthesize(expr, "seq");
|
@@ -3036,7 +3066,8 @@ function gen_code(ast, options) {
|
|
3036
3066
|
// we need to be smarter.
|
3037
3067
|
// adding parens all the time is the safest bet.
|
3038
3068
|
if (member(lvalue[0], [ "assign", "conditional", "seq" ]) ||
|
3039
|
-
lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]]
|
3069
|
+
lvalue[0] == "binary" && PRECEDENCE[operator] > PRECEDENCE[lvalue[1]] ||
|
3070
|
+
lvalue[0] == "function" && needs_parens(this)) {
|
3040
3071
|
left = "(" + left + ")";
|
3041
3072
|
}
|
3042
3073
|
if (member(rvalue[0], [ "assign", "conditional", "seq" ]) ||
|
@@ -3069,9 +3100,10 @@ function gen_code(ast, options) {
|
|
3069
3100
|
return hash + "[" + make(subscript) + "]";
|
3070
3101
|
},
|
3071
3102
|
"object": function(props) {
|
3103
|
+
var obj_needs_parens = needs_parens(this);
|
3072
3104
|
if (props.length == 0)
|
3073
|
-
return "{}";
|
3074
|
-
|
3105
|
+
return obj_needs_parens ? "({})" : "{}";
|
3106
|
+
var out = "{" + newline + with_indent(function(){
|
3075
3107
|
return MAP(props, function(p){
|
3076
3108
|
if (p.length == 3) {
|
3077
3109
|
// getter/setter. The name is in p[0], the arg.list in p[1][2], the
|
@@ -3092,14 +3124,15 @@ function gen_code(ast, options) {
|
|
3092
3124
|
: [ key + ":", val ]));
|
3093
3125
|
}).join("," + newline);
|
3094
3126
|
}) + newline + indent("}");
|
3127
|
+
return obj_needs_parens ? "(" + out + ")" : out;
|
3095
3128
|
},
|
3096
3129
|
"regexp": function(rx, mods) {
|
3097
3130
|
return "/" + rx + "/" + mods;
|
3098
3131
|
},
|
3099
3132
|
"array": function(elements) {
|
3100
3133
|
if (elements.length == 0) return "[]";
|
3101
|
-
return add_spaces([ "[", add_commas(MAP(elements, function(el){
|
3102
|
-
if (!beautify && el[0] == "atom" && el[1] == "undefined") return "";
|
3134
|
+
return add_spaces([ "[", add_commas(MAP(elements, function(el, i){
|
3135
|
+
if (!beautify && el[0] == "atom" && el[1] == "undefined") return i === elements.length - 1 ? "," : "";
|
3103
3136
|
return parenthesize(el, "seq");
|
3104
3137
|
})), "]" ]);
|
3105
3138
|
},
|
@@ -3128,6 +3161,7 @@ function gen_code(ast, options) {
|
|
3128
3161
|
// to the inner IF). This function checks for this case and
|
3129
3162
|
// adds the block brackets if needed.
|
3130
3163
|
function make_then(th) {
|
3164
|
+
if (th == null) return ";";
|
3131
3165
|
if (th[0] == "do") {
|
3132
3166
|
// https://github.com/mishoo/UglifyJS/issues/#issue/57
|
3133
3167
|
// IE croaks with "syntax error" on code like this:
|
@@ -3157,7 +3191,8 @@ function gen_code(ast, options) {
|
|
3157
3191
|
out += " " + make_name(name);
|
3158
3192
|
}
|
3159
3193
|
out += "(" + add_commas(MAP(args, make_name)) + ")";
|
3160
|
-
|
3194
|
+
out = add_spaces([ out, make_block(body) ]);
|
3195
|
+
return needs_parens(this) ? "(" + out + ")" : out;
|
3161
3196
|
};
|
3162
3197
|
|
3163
3198
|
function must_has_semicolon(node) {
|
@@ -3357,20 +3392,49 @@ exports.ast_squeeze_more = require("./squeeze-more").ast_squeeze_more;
|
|
3357
3392
|
pro = require("./process"),
|
3358
3393
|
slice = jsp.slice,
|
3359
3394
|
member = jsp.member,
|
3395
|
+
curry = jsp.curry,
|
3396
|
+
MAP = pro.MAP,
|
3360
3397
|
PRECEDENCE = jsp.PRECEDENCE,
|
3361
3398
|
OPERATORS = jsp.OPERATORS;
|
3362
3399
|
|
3363
3400
|
function ast_squeeze_more(ast) {
|
3364
|
-
var w = pro.ast_walker(), walk = w.walk;
|
3401
|
+
var w = pro.ast_walker(), walk = w.walk, scope;
|
3402
|
+
function with_scope(s, cont) {
|
3403
|
+
var save = scope, ret;
|
3404
|
+
scope = s;
|
3405
|
+
ret = cont();
|
3406
|
+
scope = save;
|
3407
|
+
return ret;
|
3408
|
+
};
|
3409
|
+
function _lambda(name, args, body) {
|
3410
|
+
return [ this[0], name, args, with_scope(body.scope, curry(MAP, body, walk)) ];
|
3411
|
+
};
|
3365
3412
|
return w.with_walkers({
|
3413
|
+
"toplevel": function(body) {
|
3414
|
+
return [ this[0], with_scope(this.scope, curry(MAP, body, walk)) ];
|
3415
|
+
},
|
3416
|
+
"function": _lambda,
|
3417
|
+
"defun": _lambda,
|
3418
|
+
"new": function(ctor, args) {
|
3419
|
+
if (ctor[0] == "name" && ctor[1] == "Array" && !scope.has("Array")) {
|
3420
|
+
if (args.length != 1) {
|
3421
|
+
return [ "array", args ];
|
3422
|
+
} else {
|
3423
|
+
return walk([ "call", [ "name", "Array" ], args ]);
|
3424
|
+
}
|
3425
|
+
}
|
3426
|
+
},
|
3366
3427
|
"call": function(expr, args) {
|
3367
3428
|
if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
|
3368
3429
|
// foo.toString() ==> foo+""
|
3369
3430
|
return [ "binary", "+", expr[1], [ "string", "" ]];
|
3370
3431
|
}
|
3432
|
+
if (expr[0] == "name" && expr[1] == "Array" && args.length != 1 && !scope.has("Array")) {
|
3433
|
+
return [ "array", args ];
|
3434
|
+
}
|
3371
3435
|
}
|
3372
3436
|
}, function() {
|
3373
|
-
return walk(ast);
|
3437
|
+
return walk(pro.ast_add_scope(ast));
|
3374
3438
|
});
|
3375
3439
|
};
|
3376
3440
|
|
data/uglifier.gemspec
CHANGED
@@ -4,13 +4,13 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.0.
|
7
|
+
s.name = "uglifier"
|
8
|
+
s.version = "1.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ville Lautanala"]
|
12
|
-
s.date =
|
13
|
-
s.email =
|
12
|
+
s.date = "2011-10-18"
|
13
|
+
s.email = "lautis@gmail.com"
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE.txt",
|
16
16
|
"README.rdoc"
|
@@ -33,16 +33,15 @@ Gem::Specification.new do |s|
|
|
33
33
|
"spec/uglifier_spec.rb",
|
34
34
|
"uglifier.gemspec"
|
35
35
|
]
|
36
|
-
s.homepage =
|
36
|
+
s.homepage = "http://github.com/lautis/uglifier"
|
37
37
|
s.require_paths = ["lib"]
|
38
|
-
s.rubygems_version =
|
39
|
-
s.summary =
|
38
|
+
s.rubygems_version = "1.8.10"
|
39
|
+
s.summary = "Ruby wrapper for UglifyJS JavaScript compressor"
|
40
40
|
|
41
41
|
if s.respond_to? :specification_version then
|
42
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
43
42
|
s.specification_version = 3
|
44
43
|
|
45
|
-
if Gem::Version.new(Gem::
|
44
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
46
45
|
s.add_runtime_dependency(%q<execjs>, [">= 0.3.0"])
|
47
46
|
s.add_runtime_dependency(%q<multi_json>, [">= 1.0.2"])
|
48
47
|
s.add_development_dependency(%q<rspec>, ["~> 2.6.0"])
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uglifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 31
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
9
|
+
- 4
|
10
|
+
version: 1.0.4
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Ville Lautanala
|
@@ -14,91 +15,102 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2011-
|
18
|
-
default_executable:
|
18
|
+
date: 2011-10-18 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|
22
|
+
none: false
|
22
23
|
requirements:
|
23
24
|
- - ">="
|
24
25
|
- !ruby/object:Gem::Version
|
26
|
+
hash: 19
|
25
27
|
segments:
|
26
28
|
- 0
|
27
29
|
- 3
|
28
30
|
- 0
|
29
31
|
version: 0.3.0
|
30
|
-
requirement: *id001
|
31
32
|
name: execjs
|
32
33
|
prerelease: false
|
33
34
|
type: :runtime
|
35
|
+
requirement: *id001
|
34
36
|
- !ruby/object:Gem::Dependency
|
35
37
|
version_requirements: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
36
39
|
requirements:
|
37
40
|
- - ">="
|
38
41
|
- !ruby/object:Gem::Version
|
42
|
+
hash: 19
|
39
43
|
segments:
|
40
44
|
- 1
|
41
45
|
- 0
|
42
46
|
- 2
|
43
47
|
version: 1.0.2
|
44
|
-
requirement: *id002
|
45
48
|
name: multi_json
|
46
49
|
prerelease: false
|
47
50
|
type: :runtime
|
51
|
+
requirement: *id002
|
48
52
|
- !ruby/object:Gem::Dependency
|
49
53
|
version_requirements: &id003 !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
50
55
|
requirements:
|
51
56
|
- - ~>
|
52
57
|
- !ruby/object:Gem::Version
|
58
|
+
hash: 23
|
53
59
|
segments:
|
54
60
|
- 2
|
55
61
|
- 6
|
56
62
|
- 0
|
57
63
|
version: 2.6.0
|
58
|
-
requirement: *id003
|
59
64
|
name: rspec
|
60
65
|
prerelease: false
|
61
66
|
type: :development
|
67
|
+
requirement: *id003
|
62
68
|
- !ruby/object:Gem::Dependency
|
63
69
|
version_requirements: &id004 !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
64
71
|
requirements:
|
65
72
|
- - ~>
|
66
73
|
- !ruby/object:Gem::Version
|
74
|
+
hash: 23
|
67
75
|
segments:
|
68
76
|
- 1
|
69
77
|
- 0
|
70
78
|
- 0
|
71
79
|
version: 1.0.0
|
72
|
-
requirement: *id004
|
73
80
|
name: bundler
|
74
81
|
prerelease: false
|
75
82
|
type: :development
|
83
|
+
requirement: *id004
|
76
84
|
- !ruby/object:Gem::Dependency
|
77
85
|
version_requirements: &id005 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
78
87
|
requirements:
|
79
88
|
- - ~>
|
80
89
|
- !ruby/object:Gem::Version
|
90
|
+
hash: 15
|
81
91
|
segments:
|
82
92
|
- 1
|
83
93
|
- 6
|
84
94
|
- 0
|
85
95
|
version: 1.6.0
|
86
|
-
requirement: *id005
|
87
96
|
name: jeweler
|
88
97
|
prerelease: false
|
89
98
|
type: :development
|
99
|
+
requirement: *id005
|
90
100
|
- !ruby/object:Gem::Dependency
|
91
101
|
version_requirements: &id006 !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
92
103
|
requirements:
|
93
104
|
- - ">="
|
94
105
|
- !ruby/object:Gem::Version
|
106
|
+
hash: 3
|
95
107
|
segments:
|
96
108
|
- 0
|
97
109
|
version: "0"
|
98
|
-
requirement: *id006
|
99
110
|
name: rcov
|
100
111
|
prerelease: false
|
101
112
|
type: :development
|
113
|
+
requirement: *id006
|
102
114
|
description:
|
103
115
|
email: lautis@gmail.com
|
104
116
|
executables: []
|
@@ -125,7 +137,6 @@ files:
|
|
125
137
|
- spec/spec_helper.rb
|
126
138
|
- spec/uglifier_spec.rb
|
127
139
|
- uglifier.gemspec
|
128
|
-
has_rdoc: true
|
129
140
|
homepage: http://github.com/lautis/uglifier
|
130
141
|
licenses: []
|
131
142
|
|
@@ -135,23 +146,27 @@ rdoc_options: []
|
|
135
146
|
require_paths:
|
136
147
|
- lib
|
137
148
|
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
138
150
|
requirements:
|
139
151
|
- - ">="
|
140
152
|
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
141
154
|
segments:
|
142
155
|
- 0
|
143
156
|
version: "0"
|
144
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
none: false
|
145
159
|
requirements:
|
146
160
|
- - ">="
|
147
161
|
- !ruby/object:Gem::Version
|
162
|
+
hash: 3
|
148
163
|
segments:
|
149
164
|
- 0
|
150
165
|
version: "0"
|
151
166
|
requirements: []
|
152
167
|
|
153
168
|
rubyforge_project:
|
154
|
-
rubygems_version: 1.
|
169
|
+
rubygems_version: 1.8.10
|
155
170
|
signing_key:
|
156
171
|
specification_version: 3
|
157
172
|
summary: Ruby wrapper for UglifyJS JavaScript compressor
|