Package daikon

Class PptRelation

  • All Implemented Interfaces:
    Serializable

    public class PptRelation
    extends Object
    implements Serializable
    Class that builds and describes relations in the ppt hierarchy. Building the relationship is specific to each type of parent/child relationship (eg, method to object, exit to combined exit, etc). The use of the relationship is general.

    The basic function of the class is to translate from a variable in the parent to the equivalent variable in the child and vice-versa. For example, in the ENTER → EXIT relationship, the parent is the ENTER ppt and the child is the EXIT ppt. Each variable in the ENTER ppt is connected to the corresponding orig variable in the EXIT ppt.

    See Also:
    Serialized Form
    • Method Detail

      • size

        @Pure
        public int size()
        Returns the number of parent to child variable relations.
      • relate_same_name

        public boolean relate_same_name()
        Relates all of the variables with the same name in parent and child. Returns true if each non-static parent variable was related to a child variable.
      • debug_print_tree

        public void debug_print_tree​(Logger l,
                                     int indent)
        Prints a ppt hierarchy of all of the ppts of this child and below.
      • is_primary

        @Pure
        public boolean is_primary()
        Returns whether or not this relation is a primary relation. This used to simplify debug prints of the PPt tree (so that extra relations don't result in duplicative information).

        Somewhat arbitrarily, Object→User and Enter→Exit are not considered primary while all others are. The remaining relations (class→object, object→method,and exit→exitNN) form a simple tree without duplication.

      • parentVar

        public @Nullable VarInfo parentVar​(VarInfo childVar)
        Returns the parent variable that corresponds to childVar. Returns null if there is no corresponding variable.
      • parentVarAnyInEquality

        public @Nullable VarInfo parentVarAnyInEquality​(VarInfo childVar)
        Like parentVar(VarInfo), but if no parent is found, tries every variable in the equality set and returns null only if none of them has a parent.
      • childVar

        public @Nullable VarInfo childVar​(VarInfo parentVar)
        Returns the child variable that corresponds to parentVar. Returns null if there is no corresponding variable.
      • hasChildren

        public boolean hasChildren()
        Returns whether or not this relation's child has children of its own.
      • get_child_equalities_as_parent

        public Map<VarInfo.Pair,​VarInfo.Pairget_child_equalities_as_parent()
        Returns a map of VarInfo.Pair with an entry for each pair of equal variables in all of the equality sets of the child. The variables are the corresponding parent variables and not the child variables themselves. The map is from the pair to itself, which allows the pair to be looked up (which is not possible with a set).
      • newParentRelation

        public static PptRelation newParentRelation​(FileIO.ParentRelation pr,
                                                    PptTopLevel parent,
                                                    PptTopLevel child)
        Creates a USER or PARENT relation from child to parent. The variable relationships are specified in the declaration record and stored in the VarInfo for each variable. RuntimeException will be thrown if any of the parent variables cannot be found.
      • newObjectUserRel

        public static PptRelation newObjectUserRel​(PptTopLevel parent,
                                                   PptTopLevel child,
                                                   VarInfo arg)
        Returns a relation in the ppt hierarchy from an object (parent) to a user (child) of that objects (eg, from the object B to the method A.foo (B arg)).
        Parameters:
        parent - ppt of the object definition
        child - ppt of a user of parent's object
        arg - variable of type object found in child
      • newCombinedExitExitNNRel

        public static PptRelation newCombinedExitExitNNRel​(PptTopLevel parent,
                                                           PptTopLevel child)
        Returns a relation in the ppt hierarchy from combined exit points (parent) to an individual exit point (child). Individual exit points are often referred to as exitNN where NN is the line number of the exit point).
      • newMergeChildRel

        public static PptRelation newMergeChildRel​(PptTopLevel parent,
                                                   PptTopLevel child)
        Returns a an artificial relation in the Program point hierarchy between the same ppt in two different PptMaps. Used to merge invariants between different data sets. The parent and the child should have exactly the same variables.
      • copy

        public PptRelation copy​(PptTopLevel new_parent,
                                PptTopLevel new_child)
        Copies the relation from its current ppts to the specified ppts. The new ppts must have the same variables in the same order as do the original ones.
      • init_hierarchy

        public static void init_hierarchy​(PptMap all_ppts)
        Initialize the hierarchical relationship between ppts. Specifically process each ppt, find its parent(s) in the partial order, and fill this point into the children field in the parent. Note that children contains only the immediate descendants of the ppt.

        This version should be used with the old version of declaration records. Use init_hierarchy_new() with new declaration records.

      • init_hierarchy_new

        public static void init_hierarchy_new​(PptMap all_ppts)
        Initialize the hierarchical relationship between ppts. Specifically process each ppt, find its parent(s) in the partial order, and fill this point into the children field in the parent. Note that children contains only the immediate descendants of the ppt.