Class Length

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

    public class Length
    extends UnaryExpression
    An expression modeling the string length operation. The type of the operand must be StringType. The type of this expression is the Int32.

    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

      • Length

        public Length​(CFG cfg,
                      CodeLocation location,
                      Expression parameter)
        Builds the length.
        Parameters:
        cfg - the CFG where this operation lies
        location - the code location where this operation is defined
        parameter - the operand of this operation
    • Method Detail

      • unarySemantics

        protected <A extends AbstractState<A,​H,​V,​T>,​H extends HeapDomain<H>,​V extends ValueDomain<V>,​T extends TypeDomain<T>> AnalysisState<A,​H,​V,​T> unarySemantics​(InterproceduralAnalysis<A,​H,​V,​T> interprocedural,
                                                                                                                                                                                                                          AnalysisState<A,​H,​V,​T> state,
                                                                                                                                                                                                                          SymbolicExpression expr,
                                                                                                                                                                                                                          StatementStore<A,​H,​V,​T> expressions)
                                                                                                                                                                                                                   throws SemanticException
        Description copied from class: UnaryExpression
        Computes the semantics of the expression, after the semantics of the sub-expression has been computed. Meta variables from the sub-expression will be forgotten after this expression returns.
        Specified by:
        unarySemantics in class UnaryExpression
        Type Parameters:
        A - the type of AbstractState
        H - the type of the HeapDomain
        V - the type of the ValueDomain
        T - the type of TypeDomain
        Parameters:
        interprocedural - the interprocedural analysis of the program to analyze
        state - the state where the expression is to be evaluated
        expr - the symbolic expressions representing the computed value of the sub-expression of this expression
        expressions - 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