Class NaryStatement

    • 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. The EvaluationOrder is LeftToRightEvaluation.
        Parameters:
        cfg - the cfg that this expression belongs to
        location - the location where the expression is defined within the program
        constructName - the name of the construct represented by this expression
        subExpressions - 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 to
        location - the location where the expression is defined within the program
        constructName - the name of the construct represented by this expression
        order - the evaluation order of the sub-expressions
        subExpressions - 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
      • accept

        public final <V> boolean accept​(GraphVisitor<CFG,​Statement,​Edge,​V> visitor,
                                        V tool)
        Description copied from interface: Node
        Accepts the given GraphVisitor. Implementors of this method are responsible for invoking GraphVisitor.visit(Object, Graph, Node) on this node after Node.accept(GraphVisitor, Object) has been invoked on all nested nodes, if any. The visiting should stop at the first of such calls that return false.
        Type Parameters:
        V - the type of auxiliary tool that visitor can use
        Parameters:
        visitor - the visitor that is visiting the Graph containing this node
        tool - the auxiliary tool that visitor can use
        Returns:
        whether or not the visiting should stop when this call returns, as decided by the visitor itself
      • toString

        public java.lang.String toString()
        Specified by:
        toString in class Statement
      • getStatementEvaluatedBefore

        public Statement getStatementEvaluatedBefore​(Statement other)
        Description copied from class: Statement
        Yields the Statement that precedes the given one, assuming that other is contained into this statement. If this method returns null, then other is the first expression evaluated when this statement is evaluated.
        Overrides:
        getStatementEvaluatedBefore in class Statement
        Parameters:
        other - the other statement
        Returns:
        the previous statement, or null
      • getStatementEvaluatedAfter

        public Statement getStatementEvaluatedAfter​(Statement other)
        Description copied from class: Statement
        Yields the Statement that follows the given one, assuming that other is contained into this statement. If this method returns null, then other is the last expression evaluated when this statement is evaluated.
        Overrides:
        getStatementEvaluatedAfter in class Statement
        Parameters:
        other - the other statement
        Returns:
        the next statement, or null
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class Statement
      • compareSameClass

        protected int compareSameClass​(Statement o)
        Description copied from class: Statement
        Auxiliary method for Statement.compareTo(Statement) that can safely assume that the two statements happen at the same CodeLocation and are instances of the same class.
        Specified by:
        compareSameClass in class Statement
        Parameters:
        o - the other statement
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
      • compareSameClassAndParams

        protected abstract int compareSameClassAndParams​(Statement o)
        Auxiliary method for Statement.compareTo(Statement) that can safely assume that the two statements happen at the same CodeLocation, are instances of the same class, and have the same parameters according to their implementation of Statement.compareTo(Statement).
        Parameters:
        o - the other statement
        Returns:
        a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object
      • 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 the Statement.forwardSemantics(AnalysisState, InterproceduralAnalysis, StatementStore) of each nested Expression, saving the result of each call in expressions.
        Specified by:
        forwardSemantics in class Statement
        Type Parameters:
        A - the type of AbstractState
        Parameters:
        entryState - the entry state that represents the abstract values of each program variable and memory location when the execution reaches this statement
        interprocedural - the interprocedural analysis of the program to analyze
        expressions - 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 of AbstractState
        Parameters:
        interprocedural - the interprocedural analysis of the program to analyze
        state - the state where the statement is to be evaluated
        params - the symbolic expressions representing the computed values of the sub-expressions of this statement
        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 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 the Statement.forwardSemantics(AnalysisState, InterproceduralAnalysis, StatementStore) of each nested Expression, saving the result of each call in expressions. By default, this method delegates to Statement.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 class Statement
        Type Parameters:
        A - the type of AbstractState
        Parameters:
        exitState - the exit state that represents the abstract values of each program variable and memory location when the execution reaches this statement
        interprocedural - the interprocedural analysis of the program to analyze
        expressions - 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 to forwardSemanticsAux(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 of AbstractState
        Parameters:
        interprocedural - the interprocedural analysis of the program to analyze
        state - the state where the statement is to be evaluated
        params - the symbolic expressions representing the computed values of the sub-expressions of this statement
        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 statement
        Throws:
        SemanticException - if something goes wrong during the computation