Class ControlFlowStructure
- java.lang.Object
-
- it.unive.lisa.program.cfg.controlFlow.ControlFlowStructure
-
- Direct Known Subclasses:
IfThenElse,Loop
public abstract class ControlFlowStructure extends java.lang.ObjectA 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 theStatements contained in this structure, including the condition and the first follower.protected abstract java.util.Collection<Statement>bodyStatements()Yields all theStatements contained in the body of this structure (thus excluding the condition and the first follower).abstract booleancontains(Statement st)Yieldstrueif the given statement is part of the body of this structure.intdistance(Statement st)Yields the minimum distance, in terms of number of edges to traverse, between the condition of this structure and the given node.booleanequals(java.lang.Object obj)NodeList<CFG,Statement,Edge>getCompleteStructure()Yields anNodeListcontaining the full structure (nodes and edges) represented by this conditional structure.StatementgetCondition()Yields the condition of this structure.StatementgetFirstFollower()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.inthashCode()voidsetFirstFollower(Statement firstFollower)Sets the first follower of this structure, that is, the first statement after the conditional structure exits.abstract voidsimplify()Simplifies this structure, removing allNoOps from its body.abstract java.lang.StringtoString()
-
-
-
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 theStatements 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 theStatements 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)
Yieldstrueif the given statement is part of the body of this structure. Note that this method will returnfalseifstis either the condition of the first follower of this structure.- Parameters:
st- the statement to check- Returns:
trueifstis in the body of this structure
-
simplify
public abstract void simplify()
Simplifies this structure, removing allNoOps 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. Ifstis not in this structure, this method returns-1. If the distance is greater thanInteger.MAX_VALUE,Integer.MAX_VALUEis 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 anNodeListcontaining 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:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public abstract java.lang.String toString()
- Overrides:
toStringin 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
-
-