|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
This class is used during typechecking for control flow analysis that maintains local variable definite assignment (JLS2, 16), throwable, and reachability information (JLS2, 14.20).
| Method Summary | |
void |
addLocalClass(CClass clazz)
Adds to this context a class declared via a type declaration statement. |
void |
addSyntheticThisParameter()
Records that a variable slot must be reserved for a synthetic this parameter. |
void |
addThisVariable()
Records that the Java keyword this is used in this
block. |
void |
addThrowable(CThrowableInfo throwable)
Registers that the given throwable can be thrown within this context. |
void |
addVariable(JLocalVariable var)
Adds a local variable to this block |
void |
adopt(CFlowControlContextType context)
|
void |
adoptParallelContexts(CFlowControlContextType[] contexts)
Adopts the information from the given contexts. |
void |
checkingComplete()
Registers that this context is no longer needed. |
CFlowControlContextType |
cloneContext()
Create a clone of this context to handle divergent paths in the control flow. |
CExpressionContextType |
createExpressionContext()
|
CFlowControlContextType |
createFinallyContext(CFlowControlContextType tryContext,
TokenReference where)
|
CFlowControlContextType |
createFlowControlContext(int params,
TokenReference where)
|
CFlowControlContextType |
createFlowControlContext(TokenReference where)
|
CLabeledContext |
createLabeledContext(JLabeledStatement self)
|
CLoopContext |
createLoopContext(JLoopStatement self)
|
CFlowControlContextType[] |
createParallelContexts(int count,
TokenReference where)
Creates a set of child contexts for typechecking parallel control flows. |
CSwitchBodyContext |
createSwitchBodyContext(JSwitchStatement stmt,
CType switchType)
|
CTryContext |
createTryContext(TokenReference where)
|
CVariableInfoTable |
fieldInfo()
Returns the field info table |
CFlowControlContextType |
getFlowControlContext()
Returns the nearest control flow context (where control flow information is stored.) |
JLabeledStatement |
getLabeledStatement(String label)
Returns the statement with the specified label. |
JStatement |
getNearestBreakableStatement()
Returns the nearest breakable statement. |
JStatement |
getNearestContinuableStatement()
Returns the nearest continuable statement. |
TokenReference |
getTokenReference()
|
void |
initializeField(VariableDescriptor varDesc)
Marks the field with the given descriptor as definitely assigned to in this context. |
void |
initializeVariable(VariableDescriptor varDesc)
Marks the variable with the given descriptor as definitely assigned to in this context. |
boolean |
isFieldDefinitelyAssigned(int pos)
Indicates whether the field in the given position is definitely assigned to in this context. |
boolean |
isFreshVariableName(JLocalVariable var)
Checks whether a local variable has a name that is fresh (i.e., no other local variable in scope has the same name). |
boolean |
isReachable()
Indicates whether the statements in this context are reachable up to most recent statement that was typechecked. |
boolean |
isVarDefinitelyAssigned(int pos)
Indicates whether the variable in the given position is definitely assigned to in this context. |
boolean |
isVarDefinitelyUnassigned(int i)
Indicates whether the variable in the given position is definitely unassigned to in this context |
int |
localsIndex()
|
int |
localsPosition()
Returns the number of stack positions required to store the local variables encountered thus far in this context. |
ArrayList |
localVars()
Returns the local variables list |
CClass |
lookupClass(String name)
Searches for a class with the given simple name according the procedure in JLS2 6.5.5. |
void |
merge(CFlowControlContextType context)
|
int |
numberOfLocalVars()
|
int |
parentIndex()
|
void |
replaceFieldInfoUpTo(int pos,
CVariableInfoTable replacement)
Replaces the local field info for fields in positions 0 up to pos with the info in replacement. |
void |
replaceVariableInfoUpTo(int pos,
CVariableInfoTable replacement)
Replaces the local variable info in positions 0 up to pos with the info in replacement. |
void |
setReachable(boolean reachable)
Mutates the reachability status of this context. |
CVariableInfoTable |
variableInfo()
Returns the variable info table |
| Method Detail |
public void checkingComplete()
Registers that this context is no longer needed. Passes information collected by this context to the parent context.
Passes this context's field information to the surrounding context; passes local variable information to the surrounding context if that context is one which maintains local variable information.
Checks that local variables are used and issues warnings if not.
This should only be called on a linearly nested context! !FIXME!10/26 If we refactor the context creation code as planned (to lock the parent context) then this method is called to unlock the parent context when we exit a linearly nested context.
public TokenReference getTokenReference()
public CFlowControlContextType createFlowControlContext(TokenReference where)
public CFlowControlContextType createFlowControlContext(int params,
TokenReference where)
public CLabeledContext createLabeledContext(JLabeledStatement self)
public CLoopContext createLoopContext(JLoopStatement self)
public CSwitchBodyContext createSwitchBodyContext(JSwitchStatement stmt,
CType switchType)
public CTryContext createTryContext(TokenReference where)
public CFlowControlContextType createFinallyContext(CFlowControlContextType tryContext,
TokenReference where)
public CExpressionContextType createExpressionContext()
public CFlowControlContextType cloneContext()
public CFlowControlContextType[] createParallelContexts(int count,
TokenReference where)
adoptParallelContexts method of this.
requires count > 0;
adoptParallelContexts(CFlowControlContextType[])public void adoptParallelContexts(CFlowControlContextType[] contexts)
requires contexts != null && contexts.length > 0;
public void merge(CFlowControlContextType context)
public void adopt(CFlowControlContextType context)
public boolean isFreshVariableName(JLocalVariable var)
var - the variable
public void addVariable(JLocalVariable var)
throws UnpositionedError
var - the name of the variable
UnpositionedError - if the variable is a redeclarationpublic void addThisVariable()
this is used in this
block.
public void addSyntheticThisParameter()
this parameter. Recall that this is
passed as a parameter for external methods.
public int localsPosition()
public int numberOfLocalVars()
public CVariableInfoTable variableInfo()
public CVariableInfoTable fieldInfo()
public ArrayList localVars()
public int parentIndex()
public int localsIndex()
public void setReachable(boolean reachable)
reachable - indicates whether the statements in this context
are reachable after the current statement being
checked.public boolean isReachable()
setReachable appropriately.)
public JLabeledStatement getLabeledStatement(String label)
public JStatement getNearestBreakableStatement()
public JStatement getNearestContinuableStatement()
public CFlowControlContextType getFlowControlContext()
getFlowControlContext in interface CContextTypepublic void initializeVariable(VariableDescriptor varDesc)
public boolean isVarDefinitelyAssigned(int pos)
public boolean isVarDefinitelyUnassigned(int i)
i - stack position
public void replaceFieldInfoUpTo(int pos,
CVariableInfoTable replacement)
pos with the info in replacement.
replaceFieldInfoUpTo in interface CContextType
public void replaceVariableInfoUpTo(int pos,
CVariableInfoTable replacement)
pos with the info in replacement.
public void initializeField(VariableDescriptor varDesc)
initializeField in interface CContextTypepublic boolean isFieldDefinitelyAssigned(int pos)
isFieldDefinitelyAssigned in interface CContextType
public void addLocalClass(CClass clazz)
throws UnpositionedError
clazz - the clazz to add
UnpositionedError - if duplicate class exists in this
lexical context
public CClass lookupClass(String name)
throws UnpositionedError
lookupClass in interface CContextTypename - the class name, without qualifiers
UnpositionedError - if search fails public void addThrowable(CThrowableInfo throwable)
throwable - the type of the new throwable
|
JML | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||