Class NaryStatement
- java.lang.Object
-
- it.unive.lisa.program.cfg.statement.Statement
-
- it.unive.lisa.program.cfg.statement.NaryStatement
-
- All Implemented Interfaces:
ProgramPoint
,CodeElement
,CodeNode<CFG,Statement,Edge>
,Node<CFG,Statement,Edge>
,java.lang.Comparable<Statement>
- Direct Known Subclasses:
BinaryStatement
,TernaryStatement
,UnaryStatement
public abstract class NaryStatement extends Statement
A generic statement withn
sub-expressions.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
NaryStatement(CFG cfg, CodeLocation location, java.lang.String constructName, EvaluationOrder order, Expression... subExpressions)
Builds the statement, happening at the given location in the program.protected
NaryStatement(CFG cfg, CodeLocation location, java.lang.String constructName, Expression... subExpressions)
Builds the statement, happening at the given location in the program.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <V> boolean
accept(GraphVisitor<CFG,Statement,Edge,V> visitor, V tool)
Accepts the givenGraphVisitor
.<A extends AbstractState<A>>
AnalysisState<A>backwardSemantics(AnalysisState<A> exitState, InterproceduralAnalysis<A> interprocedural, StatementStore<A> expressions)
Semantics of an n-ary statements is evaluated by computing the semantics of its sub-expressions, in the specified order, using the analysis state from each sub-expression's computation as entry state for the next one.<A extends AbstractState<A>>
AnalysisState<A>backwardSemanticsAux(InterproceduralAnalysis<A> interprocedural, AnalysisState<A> state, ExpressionSet[] params, StatementStore<A> expressions)
Computes the backward semantics of the statement, after the semantics of all sub-expressions have been computed.boolean
equals(java.lang.Object obj)
<A extends AbstractState<A>>
AnalysisState<A>forwardSemantics(AnalysisState<A> entryState, InterproceduralAnalysis<A> interprocedural, StatementStore<A> expressions)
Semantics of an n-ary statements is evaluated by computing the semantics of its sub-expressions, in the specified order, using the analysis state from each sub-expression's computation as entry state for the next one.abstract <A extends AbstractState<A>>
AnalysisState<A>forwardSemanticsAux(InterproceduralAnalysis<A> interprocedural, AnalysisState<A> state, ExpressionSet[] params, StatementStore<A> expressions)
Computes the forward semantics of the statement, after the semantics of all sub-expressions have been computed.java.lang.String
getConstructName()
Yields the name of the native construct represented by this statement.EvaluationOrder
getOrder()
Yields theEvaluationOrder
of the sub-expressions.Statement
getStatementEvaluatedAfter(Statement other)
Yields theStatement
that follows the given one, assuming thatother
is contained into this statement.Statement
getStatementEvaluatedBefore(Statement other)
Yields theStatement
that precedes the given one, assuming thatother
is contained into this statement.Expression[]
getSubExpressions()
Yields the sub-expressions of this statement.int
hashCode()
int
setOffset(int offset)
Sets the offset of this node to the given value, and then proceeds by setting the one of its nested nodes (if any) to subsequent values.java.lang.String
toString()
-
Methods inherited from class it.unive.lisa.program.cfg.statement.Statement
compareTo, getCFG, getEvaluationPredecessor, getEvaluationSuccessor, getLocation, getOffset, stopsExecution, throwsError
-
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
-
NaryStatement
protected NaryStatement(CFG cfg, CodeLocation location, java.lang.String constructName, Expression... subExpressions)
Builds the statement, happening at the given location in the program. TheEvaluationOrder
isLeftToRightEvaluation
.- Parameters:
cfg
- the cfg that this expression belongs tolocation
- the location where the expression is defined within the programconstructName
- the name of the construct represented by this expressionsubExpressions
- the sub-expressions to be evaluated left-to-right
-
NaryStatement
protected NaryStatement(CFG cfg, CodeLocation location, java.lang.String constructName, EvaluationOrder order, Expression... subExpressions)
Builds the statement, happening at the given location in the program.- Parameters:
cfg
- the cfg that this expression belongs tolocation
- the location where the expression is defined within the programconstructName
- the name of the construct represented by this expressionorder
- the evaluation order of the sub-expressionssubExpressions
- the sub-expressions
-
-
Method Detail
-
getConstructName
public final java.lang.String getConstructName()
Yields the name of the native construct represented by this statement.- Returns:
- the name of the construct
-
getSubExpressions
public final Expression[] getSubExpressions()
Yields the sub-expressions of this statement.- Returns:
- the sub-expressions
-
getOrder
public EvaluationOrder getOrder()
Yields theEvaluationOrder
of the sub-expressions.- Returns:
- the evaluation order
-
setOffset
public int setOffset(int offset)
Description copied from interface:CodeNode
Sets the offset of this node to the given value, and then proceeds by setting the one of its nested nodes (if any) to subsequent values. The last offset used is returned.- Parameters:
offset
- the offset to set- Returns:
- the last offset used while setting the offsets of nested nodes
-
accept
public final <V> boolean accept(GraphVisitor<CFG,Statement,Edge,V> visitor, V tool)
Description copied from interface:Node
Accepts the givenGraphVisitor
. Implementors of this method are responsible for invokingGraphVisitor.visit(Object, Graph, Node)
on this node afterNode.accept(GraphVisitor, Object)
has been invoked on all nested nodes, if any. The visiting should stop at the first of such calls that returnfalse
.- Type Parameters:
V
- the type of auxiliary tool thatvisitor
can use- Parameters:
visitor
- the visitor that is visiting theGraph
containing this nodetool
- the auxiliary tool thatvisitor
can use- Returns:
- whether or not the visiting should stop when this call returns, as decided by the visitor itself
-
getStatementEvaluatedBefore
public Statement getStatementEvaluatedBefore(Statement other)
Description copied from class:Statement
Yields theStatement
that precedes the given one, assuming thatother
is contained into this statement. If this method returnsnull
, thenother
is the first expression evaluated when this statement is evaluated.- Overrides:
getStatementEvaluatedBefore
in classStatement
- Parameters:
other
- the other statement- Returns:
- the previous statement, or
null
-
getStatementEvaluatedAfter
public Statement getStatementEvaluatedAfter(Statement other)
Description copied from class:Statement
Yields theStatement
that follows the given one, assuming thatother
is contained into this statement. If this method returnsnull
, thenother
is the last expression evaluated when this statement is evaluated.- Overrides:
getStatementEvaluatedAfter
in classStatement
- Parameters:
other
- the other statement- Returns:
- the next statement, or
null
-
forwardSemantics
public <A extends AbstractState<A>> AnalysisState<A> forwardSemantics(AnalysisState<A> entryState, InterproceduralAnalysis<A> interprocedural, StatementStore<A> expressions) throws SemanticException
Semantics of an n-ary statements is evaluated by computing the semantics of its sub-expressions, in the specified order, using the analysis state from each sub-expression's computation as entry state for the next one. Then, the semantics of the statement itself is evaluated.
Computes the forward semantics of the statement, expressing how semantic information is transformed by the execution of this statement. This method is also responsible for recursively invoking theStatement.forwardSemantics(AnalysisState, InterproceduralAnalysis, StatementStore)
of each nestedExpression
, saving the result of each call inexpressions
.- Specified by:
forwardSemantics
in classStatement
- Type Parameters:
A
- the type ofAbstractState
- 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
-
forwardSemanticsAux
public abstract <A extends AbstractState<A>> AnalysisState<A> forwardSemanticsAux(InterproceduralAnalysis<A> interprocedural, AnalysisState<A> state, ExpressionSet[] params, StatementStore<A> expressions) throws SemanticException
Computes the forward semantics of the statement, after the semantics of all sub-expressions have been computed. Meta variables from the sub-expressions will be forgotten after this call returns.- Type Parameters:
A
- the type ofAbstractState
- Parameters:
interprocedural
- the interprocedural analysis of the program to analyzestate
- the state where the statement is to be evaluatedparams
- the symbolic expressions representing the computed values of the sub-expressions of this statementexpressions
- the cache where analysis states of intermediate expressions are stored and that can be accessed to query for post-states of parameters expressions- Returns:
- the
AnalysisState
representing the abstract result of the execution of this statement - Throws:
SemanticException
- if something goes wrong during the computation
-
backwardSemantics
public <A extends AbstractState<A>> AnalysisState<A> backwardSemantics(AnalysisState<A> exitState, InterproceduralAnalysis<A> interprocedural, StatementStore<A> expressions) throws SemanticException
Semantics of an n-ary statements is evaluated by computing the semantics of its sub-expressions, in the specified order, using the analysis state from each sub-expression's computation as entry state for the next one. Then, the semantics of the statement itself is evaluated.
Computes the backward semantics of the statement, expressing how semantic information is transformed by the execution of this statement. This method is also responsible for recursively invoking theStatement.forwardSemantics(AnalysisState, InterproceduralAnalysis, StatementStore)
of each nestedExpression
, saving the result of each call inexpressions
. By default, this method delegates toStatement.forwardSemantics(AnalysisState, InterproceduralAnalysis, StatementStore)
, as it is fine for most atomic statements. One should redefine this method if a statement's semantics is composed of a series of smaller operations.- Overrides:
backwardSemantics
in classStatement
- Type Parameters:
A
- the type ofAbstractState
- Parameters:
exitState
- the exit 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
-
backwardSemanticsAux
public <A extends AbstractState<A>> AnalysisState<A> backwardSemanticsAux(InterproceduralAnalysis<A> interprocedural, AnalysisState<A> state, ExpressionSet[] params, StatementStore<A> expressions) throws SemanticException
Computes the backward semantics of the statement, after the semantics of all sub-expressions have been computed. Meta variables from the sub-expressions will be forgotten after this call returns. By default, this method delegates toforwardSemanticsAux(InterproceduralAnalysis, AnalysisState, ExpressionSet[], StatementStore)
, as it is fine for most atomic statements. One should redefine this method if a statement's semantics is composed of a series of smaller operations.- Type Parameters:
A
- the type ofAbstractState
- Parameters:
interprocedural
- the interprocedural analysis of the program to analyzestate
- the state where the statement is to be evaluatedparams
- the symbolic expressions representing the computed values of the sub-expressions of this statementexpressions
- the cache where analysis states of intermediate expressions are stored and that can be accessed to query for post-states of parameters expressions- Returns:
- the
AnalysisState
representing the abstract result of the execution of this statement - Throws:
SemanticException
- if something goes wrong during the computation
-
-