Merge branch 'master' into harmony-v2.8.6

This commit is contained in:
alexlamsl
2017-03-05 16:03:56 +08:00
20 changed files with 1089 additions and 142 deletions

View File

@@ -209,14 +209,13 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
(node.scope = defun.parent_scope).def_function(node, in_export, in_block);
}
else if (node instanceof AST_SymbolVar
|| node instanceof AST_SymbolConst
|| node instanceof AST_SymbolLet) {
|| node instanceof AST_SymbolLet
|| node instanceof AST_SymbolConst) {
var def = ((node instanceof AST_SymbolBlockDeclaration) ? scope : defun).def_variable(node, in_export, in_block);
def.destructuring = in_destructuring;
def.init = tw.parent().value;
}
else if (node instanceof AST_SymbolCatch) {
(options.screw_ie8 ? scope : defun).def_variable(node, in_export, in_block);
scope.def_variable(node, in_export, in_block);
}
else if (node instanceof AST_LabelRef) {
var sym = labels.get(node.name);
@@ -274,6 +273,23 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
});
self.walk(tw);
// pass 3: fix up any scoping issue with IE8
if (!options.screw_ie8) {
self.walk(new TreeWalker(function(node, descend) {
if (node instanceof AST_SymbolCatch) {
var name = node.name;
var scope = node.thedef.scope.parent_scope;
var def = scope.find_variable(name) || self.globals.get(name) || scope.def_variable(node);
node.thedef.references.forEach(function(ref) {
ref.thedef = def;
ref.reference(options);
});
node.thedef = def;
return true;
}
}));
}
if (options.cache) {
this.cname = options.cache.cname;
}