From 686a496b1c8c3762768c0da6ef98b37167d4d4ba Mon Sep 17 00:00:00 2001 From: alexlamsl Date: Sat, 18 Feb 2017 18:59:40 +0800 Subject: [PATCH] remove unused AST_Scope.nesting & AST_SymbolRef.frame they are computed but never used closes #1444 --- lib/scope.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/scope.js b/lib/scope.js index 55d1eff1..0fe8d83a 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -98,25 +98,24 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ var labels = new Dictionary(); var defun = null; var last_var_had_const_pragma = false; - var nesting = 0; var tw = new TreeWalker(function(node, descend){ if (options.screw_ie8 && node instanceof AST_Catch) { var save_scope = scope; scope = new AST_Scope(node); - scope.init_scope_vars(nesting); + scope.init_scope_vars(); scope.parent_scope = save_scope; descend(); scope = save_scope; return true; } if (node instanceof AST_Scope) { - node.init_scope_vars(nesting); + node.init_scope_vars(); var save_scope = node.parent_scope = scope; var save_defun = defun; var save_labels = labels; defun = scope = node; labels = new Dictionary(); - ++nesting; descend(); --nesting; + descend(); scope = save_scope; defun = save_defun; labels = save_labels; @@ -244,7 +243,7 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ } }); -AST_Scope.DEFMETHOD("init_scope_vars", function(nesting){ +AST_Scope.DEFMETHOD("init_scope_vars", function(){ this.variables = new Dictionary(); // map name to AST_SymbolVar (variables defined in this scope; includes functions) this.functions = new Dictionary(); // map name to AST_SymbolDefun (functions defined in this scope) this.uses_with = false; // will be set to true if this or some nested scope uses the `with` statement @@ -252,7 +251,6 @@ AST_Scope.DEFMETHOD("init_scope_vars", function(nesting){ this.parent_scope = null; // the parent scope this.enclosed = []; // a list of variables from this or outer scope(s) that are referenced from this or inner scopes this.cname = -1; // the current index for mangling functions/variables - this.nesting = nesting; // the nesting level of this scope (0 means toplevel) }); AST_Lambda.DEFMETHOD("init_scope_vars", function(){ @@ -278,7 +276,6 @@ AST_SymbolRef.DEFMETHOD("reference", function(options) { } s = s.parent_scope; } - this.frame = this.scope.nesting - def.scope.nesting; }); AST_Scope.DEFMETHOD("find_variable", function(name){ -- 2.34.1