Package org.jtool.cfg
Class CFGStatement
java.lang.Object
org.jtool.graph.GraphElement
org.jtool.graph.GraphNode
org.jtool.cfg.CFGNode
org.jtool.cfg.CFGStatement
- Direct Known Subclasses:
CFGException
,CFGMethodCall
,CFGParameter
,CFGReceiver
A statement node of a CFG, which stores variables defined and used in it.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.jtool.cfg.CFGNode
CFGNode.Kind
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected List<JVariableReference>
The collection of variables defined in this node.protected List<JVariableReference>
The collection of variables used in this node.Fields inherited from class org.jtool.graph.GraphNode
id, incomingEdges, outgoingEdges
-
Constructor Summary
ConstructorsConstructorDescriptionCFGStatement
(org.eclipse.jdt.core.dom.ASTNode node, CFGNode.Kind kind) Creates a new object that represents a statement. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a variable to the collection of variables defined in this node.void
Adds variables to the collection of variables defined in this node.void
Adds a variable to the collection of variables used in this node.void
Adds variables to the collection of variables used in this node.void
Clears the collection of variables defined in this node.void
Clears the collection of variables defined in this node.boolean
Tests if this node defines a given variable.Obtains primary variables used in this assignment node.findPrimaryUseVariables
(org.eclipse.jdt.core.dom.Expression expr) Obtains primary variables used in this node.Returns the first one from the collection of variables defined in this node.Returns the last one from the collection of variables defined in this node.getDefVariable
(String name) Returns a variable having a given name from the collection of variables defined in this node.Returns variables defined in this node.Returns the first one from the collection of variables used in this node.Returns the last one from the collection of variables used in this node.getUseVariable
(String name) Returns a variable having a given name from the collection of variables used in this node.Returns variables used in this node.boolean
Tests if this node defines any variable.boolean
Tests if this node uses any variable.boolean
Removes a variable from the collection of variables defined in this node.boolean
Removes a variable from the collection of variables used in this node.void
Sets the collection that stores a variable defined in this node.void
Sets the collection of variables defined in this node.void
Sets the collection that stores a variable used in this node.void
Sets the collection of variables used in this node.toString()
Obtains information on this node.protected String
Obtains information on variables.boolean
Tests if this node uses a given variable.Methods inherited from class org.jtool.cfg.CFGNode
equals, equals, getASTNode, getIncomingFalseFlows, getIncomingFlows, getIncomingTrueFlows, getKind, getNumOfPredecessors, getNumOfSuccessors, getOutgoingFalseFlow, getOutgoingFlows, getOutgoingTrueFlow, getPDGNode, getPredecessors, getSuccessors, hashCode, isActual, isActualIn, isActualOut, isAssert, isAssignment, isBranch, isBreak, isCatchClause, isClassEntry, isConstructorEntry, isContinue, isDo, isDummy, isEnhancedFor, isEntry, isEnumConstantEntry, isEnumEntry, isExit, isExpression, isFieldDeclaration, isFieldEntry, isFinallyClause, isFor, isFormal, isFormalIn, isFormalOut, isIf, isInitializerEntry, isInterfaceEntry, isJoin, isLabel, isLiteral, isLocalDeclaration, isLoop, isMerge, isMethodCall, isMethodEntry, isNextToBranch, isParameter, isReceiver, isReturn, isSelection, isStatement, isStatement, isStatementNotParameter, isSwitch, isSwitchCase, isSwitchDefault, isSynchronized, isThrow, isThrowClause, isTry, isWhile, print, resetId, setASTNode, setKind, setPDGNode, sortNodes, sortNodesInverse
Methods inherited from class org.jtool.graph.GraphNode
addIncomingEdge, addIncomingEdges, addOutgoingEdge, addOutgoingEdges, clear, equals, equals, getDstNodes, getId, getIncomingEdges, getOutgoingEdges, getSrcNodes, removeIncomingEdge, removeOutgoingEdge, setId, sortGraphNode
Methods inherited from class org.jtool.graph.GraphElement
difference, equals, getIdString, intersection, subset, subsetEqual, union
-
Field Details
-
defs
The collection of variables defined in this node. -
uses
The collection of variables used in this node.
-
-
Constructor Details
-
CFGStatement
Creates a new object that represents a statement. This method is not intended to be invoked by clients.- Parameters:
node
- the AST node corresponding to this nodekind
- the kind of this node
-
-
Method Details
-
addDefVariable
Adds a variable to the collection of variables defined in this node. This method is not intended to be invoked by clients.- Parameters:
jv
- the variable to be added
-
addUseVariable
Adds a variable to the collection of variables used in this node. This method is not intended to be invoked by clients.- Parameters:
jv
- the variable to be added
-
addDefVariables
Adds variables to the collection of variables defined in this node. This method is not intended to be invoked by clients.- Parameters:
jvs
- the collection of the variables to be added
-
addUseVariables
Adds variables to the collection of variables used in this node. This method is not intended to be invoked by clients.- Parameters:
jvs
- the collection of the variables to be added
-
removeDefVariable
Removes a variable from the collection of variables defined in this node. This method is not intended to be invoked by clients.- Parameters:
jv
- the collection of the variables to be removed- Returns:
true
if the removal is successfully done, otherwisefalse
-
removeUseVariable
Removes a variable from the collection of variables used in this node. This method is not intended to be invoked by clients.- Parameters:
jv
- the collection of the variables to be removed- Returns:
true
if the removal is successfully done, otherwisefalse
-
clearDefVariables
public void clearDefVariables()Clears the collection of variables defined in this node. This method is not intended to be invoked by clients. -
clearUseVariables
public void clearUseVariables()Clears the collection of variables defined in this node. This method is not intended to be invoked by clients. -
setDefVariables
Sets the collection of variables defined in this node. This method is not intended to be invoked by clients.- Parameters:
jvs
- the collection of the variables to be set
-
setUseVariables
Sets the collection of variables used in this node. This method is not intended to be invoked by clients.- Parameters:
jvs
- the collection of the variables to be set
-
setDefVariable
Sets the collection that stores a variable defined in this node. This method is not intended to be invoked by clients.- Parameters:
jv
- the variable to be set
-
setUseVariable
Sets the collection that stores a variable used in this node. This method is not intended to be invoked by clients.- Parameters:
jv
- the variable to be set
-
getDefVariables
Returns variables defined in this node.- Returns:
- the collection of the defined variables
-
getUseVariables
Returns variables used in this node.- Returns:
- the collection of the used variables
-
defineVariable
Tests if this node defines a given variable.- Parameters:
jv
- the variable to be checked- Returns:
true
if the variable is defined in this node, otherwisefalse
-
useVariable
Tests if this node uses a given variable.- Parameters:
jv
- the variable to be checked- Returns:
true
if the variable is used in this node, otherwisefalse
-
hasDefVariable
public boolean hasDefVariable()Tests if this node defines any variable.- Overrides:
hasDefVariable
in classCFGNode
- Returns:
true
if there is a defined variable found in this node, otherwisefalse
-
hasUseVariable
public boolean hasUseVariable()Tests if this node uses any variable.- Overrides:
hasUseVariable
in classCFGNode
- Returns:
true
if there is a used variable found in this node, otherwisefalse
-
getDefVariable
Returns a variable having a given name from the collection of variables defined in this node.- Parameters:
name
- the name of the variable- Returns:
- the found variable, or
null
if no variable is found
-
getUseVariable
Returns a variable having a given name from the collection of variables used in this node.- Parameters:
name
- the name of the variable- Returns:
- the found variable, or
null
if no variable is found
-
getDefFirst
Returns the first one from the collection of variables defined in this node.- Returns:
- the defined variable at the first position, or
null
if this node never defines any variable
-
getUseFirst
Returns the first one from the collection of variables used in this node.- Returns:
- the used variable at the first position, or
null
if this node never uses any variable
-
getDefLast
Returns the last one from the collection of variables defined in this node.- Returns:
- the defined variable at the last position, or
null
if this node never defines any variable
-
getUseLast
Returns the last one from the collection of variables used in this node.- Returns:
- the used variable at the last position, or
null
if this node never uses any variable
-
findPrimaryUseVariables
Obtains primary variables used in this assignment node.- Returns:
- the collection of the primary variables
-
findPrimaryUseVariables
Obtains primary variables used in this node.- Parameters:
expr
- the expression that contains used variables- Returns:
- the collection of the primary variables
-
toString
Obtains information on this node. -
toStringForVariables
Obtains information on variables.- Parameters:
jvars
- the set of variables- Returns:
- the string representing the information
-