com.google.javascript.jscomp
Class VariableVisibilityAnalysis

java.lang.Object
  extended by com.google.javascript.jscomp.VariableVisibilityAnalysis
All Implemented Interfaces:
CompilerPass

public class VariableVisibilityAnalysis
extends Object
implements CompilerPass

An analysis pass that determines the visibility of variables -- that is, whether a variable is truly local, a local captured by an inner scope, a parameter, or a global variable. SideEffectsAnalysis uses this class to partition a potentially infinite number of concrete storage locations into a (small) finite number of abstract storage locations based on a variable's storage visibility.


Constructor Summary
VariableVisibilityAnalysis(AbstractCompiler compiler)
           
 
Method Summary
 com.google.javascript.jscomp.VariableVisibilityAnalysis.VariableVisibility getVariableVisibility(Node declaringNameNode)
          Returns the visibility of of a variable, given that variable's declaring name node.
 void process(Node externs, Node root)
          Determines the visibility class for each variable in root.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableVisibilityAnalysis

public VariableVisibilityAnalysis(AbstractCompiler compiler)
Method Detail

getVariableVisibility

public com.google.javascript.jscomp.VariableVisibilityAnalysis.VariableVisibility getVariableVisibility(Node declaringNameNode)
Returns the visibility of of a variable, given that variable's declaring name node. The name node's parent must be one of:
    Token.VAR (for a variable declaration)
    Token.FUNCTION (for a function declaration)
    Token.LP (for a function formal parameter)
 
The returned visibility will be one of:
    LOCAL_VARIABLE : the variable is a local variable used only in its
        declared scope
    CAPTURED_LOCAL_VARIABLE : A local variable that is used in a capturing
        closure
     PARAMETER_VARIABLE : the variable is a formal parameter
     GLOBAL_VARIABLE : the variable is declared in the global scope
  

Parameters:
declaringNameNode - The name node for a declaration.

process

public void process(Node externs,
                    Node root)
Determines the visibility class for each variable in root.

Specified by:
process in interface CompilerPass
Parameters:
externs - Top of external JS tree
root - Top of JS tree