edu.cmu.cs.crystal.simple
Class SimpleLatticeOperations<LE>

java.lang.Object
  extended by edu.cmu.cs.crystal.simple.SimpleLatticeOperations<LE>
All Implemented Interfaces:
IAbstractLatticeOperations<LE,ASTNode>, ILatticeOperations<LE>
Direct Known Subclasses:
BooleanConstantLatticeOps, LiveVariableLatticeOps

public abstract class SimpleLatticeOperations<LE>
extends Object
implements ILatticeOperations<LE>

This is the interface for the operations you must provide on your lattice in order for the dataflow analysis to work. To make your own lattice operations, simply derive off of this class and templatize it by the type of lattice you are going to use. So, to make operations for a null pointer lattice, we could declare a class like this: public class NPELatticeOps extends SimpleLatticeOperations<NullPointerLattice>

Since:
Crystal 3.4.0
Author:
ciera, Kevin Bierhoff

Constructor Summary
SimpleLatticeOperations()
           
 
Method Summary
abstract  boolean atLeastAsPrecise(LE left, LE right)
          Checks to see if the left side of the operand is more precise (or as precise) as the right side.
 boolean atLeastAsPrecise(LE info, LE reference, ASTNode node)
          More complex version of atLeastAsPrecise.
abstract  LE bottom()
          Responsible for returning a lattice that represents no knowledge.
abstract  LE copy(LE original)
          Creates a new deep copy of the given analysis information.
abstract  LE join(LE left, LE right)
          Joins the two lattice elements into an element that is as precise as possible while still being less precise than both.
 LE join(LE someInfo, LE otherInfo, ASTNode node)
          More complex version of join.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleLatticeOperations

public SimpleLatticeOperations()
Method Detail

atLeastAsPrecise

public abstract boolean atLeastAsPrecise(LE left,
                                         LE right)
Checks to see if the left side of the operand is more precise (or as precise) as the right side. Notice that in a lattice, the bottom lattice element will be more precise than everything, and top element will be less precise than everything. That is, atLeastAsPrecise(bottom, x) == true and atLeastAsPrecise(x, top) == true.

Parameters:
left -
right -
Returns:
True if left is more precise (or the same as) right, false if right is more precise or the two have no precision relationship.

join

public abstract LE join(LE left,
                        LE right)
Joins the two lattice elements into an element that is as precise as possible while still being less precise than both. This is a symmetric relationship. This method is called by the framework to join different flows together. For example: The lattice that follows an If statement must represent the knowledge from the true and the false paths. The join is what combines the analysis of each path together. You may modify "this" and return it, or simply create a new LE and return it. Notice that:

Parameters:
left -
right - DO NOT MODIFY
Returns:
A lattice element which is the join of the parameters.

bottom

public abstract LE bottom()
Description copied from interface: IAbstractLatticeOperations
Responsible for returning a lattice that represents no knowledge.

Specified by:
bottom in interface IAbstractLatticeOperations<LE,ASTNode>
Specified by:
bottom in interface ILatticeOperations<LE>
Returns:
The lattice element which is the bottom of the lattice.

copy

public abstract LE copy(LE original)
Creates a new deep copy of the given analysis information. "Deep copy" means that all mutable (changeable) objects referenced by the original must not be referenced by the copy. Notice that if your lattice is immutable (an enum, for example), then you can just return this

Specified by:
copy in interface IAbstractLatticeOperations<LE,ASTNode>
Specified by:
copy in interface ILatticeOperations<LE>
Parameters:
original - analysis information to be copied.
Returns:
a copy of the argument that contains no references to mutable objects found in the original.

atLeastAsPrecise

public boolean atLeastAsPrecise(LE info,
                                LE reference,
                                ASTNode node)
More complex version of atLeastAsPrecise. If you find you want to use this, you should implement ILatticeOperations instead.

Specified by:
atLeastAsPrecise in interface IAbstractLatticeOperations<LE,ASTNode>
Specified by:
atLeastAsPrecise in interface ILatticeOperations<LE>
Parameters:
info - Analysis information to be compared against reference
reference - the other LE to compare info with.
node - ASTNode where the two paths were originally forked apart (e.g., if, while, try, switch, etc.) or null if this comparison occurs on a "dummy" node.
Returns:
true if the first argument is at least as precise as the second; false otherwise, including if the two arguments are incomparable.
See Also:
ILatticeOperations.atLeastAsPrecise(Object, Object, ASTNode)

join

public LE join(LE someInfo,
               LE otherInfo,
               ASTNode node)
More complex version of join. If you find you want to use this, you should implement ILatticeOperations instead.

Specified by:
join in interface IAbstractLatticeOperations<LE,ASTNode>
Specified by:
join in interface ILatticeOperations<LE>
Parameters:
someInfo - LE to join with otherInfo.
otherInfo - The other LE to join with, do not modify.
node - ASTNode where the two paths were originally forked apart (e.g., if, while, try, switch, etc.) or null if this join occurs on a "dummy" node.
Returns:
the resulting LE that has the combined knowledge
See Also:
ILatticeOperations.join(Object, Object, ASTNode)