Class Statement


  • public final class Statement
    extends Object
    Statement represents a Java statement, such as a method call Foo f = m(i1...iN) or a declaration int x = 0. The statement's data includes an operation and the list of inputs for the operation. The inputs to the operation are variables, but are represented by indexing into the enclosing sequence.
    • Constructor Detail

      • Statement

        public Statement​(TypedOperation operation,
                         List<Sequence.RelativeNegativeIndex> inputVariables)
        Create a new statement of type statement that takes as input the given values.
        Parameters:
        operation - the operation of this statement
        inputVariables - the variable that are used in this statement
      • Statement

        public Statement​(TypedOperation operation)
        Creates a statement based on the given operation.
        Parameters:
        operation - the operation for action of this statement
    • Method Detail

      • equals

        public boolean equals​(Object obj)
        equals tests whether two Statement objects are equal:
        Overrides:
        equals in class Object
        Returns:
        true if operation is the same, the number of inputs is the same, and inputs are equal
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • getOutputType

        public Type getOutputType()
      • getInputTypes

        public TypeTuple getInputTypes()
      • isStatic

        public boolean isStatic()
        isStatic indicates whether the corresponding operation is declared as static.
        Returns:
        result of isStatic on operation corresponding to statement
      • isMethodCall

        public boolean isMethodCall()
        isMethodCall indicates whether a statement corresponds to a method-call-like operation. This could be either a method call, an assignment/initialization involving a method call, or the use of a public field in an assignment on either lhs (as "setter") or rhs (as "getter").
        Returns:
        true if operation is method-call-like, and false otherwise
      • execute

        public ExecutionOutcome execute​(Object[] inputs)
        execute performs the operation of the statement for the input variables and returns outcome.
        Parameters:
        inputs - list of objects to use as inputs to execution
        Returns:
        object representing outcome of computation
      • getDeclaringClass

        public Type getDeclaringClass()
        getDeclaringClass returns the declaring class as defined by the Operation of the statement.
        Returns:
        result of getDeclaringClass for corresponding statement
      • isConstructorCall

        public boolean isConstructorCall()
        isConstructorCall determines if operation for statement is a call to a constructor.
        Returns:
        true if operation is a constructor call, and false otherwise
      • isNonreceivingInitialization

        public boolean isNonreceivingInitialization()
        isNonreceivingInitialization determines if operation is a nonreceiver term.
        Returns:
        true if operation is a nonreceiver, and false otherwise
      • isNullInitialization

        public boolean isNullInitialization()
        isNullInitialization determines if statement represents an initialization by null value.
        Returns:
        true if statement represents null initialization, and false otherwise
      • getInlinedForm

        public String getInlinedForm()
        Returns a printed representation of the value as a literal, rather than as a variable reference.
        Returns:
        string containing code for a literal value
      • getValue

        public Object getValue()
        getValue returns the "value" for a statement. Is only meaningful if statement is an assignment of a constant value. Appeals to CallableOperation to throw appropriate exception when unable to provide a value.

        This is a hack to allow randoop.main.GenBranchDir to do mutation.

        Returns:
        value of term in statement (rhs of assignment/initialization) if any
      • getOperation

        public final TypedOperation getOperation()
        getTypedOperation is meant to be a temporary solution to type confusion in generators. This should go away. Only intended to be called by Sequence.extend(TypedOperation, List).
        Returns:
        operation object in the statement