edu.cmu.cs.crystal.flow
Class LabeledResult<LE>

java.lang.Object
  extended by edu.cmu.cs.crystal.flow.LabeledResult<LE>
Type Parameters:
LE - The type which represents the lattice value
All Implemented Interfaces:
IResult<LE>

public class LabeledResult<LE>
extends Object
implements IResult<LE>

Maps each label to a unique value. This class also contains a default value, so if a label is requested which it does not know about, it returns the default. Of all the IResults, this class provides the most expressiveness.

Since:
Crystal 3.4.0
Author:
ciera

Method Summary
static
<LE> LabeledResult<LE>
createResult(LE defaultValue)
          Create a result with the given default value but no labels.
static
<LE> LabeledResult<LE>
createResult(List<ILabel> labels, LE defaultValue)
          Create a result for the given labels with the given default value.
 LE get(ILabel label)
          Clients should not modify the returned value.
 IResult<LE> join(IResult<LE> otherResult, IAbstractLatticeOperations<LE,?> op)
          Clients do not usually call this method.
 Set<ILabel> keySet()
          Returns the set of labels mapped by this IResult.
 void put(ILabel label, LE value)
          Add/Change the value of a label
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createResult

public static <LE> LabeledResult<LE> createResult(List<ILabel> labels,
                                                  LE defaultValue)
Create a result for the given labels with the given default value.

Type Parameters:
LE -
Parameters:
labels - The labels to create mappings for
defaultValue - a default value for each label to map to
Returns:
A new result for the given labels with the given default value.

createResult

public static <LE> LabeledResult<LE> createResult(LE defaultValue)
Create a result with the given default value but no labels. Labels can be added later by calling @link{#put}.

Type Parameters:
LE -
Parameters:
defaultValue - a default value for each label to map to
Returns:
A new result with the given default value.

put

public void put(ILabel label,
                LE value)
Add/Change the value of a label

Parameters:
label - the label to add to this result
value - the lattice information to map it to

get

public LE get(ILabel label)
Description copied from interface: IResult
Clients should not modify the returned value. Implementers must provide a default value if label is null.

Specified by:
get in interface IResult<LE>
Returns:
the value which was mapped to this label, or the default value if the label is unknown

keySet

public Set<ILabel> keySet()
Description copied from interface: IResult
Returns the set of labels mapped by this IResult.

Specified by:
keySet in interface IResult<LE>
Returns:
a set of all known labels for this result.

join

public IResult<LE> join(IResult<LE> otherResult,
                        IAbstractLatticeOperations<LE,?> op)
Description copied from interface: IResult
Clients do not usually call this method. Implementations join two results "pointwise" by joining lattice elements with the same label. This method must not modify either IResult objects passed in.

Specified by:
join in interface IResult<LE>
Parameters:
otherResult - IResult object to join this IResult with.
op - Lattice operations so we can join individual elements.
Returns:
Pointwise joined lattice elements.
See Also:
ILatticeOperations.join(LE, LE, org.eclipse.jdt.core.dom.ASTNode)