Package daikon.split

Class Splitter

  • All Implemented Interfaces:
    Serializable
    Direct Known Subclasses:
    CallerContextSplitter, ReturnTrueSplitter, SplitterExample

    @UsesObjectEquals
    public abstract class Splitter
    extends Object
    implements Serializable
    A Splitter represents a test that can be used to separate all samples into two parts. For instance, a Splitter might represent the condition "x > 0". The Splitter is used to divide a collection of variable values into sub-sets. Invariant detection can then occur for the two subsets independently.

    This class Splitter is the superclass for all the classes we dynamically compile; there will be one subclass for each condition that's checked. Other information about the splitting condition is kept in a SplitterObject object, which keeps reference to the corresponding Splitter. One instance of each Splitter subclass is then created for each program point at which the splitting condition is applicable.

    See Also:
    Serialized Form
    • Field Detail

      • instantiated

        protected boolean instantiated
        True for an instantiated (non-"factory") splitter.
    • Constructor Detail

      • Splitter

        protected Splitter()
        Creates a splitter "factory" that should only be used for creating new copies via instantiateSplitter(Ppt). (That is, the result of "new Splitter()" should not do any splitting itself.) There is no need for subclasses to override this (but most will have to, since they will add their own constructors as well).
    • Method Detail

      • instantiateSplitter

        public abstract Splitter instantiateSplitter​(@UnknownInitialization(Ppt.class) Ppt ppt)
        Creates a valid splitter than can be used for testing the condition via test(ValueTuple). The implementation should always set the "instantiated" protected field to true, if that field is present in the Splitter class.
      • instantiated

        public boolean instantiated()
        Returns true for an instantiated (non-"factory") splitter. Clients also need to check valid().
      • valid

        public abstract boolean valid()
        Returns true or false according to whether this was instantiated correctly and test(ValueTuple) can be called without error. An alternate design would have instantiateSplitter(Ppt) check this, but it's a bit easier on implementers of subclasses of Splitter for the work to be done (in just one place) by the caller.
      • test

        public abstract boolean test​(ValueTuple vt)
        Returns true or false according to whether the values in the specified ValueTuple satisfy the condition represented by this Splitter. Requires that valid() returns true.
      • condition

        public abstract String condition()
        Returns the condition being tested, as a String.
      • makeDummyInvariantFactory

        public void makeDummyInvariantFactory​(DummyInvariant inv)
        Set up the static ('factory') DummyInvariant for this kind of splitter. This only modifies static data, but it can't be static because subclasses must override it.
      • instantiateDummy

        public void instantiateDummy​(PptTopLevel ppt)
        Make an instance DummyInvariant for this instance of the splitter, if possible on an appropriate slice from ppt.
      • getDummyInvariant

        public abstract @Nullable DummyInvariant getDummyInvariant()
        On an instantiated Splitter, give back an appropriate instantiated DummyInvariant.