Class Substring
- java.lang.Object
-
- it.unive.lisa.program.cfg.statement.Statement
-
- it.unive.lisa.program.cfg.statement.Expression
-
- it.unive.lisa.program.cfg.statement.NaryExpression
-
- it.unive.lisa.program.cfg.statement.TernaryExpression
-
- it.unive.lisa.program.cfg.statement.string.Substring
-
- All Implemented Interfaces:
ProgramPoint
,CodeElement
,CodeNode<CFG,Statement,Edge>
,Node<CFG,Statement,Edge>
,java.lang.Comparable<Statement>
public class Substring extends TernaryExpression
An expression modeling the string substring operation. The type of the first operand must beStringType
, while the other two operands' types must beNumericType
. The type of this expression is theStringType
.
Since in most languages string operations are provided through calls to library functions, this class contains a fieldoriginating
whose purpose is to optionally store aStatement
that is rewritten to an instance of this class (i.e., a call to aNativeCFG
modeling the library function). If present, such statement will be used asProgramPoint
for semantics computations. This allows subclasses to implementPluggableStatement
easily without redefining the semantics provided by this class.
-
-
Field Summary
Fields Modifier and Type Field Description protected Statement
originating
Statement that has been rewritten to this operation, if any.
-
Constructor Summary
Constructors Constructor Description Substring(CFG cfg, CodeLocation location, Expression left, Expression middle, Expression right)
Builds the substring.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>>
AnalysisState<A,H,V,T>ternarySemantics(InterproceduralAnalysis<A,H,V,T> interprocedural, AnalysisState<A,H,V,T> state, SymbolicExpression left, SymbolicExpression middle, SymbolicExpression right, StatementStore<A,H,V,T> expressions)
Computes the semantics of the expression, after the semantics of the sub-expressions have been computed.-
Methods inherited from class it.unive.lisa.program.cfg.statement.TernaryExpression
expressionSemantics, getLeft, getMiddle, getRight
-
Methods inherited from class it.unive.lisa.program.cfg.statement.NaryExpression
accept, equals, getConstructName, getOrder, getStatementEvaluatedBefore, getSubExpressions, hashCode, semantics, setOffset, toString
-
Methods inherited from class it.unive.lisa.program.cfg.statement.Expression
getMetaVariables, getParentStatement, getRootStatement, getStaticType, setParentStatement
-
Methods inherited from class it.unive.lisa.program.cfg.statement.Statement
compareTo, getCFG, getEvaluationPredecessor, 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
-
-
-
-
Field Detail
-
originating
protected Statement originating
Statement that has been rewritten to this operation, if any. This is to accomodate the fact that, in most languages, string operations are performed through calls, and one might want to provide the semantics of those calls throughNativeCFG
that rewrites to instances of this class.
-
-
Constructor Detail
-
Substring
public Substring(CFG cfg, CodeLocation location, Expression left, Expression middle, Expression right)
Builds the substring.- Parameters:
cfg
- theCFG
where this operation lieslocation
- the location where this literal is definedleft
- the left-hand side of this operationmiddle
- the middle operand of this operationright
- the right-hand side of this operation
-
-
Method Detail
-
ternarySemantics
public <A extends AbstractState<A,H,V,T>,H extends HeapDomain<H>,V extends ValueDomain<V>,T extends TypeDomain<T>> AnalysisState<A,H,V,T> ternarySemantics(InterproceduralAnalysis<A,H,V,T> interprocedural, AnalysisState<A,H,V,T> state, SymbolicExpression left, SymbolicExpression middle, SymbolicExpression right, StatementStore<A,H,V,T> expressions) throws SemanticException
Description copied from class:TernaryExpression
Computes the semantics of the expression, after the semantics of the sub-expressions have been computed. Meta variables from the sub-expressions will be forgotten after this expression returns.- Specified by:
ternarySemantics
in classTernaryExpression
- Type Parameters:
A
- the type ofAbstractState
H
- the type of theHeapDomain
V
- the type of theValueDomain
T
- the type ofTypeDomain
- Parameters:
interprocedural
- the interprocedural analysis of the program to analyzestate
- the state where the expression is to be evaluatedleft
- the symbolic expression representing the computed value of the first sub-expression of this expressionmiddle
- the symbolic expression representing the computed value of the second sub-expression of this expressionright
- the symbolic expression representing the computed value of the third sub-expression of this expressionexpressions
- 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 expression - Throws:
SemanticException
- if something goes wrong during the computation
-
-