harmony-v3.3.7
This commit is contained in:
27
bin/uglifyjs
27
bin/uglifyjs
@@ -238,28 +238,15 @@ function run() {
|
|||||||
result.ast.figure_out_scope({});
|
result.ast.figure_out_scope({});
|
||||||
}
|
}
|
||||||
print(JSON.stringify(result.ast, function(key, value) {
|
print(JSON.stringify(result.ast, function(key, value) {
|
||||||
switch (key) {
|
if (value) switch (key) {
|
||||||
case "thedef":
|
case "thedef":
|
||||||
if (typeof value == "object" && typeof value.id == "number") {
|
return symdef(value);
|
||||||
return value.id;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
case "enclosed":
|
case "enclosed":
|
||||||
return value.map(function(sym){
|
return value.length ? value.map(symdef) : undefined;
|
||||||
return sym.id;
|
|
||||||
});
|
|
||||||
case "variables":
|
case "variables":
|
||||||
case "functions":
|
case "functions":
|
||||||
case "globals":
|
case "globals":
|
||||||
if (value && value.size()) {
|
return value.size() ? value.map(symdef) : undefined;
|
||||||
var ret = {};
|
|
||||||
value.each(function(val, key) {
|
|
||||||
// key/val inverted for readability.
|
|
||||||
ret[val.id] = key;
|
|
||||||
});
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (skip_key(key)) return;
|
if (skip_key(key)) return;
|
||||||
if (value instanceof UglifyJS.AST_Token) return;
|
if (value instanceof UglifyJS.AST_Token) return;
|
||||||
@@ -419,6 +406,12 @@ function skip_key(key) {
|
|||||||
return skip_keys.indexOf(key) >= 0;
|
return skip_keys.indexOf(key) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function symdef(def) {
|
||||||
|
var ret = (1e6 + def.id) + " " + def.name;
|
||||||
|
if (def.mangled_name) ret += " " + def.mangled_name;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
function format_object(obj) {
|
function format_object(obj) {
|
||||||
var lines = [];
|
var lines = [];
|
||||||
var padding = "";
|
var padding = "";
|
||||||
|
|||||||
@@ -1829,6 +1829,7 @@ merge(Compressor.prototype, {
|
|||||||
do {
|
do {
|
||||||
var node = exprs[0];
|
var node = exprs[0];
|
||||||
if (!(node instanceof AST_Assign)) break;
|
if (!(node instanceof AST_Assign)) break;
|
||||||
|
if (node.operator != "=") break;
|
||||||
if (!(node.left instanceof AST_PropAccess)) break;
|
if (!(node.left instanceof AST_PropAccess)) break;
|
||||||
var sym = node.left.expression;
|
var sym = node.left.expression;
|
||||||
if (!(sym instanceof AST_SymbolRef)) break;
|
if (!(sym instanceof AST_SymbolRef)) break;
|
||||||
@@ -1865,8 +1866,26 @@ merge(Compressor.prototype, {
|
|||||||
statements[++j] = stat;
|
statements[++j] = stat;
|
||||||
defs = stat;
|
defs = stat;
|
||||||
}
|
}
|
||||||
|
} else if (stat instanceof AST_Exit) {
|
||||||
|
var exprs = join_object_assignments(prev, stat.value);
|
||||||
|
if (exprs) {
|
||||||
|
CHANGED = true;
|
||||||
|
if (exprs.length) {
|
||||||
|
stat.value = make_sequence(stat.value, exprs);
|
||||||
|
} else if (stat.value instanceof AST_Sequence) {
|
||||||
|
stat.value = stat.value.tail_node().left;
|
||||||
|
} else {
|
||||||
|
stat.value = stat.value.left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
statements[++j] = stat;
|
||||||
} else if (stat instanceof AST_For) {
|
} else if (stat instanceof AST_For) {
|
||||||
if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
|
var exprs = join_object_assignments(prev, stat.init);
|
||||||
|
if (exprs) {
|
||||||
|
CHANGED = true;
|
||||||
|
stat.init = exprs.length ? make_sequence(stat.init, exprs) : null;
|
||||||
|
statements[++j] = stat;
|
||||||
|
} else if (prev instanceof AST_Var && (!stat.init || stat.init.TYPE == prev.TYPE)) {
|
||||||
if (stat.init) {
|
if (stat.init) {
|
||||||
prev.definitions = prev.definitions.concat(stat.init.definitions);
|
prev.definitions = prev.definitions.concat(stat.init.definitions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ function SymbolDef(scope, orig, init) {
|
|||||||
this.id = SymbolDef.next_id++;
|
this.id = SymbolDef.next_id++;
|
||||||
};
|
};
|
||||||
|
|
||||||
SymbolDef.next_id = 1e6;
|
SymbolDef.next_id = 1;
|
||||||
|
|
||||||
SymbolDef.prototype = {
|
SymbolDef.prototype = {
|
||||||
unmangleable: function(options) {
|
unmangleable: function(options) {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
"homepage": "https://github.com/mishoo/UglifyJS2/tree/harmony",
|
"homepage": "https://github.com/mishoo/UglifyJS2/tree/harmony",
|
||||||
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
"author": "Mihai Bazon <mihai.bazon@gmail.com> (http://lisperator.net/)",
|
||||||
"license": "BSD-2-Clause",
|
"license": "BSD-2-Clause",
|
||||||
"version": "3.3.6",
|
"version": "3.3.7",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.0"
|
"node": ">=0.8.0"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1465,3 +1465,113 @@ join_object_assignments_3: {
|
|||||||
}
|
}
|
||||||
expect_stdout: "PASS"
|
expect_stdout: "PASS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
join_object_assignments_4: {
|
||||||
|
options = {
|
||||||
|
join_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
var o = {
|
||||||
|
p: 3
|
||||||
|
};
|
||||||
|
return o.q = "foo";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
var o = {
|
||||||
|
p: 3,
|
||||||
|
q: "foo"
|
||||||
|
};
|
||||||
|
return o.q;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "foo"
|
||||||
|
}
|
||||||
|
|
||||||
|
join_object_assignments_5: {
|
||||||
|
options = {
|
||||||
|
join_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
var o = {
|
||||||
|
p: 3
|
||||||
|
};
|
||||||
|
return o.q = /foo/,
|
||||||
|
o.r = "bar";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
var o = {
|
||||||
|
p: 3,
|
||||||
|
q: /foo/,
|
||||||
|
r: "bar"
|
||||||
|
};
|
||||||
|
return o.r;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: "bar"
|
||||||
|
}
|
||||||
|
|
||||||
|
join_object_assignments_6: {
|
||||||
|
options = {
|
||||||
|
join_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
var o = {
|
||||||
|
p: 3
|
||||||
|
};
|
||||||
|
return o.q = "foo",
|
||||||
|
o.p += "",
|
||||||
|
console.log(o.q),
|
||||||
|
o.p;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
var o = {
|
||||||
|
p: 3,
|
||||||
|
q: "foo"
|
||||||
|
};
|
||||||
|
return o.p += "",
|
||||||
|
console.log(o.q),
|
||||||
|
o.p;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"3",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
join_object_assignments_7: {
|
||||||
|
options = {
|
||||||
|
join_vars: true,
|
||||||
|
}
|
||||||
|
input: {
|
||||||
|
console.log(function() {
|
||||||
|
var o = {
|
||||||
|
p: 3
|
||||||
|
};
|
||||||
|
for (o.q = "foo"; console.log(o.q););
|
||||||
|
return o.p;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect: {
|
||||||
|
console.log(function() {
|
||||||
|
for (var o = {
|
||||||
|
p: 3,
|
||||||
|
q: "foo"
|
||||||
|
}; console.log(o.q););
|
||||||
|
return o.p;
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
expect_stdout: [
|
||||||
|
"foo",
|
||||||
|
"3",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user