Class IfThenElse
- java.lang.Object
-
- it.unive.lisa.program.cfg.controlFlow.ControlFlowStructure
-
- it.unive.lisa.program.cfg.controlFlow.IfThenElse
-
public class IfThenElse extends ControlFlowStructure
AControlFlowStructurerepresenting a if-then-else.
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.program.cfg.controlFlow.ControlFlowStructure
cfgMatrix
-
-
Constructor Summary
Constructors Constructor Description IfThenElse(AdjacencyMatrix<Statement,Edge,CFG> cfgMatrix, Statement condition, Statement firstFollower, java.util.Collection<Statement> trueBranch, java.util.Collection<Statement> falseBranch)Builds the if-then-else.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Collection<Statement>bodyStatements()Yields all theStatements contained in the body of this structure (thus excluding the condition and the first follower).booleancontains(Statement st)Yieldstrueif the given statement is part of the body of this structure.booleanequals(java.lang.Object obj)java.util.Collection<Statement>getFalseBranch()Yields theStatements contained in the false branch of this if-then-else.java.util.Collection<Statement>getTrueBranch()Yields theStatements contained in the true branch of this if-then-else.inthashCode()voidsimplify()Simplifies this structure, removing allNoOps from its body.java.lang.StringtoString()-
Methods inherited from class it.unive.lisa.program.cfg.controlFlow.ControlFlowStructure
allStatements, distance, getCompleteStructure, getCondition, getFirstFollower, setFirstFollower
-
-
-
-
Constructor Detail
-
IfThenElse
public IfThenElse(AdjacencyMatrix<Statement,Edge,CFG> cfgMatrix, Statement condition, Statement firstFollower, java.util.Collection<Statement> trueBranch, java.util.Collection<Statement> falseBranch)
Builds the if-then-else.- Parameters:
cfgMatrix- the matrix of the cfg containing this if-then-elsecondition- the condition of the if-then-elsefirstFollower- the first statement after the if-then-else exits one of the branchestrueBranch- the statements in the true branchfalseBranch- the statements in the false branch
-
-
Method Detail
-
bodyStatements
public java.util.Collection<Statement> bodyStatements()
Description copied from class:ControlFlowStructureYields all theStatements contained in the body of this structure (thus excluding the condition and the first follower).- Specified by:
bodyStatementsin classControlFlowStructure- Returns:
- the statements of the body of this structure
-
getTrueBranch
public java.util.Collection<Statement> getTrueBranch()
Yields theStatements contained in the true branch of this if-then-else.- Returns:
- the true branch of the if-then-else
-
getFalseBranch
public java.util.Collection<Statement> getFalseBranch()
Yields theStatements contained in the false branch of this if-then-else.- Returns:
- the false branch of the if-then-else
-
contains
public boolean contains(Statement st)
Description copied from class:ControlFlowStructureYieldstrueif 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.- Specified by:
containsin classControlFlowStructure- Parameters:
st- the statement to check- Returns:
trueifstis in the body of this structure
-
simplify
public void simplify()
Description copied from class:ControlFlowStructureSimplifies this structure, removing allNoOps from its body.- Specified by:
simplifyin classControlFlowStructure
-
hashCode
public int hashCode()
- Overrides:
hashCodein classControlFlowStructure
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classControlFlowStructure
-
toString
public java.lang.String toString()
- Specified by:
toStringin classControlFlowStructure
-
-