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];
|
||||
if (dir) return dir;
|
||||
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) {
|
||||
var st = node.body[i];
|
||||
if (!(st instanceof AST_Directive)) break;
|
||||
|
|
|
|||
|
|
@ -1449,6 +1449,9 @@ merge(Compressor.prototype, {
|
|||
AST_Scope.DEFMETHOD("hoist_declarations", function(compressor){
|
||||
var self = this;
|
||||
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_vars = compressor.option("hoist_vars");
|
||||
var self = this;
|
||||
|
|
|
|||
|
|
@ -190,6 +190,9 @@ function parse_js_number(num) {
|
|||
return parseInt(num.substr(2), 2);
|
||||
} else if (RE_DEC_NUMBER.test(num)) {
|
||||
return parseFloat(num);
|
||||
} else {
|
||||
var val = parseFloat(num);
|
||||
if (val == num) return val;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
22
lib/scope.js
22
lib/scope.js
|
|
@ -158,7 +158,11 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|||
if (node instanceof AST_Symbol) {
|
||||
node.scope = scope;
|
||||
}
|
||||
if (node instanceof AST_Label) {
|
||||
if (node instanceof AST_SymbolFunarg) {
|
||||
node.object_destructuring_arg = !!in_destructuring;
|
||||
defun.def_variable(node, in_export);
|
||||
}
|
||||
if (node instanceof AST_Label) {
|
||||
node.thedef = node;
|
||||
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
|
||||
// later.
|
||||
(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) {
|
||||
defun.def_variable(node, in_export);
|
||||
|
|
@ -233,6 +234,10 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
|
|||
cls = prev_cls;
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_LoopControl && node.label) {
|
||||
node.label.thedef.references.push(node);
|
||||
return true;
|
||||
}
|
||||
if (node instanceof AST_SymbolRef) {
|
||||
var name = node.name;
|
||||
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));
|
||||
});
|
||||
|
||||
AST_Scope.DEFMETHOD("has_directive", function(value){
|
||||
return this.parent_scope && this.parent_scope.has_directive(value)
|
||||
|| (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_function", function(symbol, in_export){
|
||||
this.functions.set(symbol.name, this.def_variable(symbol, in_export));
|
||||
});
|
||||
|
||||
AST_Scope.DEFMETHOD("def_variable", function(symbol, in_export){
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user