diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2018-03-23 03:43:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-23 03:43:52 +0800 |
commit | 49bfc6b555ca3be3084c0819391eabf2839e6f1b (patch) | |
tree | 12dda86d5f4feeb1a643e169e5daccdabc35112d /lib/scope.js | |
parent | d1c6bb8c7c4cc491c4bb52e14ac2127a2496fbb8 (diff) | |
download | tracifyjs-49bfc6b555ca3be3084c0819391eabf2839e6f1b.tar.gz tracifyjs-49bfc6b555ca3be3084c0819391eabf2839e6f1b.zip |
improve performance (#3020)
- replace `find_if()` with `all()` wherever possible
- move ESTree-specific logic out of `figure_out_scope()`
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 23 |
1 files changed, 0 insertions, 23 deletions
diff --git a/lib/scope.js b/lib/scope.js index baa3e8bd..7cbd82c1 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -100,7 +100,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ // pass 1: setup scope chaining and handle definitions var self = this; var scope = self.parent_scope = null; - var labels = new Dictionary(); var defun = null; var tw = new TreeWalker(function(node, descend){ if (node instanceof AST_Catch) { @@ -115,25 +114,12 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ node.init_scope_vars(scope); var save_scope = scope; var save_defun = defun; - var save_labels = labels; defun = scope = node; - labels = new Dictionary(); descend(); scope = save_scope; defun = save_defun; - labels = save_labels; return true; // don't descend again in TreeWalker } - if (node instanceof AST_LabeledStatement) { - var l = node.label; - if (labels.has(l.name)) { - throw new Error(string_template("Label {name} defined twice", l)); - } - labels.set(l.name, l); - descend(); - labels.del(l.name); - return true; // no descend again - } if (node instanceof AST_With) { for (var s = scope; s; s = s.parent_scope) s.uses_with = true; @@ -171,15 +157,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){ else if (node instanceof AST_SymbolCatch) { scope.def_variable(node).defun = defun; } - else if (node instanceof AST_LabelRef) { - var sym = labels.get(node.name); - if (!sym) throw new Error(string_template("Undefined label {name} [{line},{col}]", { - name: node.name, - line: node.start.line, - col: node.start.col - })); - node.thedef = sym; - } }); self.walk(tw); |