public abstract class CfgWalker
extends java.lang.Object
Provides methods for traversing nodes of CfgModel
control flow graph model.
Actions taken in the traversal process depend on the current status of the visitor (see
CfgVisitor.Status
). Possible status values are:
The status is checked after calling any visitor method. Once Status.ABORT
is set,
all traversal methods cease the execution. If after a call to a method having the Begin suffix
(e.g. onModuleBegin), the Status.SKIP
status is set, nested elements of the visited node
(child nodes or subtrees) are not traversed and a corresponding terminating method
(that has the End suffix eg. onModuleEnd) is called.
Constructor and Description |
---|
CfgWalker(CfgVisitor visitor,
CfgWalkerMode mode)
Constructs object with the specified parameters.
|
Modifier and Type | Method and Description |
---|---|
void |
addVisited(java.util.Collection<java.lang.String> visitedIds)
Add statement identifiers from the specified collection to the storage of identifiers
for statements that are already visited by this walker.
|
void |
addVisited(java.lang.String visitedId)
Add the specified statement identifier to the storage of identifiers
for statements that are already visited by this walker.
|
CfgWalkerMode |
getMode() |
java.util.Collection<java.lang.String> |
getVisited()
Returns a collection of identifiers for statements that are already visited.
|
CfgVisitor |
getVisitor()
Returns visitor.
|
abstract void |
goToNextStatement()
Next statement for walking choosing method.
|
protected boolean |
isStatus(CfgVisitor.Status status)
Checks rather this walker object has the specified status value.
|
abstract void |
processChildren(CfgStatement statement)
Process child statements of the specified one.
|
void |
start(CfgModel model)
Starts control flow graph model walking.
|
void |
visitNode(CfgStatement node)
Visits the specified node.
|
public CfgWalker(CfgVisitor visitor, CfgWalkerMode mode)
visitor
- visitor to be applied to control flow graph modelmode
- walking modejava.lang.IllegalArgumentException
- when any argument is null
.public CfgVisitor getVisitor()
CfgVisitor
public CfgWalkerMode getMode()
public java.util.Collection<java.lang.String> getVisited()
public void addVisited(java.lang.String visitedId)
visitedId
- statement identifier that should be treated by this walker as already visitedjava.lang.IllegalArgumentException
- when argument is null
.public void addVisited(java.util.Collection<java.lang.String> visitedIds)
visitedIds
- identifiers for statements that should be treated as already visitedjava.lang.IllegalArgumentException
- when argument is null
.public void start(CfgModel model)
model
- control flow graph modeljava.lang.IllegalArgumentException
- when argument is null
.public void visitNode(CfgStatement node)
node
- node to be visitedjava.lang.IllegalArgumentException
- when argument is null
.public abstract void processChildren(CfgStatement statement)
statement
- Statement those children are to be processed.public abstract void goToNextStatement()
protected boolean isStatus(CfgVisitor.Status status)
status
- Status valuetrue
whether this object has the specified status value,
false
otherwise.