class VariableVisibilityAnalysis extends java.lang.Object implements CompilerPass
Modifier and Type | Class and Description |
---|---|
(package private) static class |
VariableVisibilityAnalysis.VariableVisibility |
Modifier and Type | Field and Description |
---|---|
private AbstractCompiler |
compiler |
private java.util.Map<Node,VariableVisibilityAnalysis.VariableVisibility> |
visibilityByDeclaringNameNode
Maps the declaring name node for a variable to that variable's
visibility.
|
Constructor and Description |
---|
VariableVisibilityAnalysis(AbstractCompiler compiler) |
Modifier and Type | Method and Description |
---|---|
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.
|
private static boolean |
variableIsParameter(Var variable)
Returns true if the variable is a formal parameter.
|
private AbstractCompiler compiler
private java.util.Map<Node,VariableVisibilityAnalysis.VariableVisibility> visibilityByDeclaringNameNode
public VariableVisibilityAnalysis(AbstractCompiler compiler)
public VariableVisibilityAnalysis.VariableVisibility getVariableVisibility(Node declaringNameNode)
Token.VAR (for a variable declaration) Token.FUNCTION (for a function declaration) Token.PARAM_LIST (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
declaringNameNode
- The name node for a declaration.public void process(Node externs, Node root)
process
in interface CompilerPass
externs
- Top of external JS treeroot
- Top of JS treeprivate static boolean variableIsParameter(Var variable)