Class Substring

  • All Implemented Interfaces:
    ProgramPoint, CodeElement, Node<Statement,​Edge,​CFG>, java.lang.Comparable<Statement>

    public class Substring
    extends TernaryNativeCall
    An expression modeling the string substring operation. The type of the first operand must be StringType, while the other two operands' types must be Int32. The type of this expression is the StringType.

    Since in most languages string operations are provided through calls to library functions, this class contains a field originating whose purpose is to optionally store a Statement that is rewritten to an instance of this class (i.e., a call to a NativeCFG modeling the library function). If present, such statement will be used as ProgramPoint for semantics computations. This allows subclasses to implement PluggableStatement easily without redefining the semantics provided by this class.
    • 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 through NativeCFG 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 - the CFG where this operation lies
        location - the location where this literal is defined
        left - the left-hand side of this operation
        middle - the middle operand of this operation
        right - the right-hand side of this operation
    • Method Detail

      • ternarySemantics

        protected <A extends AbstractState<A,​H,​V>,​H extends HeapDomain<H>,​V extends ValueDomain<V>> AnalysisState<A,​H,​V> ternarySemantics​(AnalysisState<A,​H,​V> entryState,
                                                                                                                                                                              InterproceduralAnalysis<A,​H,​V> interprocedural,
                                                                                                                                                                              AnalysisState<A,​H,​V> leftState,
                                                                                                                                                                              SymbolicExpression leftExp,
                                                                                                                                                                              AnalysisState<A,​H,​V> middleState,
                                                                                                                                                                              SymbolicExpression middleExp,
                                                                                                                                                                              AnalysisState<A,​H,​V> rightState,
                                                                                                                                                                              SymbolicExpression rightExp)
                                                                                                                                                                       throws SemanticException
        Description copied from class: TernaryNativeCall
        Computes the semantics of the call, after the semantics of the parameters have been computed. Meta variables from the parameters will be forgotten after this call returns.
        Specified by:
        ternarySemantics in class TernaryNativeCall
        Type Parameters:
        A - the type of AbstractState
        H - the type of the HeapDomain
        V - the type of the ValueDomain
        Parameters:
        entryState - the entry state of this binary call
        interprocedural - the interprocedural analysis of the program to analyze
        leftState - the state obtained by evaluating left in entryState
        leftExp - the symbolic expression representing the computed value of the first parameter of this call
        middleState - the state obtained by evaluating middle in leftState
        middleExp - the symbolic expression representing the computed value of the second parameter of this call
        rightState - the state obtained by evaluating right in middleState
        rightExp - the symbolic expression representing the computed value of the third parameter of this call
        Returns:
        the AnalysisState representing the abstract result of the execution of this call
        Throws:
        SemanticException - if something goes wrong during the computation