daikon
Class ValueTuple

Object
  extended by ValueTuple
All Implemented Interfaces:
Cloneable

public final class ValueTuple
extends Object
implements Cloneable

This data structure holds a tuple of values for a particular program point. VarInfo objects can use this to get the values of the variables they represent.

It has two fields: vals and mods. While the arrays and their elements are interned, the ValueTuple objects themselves are not interned.


Field Summary
static Logger debug
          Debug tracer.
static int MISSING_FLOW
          Missing value because of data flow: this.x.x isn't available from a ppt.
static int MISSING_FLOW_BITVAL
           
static int MISSING_NONSENSICAL
          Missing value because the expression doesn't make sense: x.a when x is null.
static int MISSING_NONSENSICAL_BITVAL
           
static int MODBIT_VALUES
          Maximum mod bit value.
static int MODIFIED
          Modified.
static int MODIFIED_BITVAL
           
 int[] mods
          Modification bit per value, possibly packed into fewer ints than the vals field.
static int STATIC_CONSTANT
           
static int[] tuplemod_modified_not_missing
           
static int[] tuplemod_not_missing
           
static int TUPLEMOD_VALUES
           
static int UNMODIFIED
          Not modified.
static int UNMODIFIED_BITVAL
           
 Object[] vals
           
 
Constructor Summary
ValueTuple(Object[] vals, int[] mods)
          Default constructor that interns its argument.
 
Method Summary
 void checkRep()
           
 ValueTuple clone()
          Creates and returns a copy of this.
 boolean equals(Object obj)
           
 int getModified(VarInfo vi)
           
 Object getValue(VarInfo vi)
          Get the value of the variable vi in this ValueTuple.
 Object getValueOrNull(VarInfo vi)
          Get the value of the variable vi in this ValueTuple, or null if it is missing.
 int hashCode()
           
 boolean isMissing(VarInfo vi)
           
 boolean isMissingFlow(VarInfo vi)
           
 boolean isMissingNonsensical(VarInfo vi)
           
 boolean isModified(VarInfo vi)
           
 boolean isUnmodified(VarInfo vi)
           
static ValueTuple makeUninterned(Object[] vals, int[] mods)
          More convenient name for the constructor that doesn't intern.
static int parseModified(String raw)
           
 ValueTuple shallowcopy()
           
 int size()
           
 ValueTuple slice(int[] indices)
          Return a new ValueTuple consisting of the elements of this one with indices listed in indices.
 String toString()
           
 String toString(VarInfo[] vis)
          Return the values of this tuple.
 ValueTuple trim(int len)
          Return a new ValueTuple containing this one's first len elements.
static String valsToString(Object[] vals)
           
static String valToString(Object val)
           
 
Methods inherited from class Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

debug

public static Logger debug
Debug tracer.


vals

public Object[] vals

mods

public int[] mods
Modification bit per value, possibly packed into fewer ints than the vals field. Don't use a single int because that won't scale to (say) more than 32 values.


UNMODIFIED

public static final int UNMODIFIED
Not modified.

See Also:
Constant Field Values

MODIFIED

public static final int MODIFIED
Modified.

See Also:
Constant Field Values

MISSING_NONSENSICAL

public static final int MISSING_NONSENSICAL
Missing value because the expression doesn't make sense: x.a when x is null. Data trace files can contain this modbit.

See Also:
Constant Field Values

MISSING_FLOW

public static final int MISSING_FLOW
Missing value because of data flow: this.x.x isn't available from a ppt. Data trace files must not contain this modbit.

See Also:
Constant Field Values

MODBIT_VALUES

public static final int MODBIT_VALUES
Maximum mod bit value. Always set to 1+ last modbit value.

See Also:
Constant Field Values

STATIC_CONSTANT

public static final int STATIC_CONSTANT
See Also:
Constant Field Values

TUPLEMOD_VALUES

public static final int TUPLEMOD_VALUES

UNMODIFIED_BITVAL

public static final int UNMODIFIED_BITVAL

MODIFIED_BITVAL

public static final int MODIFIED_BITVAL

MISSING_NONSENSICAL_BITVAL

public static final int MISSING_NONSENSICAL_BITVAL

MISSING_FLOW_BITVAL

public static final int MISSING_FLOW_BITVAL

tuplemod_not_missing

public static final int[] tuplemod_not_missing

tuplemod_modified_not_missing

public static final int[] tuplemod_modified_not_missing
Constructor Detail

ValueTuple

public ValueTuple(Object[] vals,
                  int[] mods)
Default constructor that interns its argument.

Method Detail

getModified

public int getModified(VarInfo vi)

isUnmodified

public boolean isUnmodified(VarInfo vi)

isModified

public boolean isModified(VarInfo vi)

isMissingNonsensical

public boolean isMissingNonsensical(VarInfo vi)

isMissingFlow

public boolean isMissingFlow(VarInfo vi)

isMissing

public boolean isMissing(VarInfo vi)

parseModified

public static int parseModified(String raw)

getValue

public Object getValue(VarInfo vi)
Get the value of the variable vi in this ValueTuple.

Parameters:
vi - the variable whose value is to be returned
Returns:
the value of the variable at this ValueTuple

getValueOrNull

public Object getValueOrNull(VarInfo vi)
Get the value of the variable vi in this ValueTuple, or null if it is missing. Use of this method is discouraged.

Parameters:
vi - the variable whose value is to be returned
Returns:
the value of the variable at this ValueTuple
See Also:
getValue(VarInfo)

checkRep

public void checkRep()

clone

public ValueTuple clone()
                 throws CloneNotSupportedException
Creates and returns a copy of this.

Overrides:
clone in class Object
Throws:
CloneNotSupportedException

makeUninterned

public static ValueTuple makeUninterned(Object[] vals,
                                        int[] mods)
More convenient name for the constructor that doesn't intern. That is, the result is an uninterned ValueTuple. This is not private because it is used (only) by read_data_trace_file, which makes a partial ValueTuple, fills it in with derived variables, and only then interns it; the alternative would be for derived variables to take separate vals and mods arguments. No one else should use it!


shallowcopy

public ValueTuple shallowcopy()

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

size

public int size()

trim

public ValueTuple trim(int len)
Return a new ValueTuple containing this one's first len elements.


toString

public String toString()
Overrides:
toString in class Object

toString

public String toString(VarInfo[] vis)
Return the values of this tuple. If vis is non-null, the values are annotated with the VarInfo name that would be associated with the value.


valsToString

public static String valsToString(Object[] vals)

valToString

public static String valToString(Object val)

slice

public ValueTuple slice(int[] indices)
Return a new ValueTuple consisting of the elements of this one with indices listed in indices.