Class ControlFlowStructure
- java.lang.Object
-
- it.unive.lisa.program.cfg.controlFlow.ControlFlowStructure
-
- Direct Known Subclasses:
IfThenElse
,Loop
public abstract class ControlFlowStructure extends java.lang.Object
A control flow structure of aCFG
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.util.Collection<Statement>
allStatements()
Yields all theStatement
s contained in this structure, including the condition and the first follower.protected abstract java.util.Collection<Statement>
bodyStatements()
Yields all theStatement
s contained in the body of this structure (thus excluding the condition and the first follower).abstract boolean
contains(Statement st)
Yieldstrue
if the given statement is part of the body of this structure.int
distance(Statement st)
Yields the minimum distance, in terms of number of edges to traverse, between the condition of this structure and the given node.boolean
equals(java.lang.Object obj)
NodeList<CFG,Statement,Edge>
getCompleteStructure()
Yields anNodeList
containing the full structure (nodes and edges) represented by this conditional structure.Statement
getCondition()
Yields the condition of this structure.Statement
getFirstFollower()
Yields the first follower of this structure, that is, the first statement after the conditional structure exits.abstract java.util.Collection<Statement>
getTargetedStatements()
Yields all the statements that are targeted by some node in this structure.int
hashCode()
void
setFirstFollower(Statement firstFollower)
Sets the first follower of this structure, that is, the first statement after the conditional structure exits.abstract void
simplify()
Simplifies this structure, removing allNoOp
s from its body.abstract java.lang.String
toString()
-
-
-
Constructor Detail
-
ControlFlowStructure
protected ControlFlowStructure(NodeList<CFG,Statement,Edge> cfgMatrix, Statement condition, Statement firstFollower)
Builds the structure.- Parameters:
cfgMatrix
- the matrix of the cfg containing this structurecondition
- the condition of the structurefirstFollower
- the first statement after the structure exits
-
-
Method Detail
-
getCondition
public final Statement getCondition()
Yields the condition of this structure.- Returns:
- the condition
-
getFirstFollower
public final Statement getFirstFollower()
Yields the first follower of this structure, that is, the first statement after the conditional structure exits.- Returns:
- the follower
-
setFirstFollower
public void setFirstFollower(Statement firstFollower)
Sets the first follower of this structure, that is, the first statement after the conditional structure exits.- Parameters:
firstFollower
- the new follower
-
allStatements
public final java.util.Collection<Statement> allStatements()
Yields all theStatement
s contained in this structure, including the condition and the first follower.- Returns:
- the statements of the body of this structure
-
bodyStatements
protected abstract java.util.Collection<Statement> bodyStatements()
Yields all theStatement
s contained in the body of this structure (thus excluding the condition and the first follower).- Returns:
- the statements of the body of this structure
-
contains
public abstract boolean contains(Statement st)
Yieldstrue
if the given statement is part of the body of this structure. Note that this method will returnfalse
ifst
is either the condition of the first follower of this structure.- Parameters:
st
- the statement to check- Returns:
true
ifst
is in the body of this structure
-
simplify
public abstract void simplify()
Simplifies this structure, removing allNoOp
s from its body.
-
distance
public int distance(Statement st)
Yields the minimum distance, in terms of number of edges to traverse, between the condition of this structure and the given node. Ifst
is not in this structure, this method returns-1
. If the distance is greater thanInteger.MAX_VALUE
,Integer.MAX_VALUE
is returned.- Parameters:
st
- the node to reach starting at the condition- Returns:
- the minimum distance, in terms of number of edges to traverse, between the condition and the given node
-
getCompleteStructure
public NodeList<CFG,Statement,Edge> getCompleteStructure()
Yields anNodeList
containing the full structure (nodes and edges) represented by this conditional structure. The returned matrix will also contain the condition and the first follower, if any.- Returns:
- the matrix containing the full structure
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public abstract java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getTargetedStatements
public abstract java.util.Collection<Statement> getTargetedStatements()
Yields all the statements that are targeted by some node in this structure. This always comprises destination nodes of conditional branches, and join points where more than one branch converge. Equivalently, these can be characterized as targets of conditional or unconditional branches and followers of conditional or unconditional branches.- Returns:
- the targeted statements
-
-