diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2020-08-23 05:45:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-23 05:45:35 +0800 |
commit | 35fe1092d368f3a79df54120d5e1c1dcb268af1a (patch) | |
tree | 2a7a569f3934acbeb520f32611fa1a1308064433 /lib/scope.js | |
parent | f2d486e771271ce03f25a50a6107cb87735a681d (diff) | |
download | tracifyjs-35fe1092d368f3a79df54120d5e1c1dcb268af1a.tar.gz tracifyjs-35fe1092d368f3a79df54120d5e1c1dcb268af1a.zip |
simplify traversal logic (#4063)
Diffstat (limited to 'lib/scope.js')
-rw-r--r-- | lib/scope.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/lib/scope.js b/lib/scope.js index 3297b8e6..450c1062 100644 --- a/lib/scope.js +++ b/lib/scope.js @@ -559,21 +559,23 @@ AST_Toplevel.DEFMETHOD("compute_char_frequency", function(options) { options = _default_mangler_options(options); base54.reset(); try { - AST_Node.prototype.print = function(stream, force_parens) { - this._print(stream, force_parens); - if (this instanceof AST_Symbol && !this.unmangleable(options)) { - base54.consider(this.name, -1); - } else if (options.properties) { - if (this instanceof AST_Dot) { - base54.consider(this.property, -1); - } else if (this instanceof AST_Sub) { - skip_string(this.property); - } - } + var fn = AST_Symbol.prototype.add_source_map; + AST_Symbol.prototype.add_source_map = function() { + if (!this.unmangleable(options)) base54.consider(this.name, -1); }; + if (options.properties) { + AST_Dot.prototype.add_source_map = function() { + base54.consider(this.property, -1); + }; + AST_Sub.prototype.add_source_map = function() { + skip_string(this.property); + }; + } base54.consider(this.print_to_string(), 1); } finally { - AST_Node.prototype.print = AST_Node.prototype._print; + AST_Symbol.prototype.add_source_map = fn; + delete AST_Dot.prototype.add_source_map; + delete AST_Sub.prototype.add_source_map; } base54.sort(); |