public class TypeAnalyzerState
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
TypeAnalyzerState.CurrentClassElement
A table to hold the current class, which is the only object in the
table.
|
Constructor and Description |
---|
TypeAnalyzerState(TypeAnalyzer analyzer)
Construct a state object for a type analyzer.
|
Modifier and Type | Method and Description |
---|---|
void |
addVariable(java.lang.String name,
Type type)
Add a variable to the current scope.
|
void |
enterBlock()
Enter the scope of a block.
|
void |
enterClass(java.lang.Class c)
Enter the scope of a class.
|
TypeAnalyzer |
getAnalyzer()
Get the type analyzer that owns this state.
|
LocalClassLoader |
getClassLoader()
Get the class loader.
|
java.util.Set<java.lang.String> |
getCrossAnalyzedTypes()
Get the set of cross-analyzed types.
|
java.lang.Class |
getCurrentClass()
Get the current class (the class currently being inspected).
|
java.util.Stack<java.util.Hashtable<java.lang.String,java.lang.Class>> |
getPreviousClasses()
Get the previous class stack.
|
Type |
getVariable(java.lang.String name)
Get the type of a variable with its name in the current scope
and all the scopes enclosing the current scope.
|
Type |
getVariable(java.lang.String name,
boolean variablesOnly)
Get the type of a variable with its name in the current scope
and all the scopes enclosing the current scope.
|
java.util.Stack<java.util.Hashtable<java.lang.String,Type>> |
getVariableStack()
Get the variable stack.
|
boolean |
isVariable(java.lang.String name)
Return whether a name refers to a variable in the variable stack.
|
void |
leaveBlock()
Leave a block declaration.
|
void |
leaveClass()
Leave a class declaration.
|
int |
nextAnonymousCount()
Get the next count of anonymous classes in the current class.
|
int |
nextTotalAnonymousCount()
Get the next count of total anonymous classes.
|
void |
setClassLoader(LocalClassLoader loader)
Set the class loader.
|
void |
setClassScope()
Set the current scope to be a class scope (a scope opened by
a class declaration).
|
void |
setCurrentClass(java.lang.Class currentClass)
Get the current class (the class currently being inspected).
|
void |
setPreviousClasses(java.util.Stack<java.util.Hashtable<java.lang.String,java.lang.Class>> previousClasses)
Set the previous class stack.
|
void |
setVariableStack(java.util.Stack<java.util.Hashtable<java.lang.String,Type>> variableStack)
Set the variable stack.
|
void |
unsetClassScope()
Unset the current scope as a class scope (a scope opened by a
class declaration).
|
public TypeAnalyzerState(TypeAnalyzer analyzer)
analyzer
- The type analyzer.public void addVariable(java.lang.String name, Type type)
name
- The name of the variable.type
- The type of the variable.public void enterBlock()
leaveBlock()
public void enterClass(java.lang.Class c)
c
- The class entered.leaveClass()
public TypeAnalyzer getAnalyzer()
public LocalClassLoader getClassLoader()
setClassLoader(LocalClassLoader)
public java.util.Set<java.lang.String> getCrossAnalyzedTypes()
public java.lang.Class getCurrentClass()
setCurrentClass(Class)
public java.util.Stack<java.util.Hashtable<java.lang.String,java.lang.Class>> getPreviousClasses()
Class
or type Hashtable
.
The bottom element in the stack is always null.
An element of type Hashtable
means the previous entity is
a block, where classes can also be defined in it. In that case,
simple class names are the keys of the table, and Class
objects are its values.
setPreviousClasses(Stack)
public Type getVariable(java.lang.String name)
name
- The variable name.getVariable(String, boolean)
public Type getVariable(java.lang.String name, boolean variablesOnly)
If variableOnly is true, only variable scopes are checked, but class scopes are ignored.
name
- The variable name.variablesOnly
- Whether to check variable scopes only.getVariable(String)
public java.util.Stack<java.util.Hashtable<java.lang.String,Type>> getVariableStack()
Hashtable
, with
variable names as its keys and types of those variables as its
values. The top element in this stack is considered the current
scope. Other elements in it are scopes enclosing the current
scope.setVariableStack(Stack)
public boolean isVariable(java.lang.String name)
name
- The name.public void leaveBlock()
enterBlock()
public void leaveClass()
enterClass(Class)
public int nextAnonymousCount()
public int nextTotalAnonymousCount()
public void setClassLoader(LocalClassLoader loader)
loader
- The class loader.getClassLoader()
public void setClassScope()
unsetClassScope()
public void setCurrentClass(java.lang.Class currentClass)
currentClass
- The current class, or null if there
is no current class.getCurrentClass()
public void setPreviousClasses(java.util.Stack<java.util.Hashtable<java.lang.String,java.lang.Class>> previousClasses)
Class
. The bottom element in the stack is always null.previousClasses
- The previous class stack.getPreviousClasses()
public void setVariableStack(java.util.Stack<java.util.Hashtable<java.lang.String,Type>> variableStack)
Hashtable
, with
variable names as its keys and types of those variables as its
values. The top element in this stack is considered the current
scope. Other elements in it are scopes enclosing the current
scope.variableStack
- The variable stack.getVariableStack()
public void unsetClassScope()
A class scope should be unset when removed from the scope stack.
setClassScope()