Package daikon
Class PptRelation
- Object
-
- 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PptRelation.PptRelationType
The different ppt/variable hierarchy relationships.
-
Field Summary
Fields Modifier and Type Field Description PptTopLevel
child
Child of relation.Map<VarInfo,VarInfo>
child_to_parent_map
Map from child vars to matching parent vars.static boolean
dkconfig_enable_object_user
Boolean.PptTopLevel
parent
Parent of relation.Map<VarInfo,VarInfo>
parent_to_child_map
Map from parent vars to matching child vars.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description @Nullable VarInfo
childVar(VarInfo parentVar)
Returns the child variable that corresponds to parentVar.PptRelation
copy(PptTopLevel new_parent, PptTopLevel new_child)
Copies the relation from its current ppts to the specified ppts.void
debug_print_tree(Logger l, int indent)
Prints a ppt hierarchy of all of the ppts of this child and below.Map<VarInfo.Pair,VarInfo.Pair>
get_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.PptRelation.PptRelationType
getRelationType()
Returns a string describing the parent-child relationship.boolean
hasChildren()
Returns whether or not this relation's child has children of its own.static void
init_hierarchy(PptMap all_ppts)
Initialize the hierarchical relationship between ppts.static void
init_hierarchy_new(PptMap all_ppts)
Initialize the hierarchical relationship between ppts.boolean
is_primary()
Returns whether or not this relation is a primary relation.static PptRelation
newClassObjectRel(PptTopLevel parent, PptTopLevel child)
Returns a relation in the ppt hierarchy from a class (parent) to an object (child) containing static members of that class.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).static PptRelation
newEnterExitRel(PptTopLevel parent, PptTopLevel child)
Returns a relation in the ppt hierarchy from enter points to exit points over orig variables.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.static PptRelation
newObjectMethodRel(PptTopLevel parent, PptTopLevel child)
Returns a relation in the ppt hierarchy from an object (parent) to a method (child) on that object.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)).static PptRelation
newParentRelation(FileIO.ParentRelation pr, PptTopLevel parent, PptTopLevel child)
Creates a USER or PARENT relation from child to parent.static PptRelation
newPptPptConditional(PptTopLevel parent, PptTopLevel child)
Returns a relation in the ppt hierarchy from a ppt to a PptConditional for that point.String
parent_to_child_var_string()
Return a string containing all of the parent→child var relations.@Nullable VarInfo
parentVar(VarInfo childVar)
Returns the parent variable that corresponds to childVar.@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.boolean
relate_same_name()
Relates all of the variables with the same name in parent and child.int
size()
Returns the number of parent to child variable relations.String
toString()
-
-
-
Field Detail
-
parent
public PptTopLevel parent
Parent of relation.
-
child
public PptTopLevel child
Child of relation.
-
parent_to_child_map
public Map<VarInfo,VarInfo> parent_to_child_map
Map from parent vars to matching child vars.
-
child_to_parent_map
public Map<VarInfo,VarInfo> child_to_parent_map
Map from child vars to matching parent vars.
-
dkconfig_enable_object_user
public static boolean dkconfig_enable_object_user
Boolean. Controls whether the object-user relation is created in the variable hierarchy.
-
-
Method Detail
-
size
@Pure public int size()
Returns the number of parent to child variable relations.
-
parent_to_child_var_string
public String parent_to_child_var_string()
Return a string containing all of the parent→child var 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.
-
getRelationType
public PptRelation.PptRelationType getRelationType()
Returns a string describing the parent-child relationship.
-
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.Pair> get_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).
-
newObjectMethodRel
public static PptRelation newObjectMethodRel(PptTopLevel parent, PptTopLevel child)
Returns a relation in the ppt hierarchy from an object (parent) to a method (child) on that object.
-
newClassObjectRel
public static PptRelation newClassObjectRel(PptTopLevel parent, PptTopLevel child)
Returns a relation in the ppt hierarchy from a class (parent) to an object (child) containing static members of that class.
-
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 definitionchild
- ppt of a user of parent's objectarg
- variable of type object found in child
-
newEnterExitRel
public static PptRelation newEnterExitRel(PptTopLevel parent, PptTopLevel child)
Returns a relation in the ppt hierarchy from enter points to exit points over orig variables.
-
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).
-
newPptPptConditional
public static PptRelation newPptPptConditional(PptTopLevel parent, PptTopLevel child)
Returns a relation in the ppt hierarchy from a ppt to a PptConditional for that 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.
-
-