Package org.jtool.cfg
Class CFGNode
java.lang.Object
org.jtool.graph.GraphElement
org.jtool.graph.GraphNode
org.jtool.cfg.CFGNode
- Direct Known Subclasses:
CCFGEntry
,CFGEntry
,CFGExit
,CFGMerge
,CFGStatement
A node of a CFG.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.eclipse.jdt.core.dom.ASTNode
The AST node corresponding to this node.protected CFGNode.Kind
The kind of this node.protected PDGNode
The PDG node corresponding to this node.Fields inherited from class org.jtool.graph.GraphNode
id, incomingEdges, outgoingEdges
-
Constructor Summary
ConstructorsConstructorDescriptionCFGNode()
Creates a new object that represents a dummy node.CFGNode
(org.eclipse.jdt.core.dom.ASTNode node, CFGNode.Kind kind) Creates a new object that represents a CFG node. -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
Tests if a given CFG node is equal to this node.org.eclipse.jdt.core.dom.ASTNode
Returns the AST node corresponding to this node.Obtains true control flow edges incoming to this node.Obtains control flow edges incoming to this node.Obtains true control flow edges incoming to this node.getKind()
Returns the kind of this node.int
Returns the number of predecessors of this node.int
Returns the number of successors of this node.Obtains true control flow edges outgoing from this node.Obtains control flow edges outgoing from this node.Obtains true control flow edges outgoing from this node.Returns the PDG node corresponding to this node.Obtains predecessors of this node.Obtains successors of this node.boolean
Tests if a variable is defined in this node.int
hashCode()
boolean
Tests if a variable is used in this node.boolean
isActual()
Tests if this is a statement node formed by an actual argument.boolean
Tests if this is a statement node formed by an actual-in argument.boolean
Tests if this is a statement node formed by an actual-out argument.boolean
isAssert()
Tests if this is an assert-statement node.boolean
Tests if this is a statement node formed by an assignment.boolean
isBranch()
Tests if this node causes branching, which has multiple outgoing control flow edges.boolean
isBreak()
Tests if this is a break-statement node.boolean
Tests if this is a catch-clause node.boolean
Tests if this is a class entry node.boolean
Tests if this is a constructor entry node.boolean
Tests if this is a continue-statement node.boolean
isDo()
Tests if this is a do-statement node.boolean
isDummy()
Tests if this is a dummy node.boolean
Tests if this is an enhanced for-statement node.boolean
isEntry()
Tests if this is an entry node.boolean
Tests if this is an enum constant entry node.boolean
Tests if this is an enum entry node.boolean
isExit()
Tests if this is an exit node.static boolean
isExpression
(org.eclipse.jdt.core.dom.ASTNode node) Tests if a AST node is categorized into the expression.boolean
Tests if this is a statement node formed by a field declaration.boolean
Tests if this is a field entry node.boolean
Tests if this is a finally-clause node.boolean
isFor()
Tests if this is a for-statement node.boolean
isFormal()
Tests if this is a statement node formed by a formal parameter.boolean
Tests if this is a statement node formed by a formal-in parameter.boolean
Tests if this is a statement node formed by a formal-out parameter.boolean
isIf()
Tests if this is an if-statement node.boolean
Tests if this is a static initializer entry node.boolean
Tests if this is an interface entry node.boolean
isJoin()
Tests if this node causes joining, which has multiple incoming control flow edges.boolean
isLabel()
Tests if this is a statement node for the label.static boolean
isLiteral
(org.eclipse.jdt.core.dom.ASTNode node) Tests if a AST node is categorized into the literal.boolean
Tests if this is a statement node formed by a local variable declaration.boolean
isLoop()
Tests if this node causes looping.boolean
isMerge()
Tests if this node is responsible for merging branches.boolean
Tests if this is a statement node formed by a method call.boolean
Tests if this is a method entry node.boolean
Tests if this node is a successor of the branch node.boolean
Tests if this is a statement node formed by a parameter.boolean
Tests if this is a statement node formed by a receiver.boolean
isReturn()
Tests if this is a return statement node.boolean
Tests if this node causes selection.boolean
Tests if this is a a statement node.static boolean
isStatement
(org.eclipse.jdt.core.dom.ASTNode node) Tests if a AST node is categorized into the statement.boolean
Tests if this node represents a statement but not a parameter.boolean
isSwitch()
Tests if this is a switch-statement node.boolean
Tests if this is a switch-case node for the case label.boolean
Tests if this is a switch-default-case node for the default label.boolean
Tests if this is a synchronized-statement node.boolean
isThrow()
Tests if this is a throw-statement node.boolean
Tests if this is a throws-clause node.boolean
isTry()
Tests if this is a try-statement node.boolean
isWhile()
Tests if this is a while-statement node.void
print()
Displays information on this node.static void
resetId()
Resets the identification number for CFG nodes.void
setASTNode
(org.eclipse.jdt.core.dom.ASTNode node) Sets the AST node corresponding to this node.void
setKind
(CFGNode.Kind kind) Sets the kind of this node.void
setPDGNode
(PDGNode node) Sets the PDG node corresponding to this node.sortNodes
(Collection<? extends CFGNode> nodes) Sorts the list of CFG nodessortNodesInverse
(Collection<? extends CFGNode> collection) Sorts inversely the list of CFG nodestoString()
Obtains information on this node.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
-
astNode
protected org.eclipse.jdt.core.dom.ASTNode astNodeThe AST node corresponding to this node. -
kind
The kind of this node. -
pdgNode
The PDG node corresponding to this node.
-
-
Constructor Details
-
CFGNode
public CFGNode()Creates a new object that represents a dummy node. This method is not intended to be invoked by clients. -
CFGNode
Creates a new object that represents a CFG node. 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
-
resetId
public static void resetId()Resets the identification number for CFG nodes. This method is not intended to be invoked by clients. -
setASTNode
public void setASTNode(org.eclipse.jdt.core.dom.ASTNode node) Sets the AST node corresponding to this node. This method is not intended to be invoked by clients.- Parameters:
node
- the AST node to be set
-
getASTNode
public org.eclipse.jdt.core.dom.ASTNode getASTNode()Returns the AST node corresponding to this node.- Returns:
- the corresponding AST node
-
setKind
Sets the kind of this node. This method is not intended to be invoked by clients.- Parameters:
kind
- the kind to be set
-
getKind
Returns the kind of this node.- Returns:
- the kind of this node
-
setPDGNode
Sets the PDG node corresponding to this node. This method is not intended to be invoked by clients.- Parameters:
node
- the PDG node to be set
-
getPDGNode
Returns the PDG node corresponding to this node.- Returns:
- the corresponding PDG node
-
getPredecessors
Obtains predecessors of this node.- Returns:
- the collection of the predecessors
-
getSuccessors
Obtains successors of this node.- Returns:
- the collection of the successors
-
getNumOfPredecessors
public int getNumOfPredecessors()Returns the number of predecessors of this node.- Returns:
- the the number of the predecessors
-
getNumOfSuccessors
public int getNumOfSuccessors()Returns the number of successors of this node.- Returns:
- the the number of the successors
-
getIncomingFlows
Obtains control flow edges incoming to this node.- Returns:
- the collection of the incoming edges
-
getOutgoingFlows
Obtains control flow edges outgoing from this node.- Returns:
- the collection of the outgoing edges
-
getIncomingTrueFlows
Obtains true control flow edges incoming to this node.- Returns:
- the collection of the incoming true edges
-
getIncomingFalseFlows
Obtains true control flow edges incoming to this node.- Returns:
- the collection of the incoming false edges
-
getOutgoingTrueFlow
Obtains true control flow edges outgoing from this node.- Returns:
- the outgoing true edge
-
getOutgoingFalseFlow
Obtains true control flow edges outgoing from this node.- Returns:
- the outgoing false edge
-
isBranch
public boolean isBranch()Tests if this node causes branching, which has multiple outgoing control flow edges.- Returns:
true
if this node causes branching, otherwisefalse
-
isSelection
public boolean isSelection()Tests if this node causes selection.- Returns:
true
if this node causes selection, otherwisefalse
-
isLoop
public boolean isLoop()Tests if this node causes looping.- Returns:
true
if this node causes looping, otherwisefalse
-
isJoin
public boolean isJoin()Tests if this node causes joining, which has multiple incoming control flow edges.- Returns:
true
if this node causes joining, otherwisefalse
-
isEntry
public boolean isEntry()Tests if this is an entry node.- Returns:
true
if this is an entry node, otherwisefalse
-
isClassEntry
public boolean isClassEntry()Tests if this is a class entry node.- Returns:
true
if this is a class entry node, otherwisefalse
-
isInterfaceEntry
public boolean isInterfaceEntry()Tests if this is an interface entry node.- Returns:
true
if this is an interface entry node, otherwisefalse
-
isEnumEntry
public boolean isEnumEntry()Tests if this is an enum entry node.- Returns:
true
if this is an enum entry node, otherwisefalse
-
isMethodEntry
public boolean isMethodEntry()Tests if this is a method entry node.- Returns:
true
if this is a method entry node, otherwisefalse
-
isConstructorEntry
public boolean isConstructorEntry()Tests if this is a constructor entry node.- Returns:
true
if this is a constructor entry node, otherwisefalse
-
isInitializerEntry
public boolean isInitializerEntry()Tests if this is a static initializer entry node.- Returns:
true
if this is a static initializer entry node, otherwisefalse
-
isFieldEntry
public boolean isFieldEntry()Tests if this is a field entry node.- Returns:
true
if this is a field entry node, otherwisefalse
-
isEnumConstantEntry
public boolean isEnumConstantEntry()Tests if this is an enum constant entry node.- Returns:
true
if this is an enum constant entry node, otherwisefalse
-
isExit
public boolean isExit()Tests if this is an exit node.- Returns:
true
if this is an exit node, otherwisefalse
-
isAssignment
public boolean isAssignment()Tests if this is a statement node formed by an assignment.- Returns:
true
if this is an assignment node, otherwisefalse
-
isMethodCall
public boolean isMethodCall()Tests if this is a statement node formed by a method call.- Returns:
true
if this is a method call node, otherwisefalse
-
isFieldDeclaration
public boolean isFieldDeclaration()Tests if this is a statement node formed by a field declaration.- Returns:
true
if this is a field declaration node, otherwisefalse
-
isLocalDeclaration
public boolean isLocalDeclaration()Tests if this is a statement node formed by a local variable declaration.- Returns:
true
if this is a local variable declaration node, otherwisefalse
-
isAssert
public boolean isAssert()Tests if this is an assert-statement node.- Returns:
true
if this is an assert-statement node, otherwisefalse
-
isBreak
public boolean isBreak()Tests if this is a break-statement node.- Returns:
true
if this is a break-statement node, otherwisefalse
-
isContinue
public boolean isContinue()Tests if this is a continue-statement node.- Returns:
true
if this is a continue-statement node, otherwisefalse
-
isDo
public boolean isDo()Tests if this is a do-statement node.- Returns:
true
if this is a do-statement node, otherwisefalse
-
isFor
public boolean isFor()Tests if this is a for-statement node.- Returns:
true
if this is a for-statement node, otherwisefalse
-
isEnhancedFor
public boolean isEnhancedFor()Tests if this is an enhanced for-statement node.- Returns:
true
if this is an enhanced for-statement node, otherwisefalse
-
isIf
public boolean isIf()Tests if this is an if-statement node.- Returns:
true
if this is an if-statement, otherwisefalse
-
isReturn
public boolean isReturn()Tests if this is a return statement node.- Returns:
true
if this is a return statement, otherwisefalse
-
isSwitchCase
public boolean isSwitchCase()Tests if this is a switch-case node for the case label.- Returns:
true
if this is a switch-case-statement, otherwisefalse
-
isSwitchDefault
public boolean isSwitchDefault()Tests if this is a switch-default-case node for the default label.- Returns:
true
if this is a switch-default-statement node, otherwisefalse
-
isWhile
public boolean isWhile()Tests if this is a while-statement node.- Returns:
true
if this is a while-statement node, otherwisefalse
-
isLabel
public boolean isLabel()Tests if this is a statement node for the label.- Returns:
true
if this is a label statement node, otherwisefalse
-
isSwitch
public boolean isSwitch()Tests if this is a switch-statement node.- Returns:
true
if this is a switch-statement, otherwisefalse
-
isSynchronized
public boolean isSynchronized()Tests if this is a synchronized-statement node.- Returns:
true
if this is a synchronized-statement node, otherwisefalse
-
isThrow
public boolean isThrow()Tests if this is a throw-statement node.- Returns:
true
if this is a throw-statement node, otherwisefalse
-
isTry
public boolean isTry()Tests if this is a try-statement node.- Returns:
true
if this is a try-statement node, otherwisefalse
-
isCatchClause
public boolean isCatchClause()Tests if this is a catch-clause node.- Returns:
true
if this is a catch-clause node, otherwisefalse
-
isFinallyClause
public boolean isFinallyClause()Tests if this is a finally-clause node.- Returns:
true
if this is a finally-clause node, otherwisefalse
-
isThrowClause
public boolean isThrowClause()Tests if this is a throws-clause node.- Returns:
true
if this is a throws-clause node, otherwisefalse
-
isParameter
public boolean isParameter()Tests if this is a statement node formed by a parameter.- Returns:
true
if this is a parameter node, otherwisefalse
-
isFormal
public boolean isFormal()Tests if this is a statement node formed by a formal parameter.- Returns:
true
if this is a formal parameter node, otherwisefalse
-
isFormalIn
public boolean isFormalIn()Tests if this is a statement node formed by a formal-in parameter.- Returns:
true
if this is a formal-in parameter node, otherwisefalse
-
isFormalOut
public boolean isFormalOut()Tests if this is a statement node formed by a formal-out parameter.- Returns:
true
if this is a formal parameter-out parameter node, otherwisefalse
-
isActual
public boolean isActual()Tests if this is a statement node formed by an actual argument.- Returns:
true
if this is an actual argument node, otherwisefalse
-
isActualIn
public boolean isActualIn()Tests if this is a statement node formed by an actual-in argument.- Returns:
true
if this is an actual-in argument node, otherwisefalse
-
isActualOut
public boolean isActualOut()Tests if this is a statement node formed by an actual-out argument.- Returns:
true
if this is an actual-out argument node, otherwisefalse
-
isReceiver
public boolean isReceiver()Tests if this is a statement node formed by a receiver.- Returns:
true
if this is a receiver node, otherwisefalse
-
isStatementNotParameter
public boolean isStatementNotParameter()Tests if this node represents a statement but not a parameter.- Returns:
true
if this node represents a statement node but not a parameter, otherwisefalse
-
isStatement
public boolean isStatement()Tests if this is a a statement node.- Returns:
true
if this is a statement node, otherwisefalse
-
isMerge
public boolean isMerge()Tests if this node is responsible for merging branches.- Returns:
true
if this is a merge node, otherwisefalse
-
isDummy
public boolean isDummy()Tests if this is a dummy node.- Returns:
true
if this is a dummy node, otherwisefalse
-
isNextToBranch
public boolean isNextToBranch()Tests if this node is a successor of the branch node.- Returns:
true
if this node is a successor of the branch node, otherwisefalse
-
hasDefVariable
public boolean hasDefVariable()Tests if a variable is defined in this node.- Returns:
true
if this has any used variable, otherwisefalse
-
hasUseVariable
public boolean hasUseVariable()Tests if a variable is used in this node.- Returns:
true
if this has any used variable, otherwisefalse
-
equals
- Overrides:
equals
in classGraphElement
-
equals
Tests if a given CFG node is equal to this node.- Parameters:
node
- the node to be checked- Returns:
- the
true
if the given node is equal to this node
-
hashCode
public int hashCode() -
print
public void print()Displays information on this node. -
toString
Obtains information on this node. -
sortNodes
Sorts the list of CFG nodes- Parameters:
nodes
- the collection of the CFG nodes to be sorted- Returns:
- the sorted list of the CFG nodes
-
sortNodesInverse
Sorts inversely the list of CFG nodes- Parameters:
collection
- the collection of the CFG nodes to be sorted- Returns:
- the sorted list of the CFG nodes
-
isStatement
public static boolean isStatement(org.eclipse.jdt.core.dom.ASTNode node) Tests if a AST node is categorized into the statement.- Parameters:
node
- an AST node to be checked- Returns:
true
if the AST node is categorized into the statement, otherwisefalse
-
isExpression
public static boolean isExpression(org.eclipse.jdt.core.dom.ASTNode node) Tests if a AST node is categorized into the expression.- Parameters:
node
- an AST node to be checked- Returns:
true
if the AST node is categorized into the expression, otherwisefalse
-
isLiteral
public static boolean isLiteral(org.eclipse.jdt.core.dom.ASTNode node) Tests if a AST node is categorized into the literal.- Parameters:
node
- an AST node to be checked- Returns:
true
if the AST node is categorized into the literal, otherwisefalse
-