aboutsummaryrefslogtreecommitdiff
path: root/lib/scope.js
diff options
context:
space:
mode:
authoralexlamsl <alexlamsl@gmail.com>2017-02-18 19:19:55 +0800
committeralexlamsl <alexlamsl@gmail.com>2017-02-21 13:29:58 +0800
commita0f4fd390a0a1af80964aab9754bf5358db575e2 (patch)
treeb07e7f034909cb2b234fb8963575b6e0f8ff2ef5 /lib/scope.js
parentb8b133d91a7a65f3375d391a036623901d1e357f (diff)
downloadtracifyjs-a0f4fd390a0a1af80964aab9754bf5358db575e2.tar.gz
tracifyjs-a0f4fd390a0a1af80964aab9754bf5358db575e2.zip
improve reduce_vars and fix a bug
- update modified flag between compress() passes - support IIFE arguments - fix corner case with multiple definitions closes #1473
Diffstat (limited to 'lib/scope.js')
-rw-r--r--lib/scope.js26
1 files changed, 5 insertions, 21 deletions
diff --git a/lib/scope.js b/lib/scope.js
index d5cadd34..6ad12616 100644
--- a/lib/scope.js
+++ b/lib/scope.js
@@ -183,17 +183,6 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
var func = null;
var globals = self.globals = new Dictionary();
var tw = new TreeWalker(function(node, descend){
- function isModified(node, level) {
- var parent = tw.parent(level);
- if (parent instanceof AST_Unary && (parent.operator === "++" || parent.operator === "--")
- || parent instanceof AST_Assign && parent.left === node
- || parent instanceof AST_Call && parent.expression === node) {
- return true;
- } else if (parent instanceof AST_PropAccess && parent.expression === node) {
- return isModified(parent, level + 1);
- }
- }
-
if (node instanceof AST_Lambda) {
var prev_func = func;
func = node;
@@ -217,21 +206,16 @@ AST_Toplevel.DEFMETHOD("figure_out_scope", function(options){
node.scope.uses_arguments = true;
}
if (!sym) {
- var g;
if (globals.has(name)) {
- g = globals.get(name);
+ sym = globals.get(name);
} else {
- g = new SymbolDef(self, globals.size(), node);
- g.undeclared = true;
- g.global = true;
- globals.set(name, g);
+ sym = new SymbolDef(self, globals.size(), node);
+ sym.undeclared = true;
+ sym.global = true;
+ globals.set(name, sym);
}
- sym = g;
}
node.thedef = sym;
- if (isModified(node, 0)) {
- sym.modified = true;
- }
node.reference(options);
return true;
}