Merge branch 'harmony' of github.com:mishoo/UglifyJS2 into harmony
This commit is contained in:
commit
021325f77f
|
|
@ -1267,7 +1267,7 @@ TreeWalker.prototype = {
|
||||||
var dir = this.directives[type];
|
var dir = this.directives[type];
|
||||||
if (dir) return dir;
|
if (dir) return dir;
|
||||||
var node = this.stack[this.stack.length - 1];
|
var node = this.stack[this.stack.length - 1];
|
||||||
if (node instanceof AST_Scope) {
|
if (node instanceof AST_Scope && node.body) {
|
||||||
for (var i = 0; i < node.body.length; ++i) {
|
for (var i = 0; i < node.body.length; ++i) {
|
||||||
var st = node.body[i];
|
var st = node.body[i];
|
||||||
if (!(st instanceof AST_Directive)) break;
|
if (!(st instanceof AST_Directive)) break;
|
||||||
|
|
|
||||||
|
|
@ -1449,6 +1449,9 @@ merge(Compressor.prototype, {
|
||||||
AST_Scope.DEFMETHOD("hoist_declarations", function(compressor){
|
AST_Scope.DEFMETHOD("hoist_declarations", function(compressor){
|
||||||
var self = this;
|
var self = this;
|
||||||
if (compressor.has_directive("use asm")) return self;
|
if (compressor.has_directive("use asm")) return self;
|
||||||
|
// Hoisting makes no sense in an arrow func
|
||||||
|
if (!Array.isArray(self.body)) return self;
|
||||||
|
|
||||||
var hoist_funs = compressor.option("hoist_funs");
|
var hoist_funs = compressor.option("hoist_funs");
|
||||||
var hoist_vars = compressor.option("hoist_vars");
|
var hoist_vars = compressor.option("hoist_vars");
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
|
||||||
|
|
@ -190,6 +190,9 @@ function parse_js_number(num) {
|
||||||
return parseInt(num.substr(2), 2);
|
return parseInt(num.substr(2), 2);
|
||||||
} else if (RE_DEC_NUMBER.test(num)) {
|
} else if (RE_DEC_NUMBER.test(num)) {
|
||||||
return parseFloat(num);
|
return parseFloat(num);
|
||||||
|
} else {
|
||||||
|
var val = parseFloat(num);
|
||||||
|
if (val == num) return val;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
20
lib/scope.js
20
lib/scope.js
|
|
@ -158,6 +158,10 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
||||||
if (node instanceof AST_Symbol) {
|
if (node instanceof AST_Symbol) {
|
||||||
node.scope = scope;
|
node.scope = scope;
|
||||||
}
|
}
|
||||||
|
if (node instanceof AST_SymbolFunarg) {
|
||||||
|
node.object_destructuring_arg = !!in_destructuring;
|
||||||
|
defun.def_variable(node, in_export);
|
||||||
|
}
|
||||||
if (node instanceof AST_Label) {
|
if (node instanceof AST_Label) {
|
||||||
node.thedef = node;
|
node.thedef = node;
|
||||||
node.references = [];
|
node.references = [];
|
||||||
|
|
@ -176,9 +180,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
||||||
// instanceof AST_Scope) but we get to the symbol a bit
|
// instanceof AST_Scope) but we get to the symbol a bit
|
||||||
// later.
|
// later.
|
||||||
(node.scope = defun.parent_scope).def_function(node, in_export);
|
(node.scope = defun.parent_scope).def_function(node, in_export);
|
||||||
}
|
|
||||||
else if (node instanceof AST_Var) {
|
|
||||||
last_var_had_const_pragma = node.has_const_pragma();
|
|
||||||
}
|
}
|
||||||
else if (node instanceof AST_SymbolClass) {
|
else if (node instanceof AST_SymbolClass) {
|
||||||
defun.def_variable(node, in_export);
|
defun.def_variable(node, in_export);
|
||||||
|
|
@ -233,6 +234,10 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
||||||
cls = prev_cls;
|
cls = prev_cls;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (node instanceof AST_LoopControl && node.label) {
|
||||||
|
node.label.thedef.references.push(node);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (node instanceof AST_SymbolRef) {
|
if (node instanceof AST_SymbolRef) {
|
||||||
var name = node.name;
|
var name = node.name;
|
||||||
if (name == "eval" && tw.parent() instanceof AST_Call) {
|
if (name == "eval" && tw.parent() instanceof AST_Call) {
|
||||||
|
|
@ -316,13 +321,8 @@ AST_Scope.DEFMETHOD("find_variable", function(name){
|
||||||
|| (this.parent_scope && this.parent_scope.find_variable(name));
|
|| (this.parent_scope && this.parent_scope.find_variable(name));
|
||||||
});
|
});
|
||||||
|
|
||||||
AST_Scope.DEFMETHOD("has_directive", function(value){
|
AST_Scope.DEFMETHOD("def_function", function(symbol, in_export){
|
||||||
return this.parent_scope && this.parent_scope.has_directive(value)
|
this.functions.set(symbol.name, this.def_variable(symbol, in_export));
|
||||||
|| (this.directives.indexOf(value) >= 0 ? this : null);
|
|
||||||
});
|
|
||||||
|
|
||||||
AST_Scope.DEFMETHOD("def_function", function(symbol){
|
|
||||||
this.functions.set(symbol.name, this.def_variable(symbol));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
AST_Scope.DEFMETHOD("def_variable", function(symbol, in_export){
|
AST_Scope.DEFMETHOD("def_variable", function(symbol, in_export){
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user