edu.cmu.cs.crystal.bridge
Class LatticeElementOps<LE extends LatticeElement<LE>>

java.lang.Object
  extended by edu.cmu.cs.crystal.bridge.LatticeElementOps<LE>
All Implemented Interfaces:
IAbstractLatticeOperations<LE,ASTNode>, ILatticeOperations<LE>

public class LatticeElementOps<LE extends LatticeElement<LE>>
extends Object
implements ILatticeOperations<LE>

This class is not to be used in new Crystal analyses and is kept for older projects only. This class provides generic lattice operations for LatticeElement implementations. This facilitates using classes implementing LatticeElement in Crystal flow analyses.

Since:
Crystal 3.4.0
Author:
Kevin Bierhoff

Constructor Summary
LatticeElementOps(LE bottom)
          Use create(LatticeElement) for more compact syntax.
 
Method Summary
 boolean atLeastAsPrecise(LE info, LE reference, ASTNode node)
          Compares analysis information for precision; more precisely, determines whether the first argument is at least as precise as the second.
 LE bottom()
          Responsible for returning a lattice that represents no knowledge.
 LE copy(LE original)
          Creates a new deep copy of the given analysis information.
static
<LE extends LatticeElement<LE>>
LatticeElementOps<LE>
create(LE bottom)
          Create lattice operations for a given bottom element.
 LE join(LE someInfo, LE otherInfo, ASTNode node)
          Carries out a join on this lattice and another lattice.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LatticeElementOps

public LatticeElementOps(LE bottom)
Use create(LatticeElement) for more compact syntax. Create lattice operations for a given bottom element.

Parameters:
bottom - Bottom element to be returned by bottom().
Method Detail

create

public static <LE extends LatticeElement<LE>> LatticeElementOps<LE> create(LE bottom)
Create lattice operations for a given bottom element. Using this method requires less explicit type annotations that using the constructor directly.

Type Parameters:
LE - Analysis knowledge implementation class.
Parameters:
bottom - Bottom element to be returned by bottom().
Returns:
lattice operations for the given bottom element.

atLeastAsPrecise

public boolean atLeastAsPrecise(LE info,
                                LE reference,
                                ASTNode node)
Description copied from interface: IAbstractLatticeOperations
Compares analysis information for precision; more precisely, determines whether the first argument is at least as precise as the second. This method is used by the framework to compare analysis information.

Specified by:
atLeastAsPrecise in interface IAbstractLatticeOperations<LE extends LatticeElement<LE>,ASTNode>
Specified by:
atLeastAsPrecise in interface ILatticeOperations<LE extends LatticeElement<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.

bottom

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

Specified by:
bottom in interface IAbstractLatticeOperations<LE extends LatticeElement<LE>,ASTNode>
Specified by:
bottom in interface ILatticeOperations<LE extends LatticeElement<LE>>
Returns:
the lattice that represents "bottom"

copy

public LE copy(LE original)
Description copied from interface: IAbstractLatticeOperations
Creates a new deep copy of the given analysis information. "Deep copy" means that all mutable (changeable) objects referenced by the given LE must not be referenced by the returned LE.

Specified by:
copy in interface IAbstractLatticeOperations<LE extends LatticeElement<LE>,ASTNode>
Specified by:
copy in interface ILatticeOperations<LE extends LatticeElement<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.

join

public LE join(LE someInfo,
               LE otherInfo,
               ASTNode node)
Description copied from interface: IAbstractLatticeOperations
Carries out a join on this lattice and another lattice. 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.

Specified by:
join in interface IAbstractLatticeOperations<LE extends LatticeElement<LE>,ASTNode>
Specified by:
join in interface ILatticeOperations<LE extends LatticeElement<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