diff options
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/scope.js b/lib/scope.js index e3433340..1224e604 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -50,7 +50,8 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(){ // times on the same tree. // pass 1: setup scope chaining and handle definitions - var scope = this.parent_scope; + var self = this; + var scope = self.parent_scope = null; var labels = {}; var tw = new TreeWalker(function(node, descend){ if (node instanceof AST_Scope) { @@ -110,7 +111,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(){ node.reference(sym); } }); - this.walk(tw); + self.walk(tw); // pass 2: find back references and eval var func = null; @@ -137,7 +138,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(){ } } }); - this.walk(tw); + self.walk(tw); }); AST_Scope.DEFMETHOD("init_scope_vars", function(){ @@ -364,6 +365,14 @@ AST_Toplevel.DEFMETHOD("compute_char_frequency", function(){ var tw = new TreeWalker(function(node){ if (node instanceof AST_Constant) base54.consider(node.print_to_string()); + else if (node instanceof AST_Return) + base54.consider("return"); + else if (node instanceof AST_Throw) + base54.consider("throw"); + else if (node instanceof AST_Continue) + base54.consider("continue"); + else if (node instanceof AST_Break) + base54.consider("break"); else if (node instanceof AST_Debugger) base54.consider("debugger"); else if (node instanceof AST_Directive) @@ -420,7 +429,6 @@ AST_Toplevel.DEFMETHOD("compute_char_frequency", function(){ base54.consider(node.property); }); this.walk(tw); - base54.sort(); }); var base54 = (function() { |