Class Statement
- java.lang.Object
-
- it.unive.lisa.program.cfg.statement.Statement
-
- All Implemented Interfaces:
ProgramPoint
,CodeElement
,CodeNode<CFG,Statement,Edge>
,Node<CFG,Statement,Edge>
,java.lang.Comparable<Statement>
- Direct Known Subclasses:
Expression
,NoOp
,Ret
,UnaryStatement
public abstract class Statement extends java.lang.Object implements CodeNode<CFG,Statement,Edge>, ProgramPoint, java.lang.Comparable<Statement>
A statement of the program to analyze.
-
-
Field Summary
Fields Modifier and Type Field Description protected int
offset
The offset of the statement within the cfg.
-
Constructor Summary
Constructors Modifier Constructor Description protected
Statement(CFG cfg, CodeLocation location)
Builds a statement happening at the given source location.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
compareTo(Statement o)
boolean
equals(java.lang.Object obj)
CFG
getCFG()
Yields theCFG
that this program point belongs to.Statement
getEvaluationPredecessor()
Yields theStatement
that is evaluated right before this one, such that querying for the entry state ofthis
expression is equivalent to querying the exit state of the returned one.CodeLocation
getLocation()
Yields the location where this code element appears in the program.int
getOffset()
Yields the offset of this node relative to its containing graph.Statement
getStatementEvaluatedBefore(Statement other)
Yields theStatement
that precedes the given one, assuming thatother
is contained into this expression.int
hashCode()
abstract <A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>
AnalysisState<A,H,V,T>semantics(AnalysisState<A,H,V,T> entryState, InterproceduralAnalysis<A,H,V,T> interprocedural, StatementStore<A,H,V,T> expressions)
Computes the semantics of the statement, expressing how semantic information is transformed by the execution of this statement.boolean
stopsExecution()
Whether or not this statement stops the execution of the containing cfg, either by throwing an error or returning a value.boolean
throwsError()
Whether or not this statement throws an error, halting the normal execution of the containing cfg.abstract java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.program.cfg.ProgramPoint
getProgram
-
-
-
-
Constructor Detail
-
Statement
protected Statement(CFG cfg, CodeLocation location)
Builds a statement happening at the given source location.- Parameters:
cfg
- the cfg that this statement belongs tolocation
- the location where this statement is defined within the program
-
-
Method Detail
-
getCFG
public final CFG getCFG()
Description copied from interface:ProgramPoint
Yields theCFG
that this program point belongs to.- Specified by:
getCFG
in interfaceProgramPoint
- Returns:
- the containing cfg
-
getOffset
public final int getOffset()
Description copied from interface:CodeNode
Yields the offset of this node relative to its containing graph.
-
stopsExecution
public boolean stopsExecution()
Whether or not this statement stops the execution of the containing cfg, either by throwing an error or returning a value. To distinguish error-raising halting statements and normal ones, usethrowsError()
.- Returns:
true
only if that condition holds
-
throwsError
public boolean throwsError()
Whether or not this statement throws an error, halting the normal execution of the containing cfg.- Returns:
true
only if that condition holds
-
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
-
semantics
public abstract <A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>> AnalysisState<A,H,V,T> semantics(AnalysisState<A,H,V,T> entryState, InterproceduralAnalysis<A,H,V,T> interprocedural, StatementStore<A,H,V,T> expressions) throws SemanticException
Computes the semantics of the statement, expressing how semantic information is transformed by the execution of this statement. This method is also responsible for recursively invoking thesemantics(AnalysisState, InterproceduralAnalysis, StatementStore)
of each nestedExpression
, saving the result of each call inexpressions
.- Type Parameters:
A
- the type ofAbstractState
H
- the type of theHeapDomain
V
- the type of theValueDomain
T
- the type ofTypeDomain
- Parameters:
entryState
- the entry state that represents the abstract values of each program variable and memory location when the execution reaches this statementinterprocedural
- the interprocedural analysis of the program to analyzeexpressions
- the cache where analysis states of intermediate expressions must be stored- Returns:
- the
AnalysisState
representing the abstract result of the execution of this statement - Throws:
SemanticException
- if something goes wrong during the computation
-
getLocation
public CodeLocation getLocation()
Description copied from interface:CodeElement
Yields the location where this code element appears in the program.- Specified by:
getLocation
in interfaceCodeElement
- Returns:
- the location where this code element appears in the program
-
compareTo
public int compareTo(Statement o)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Statement>
-
getEvaluationPredecessor
public final Statement getEvaluationPredecessor()
Yields theStatement
that is evaluated right before this one, such that querying for the entry state ofthis
expression is equivalent to querying the exit state of the returned one. If this method returnsnull
, then this is the first expression evaluated when an entire statement is evaluated.- Returns:
- the previous statement, or
null
-
getStatementEvaluatedBefore
public Statement getStatementEvaluatedBefore(Statement other)
Yields theStatement
that precedes the given one, assuming thatother
is contained into this expression. If this method returnsnull
, thenother
is the first expression evaluated when this statement is evaluated.- Parameters:
other
- the other statement- Returns:
- the previous statement, or
null
-
-