uk.ac.man.cs.rainbow.datamodel
Class Data.Union

java.lang.Object
  |
  +--uk.ac.man.cs.rainbow.rapa.data.Expression
        |
        +--uk.ac.man.cs.rainbow.datamodel.Data
              |
              +--uk.ac.man.cs.rainbow.datamodel.Data.Union
All Implemented Interfaces:
Argument, Serializable, Value, VariableContainer
Enclosing class:
Data

public static class Data.Union
extends Data
implements Serializable

Union datatypes.

See Also:
Data, Type, Type.Union, Serialized Form

Inner Class Summary
static interface Data.Union.T
          What special operations must the type of a union implement?
 
Inner classes inherited from class uk.ac.man.cs.rainbow.datamodel.Data
Data.Comparable, Data.List, Data.Union, Data.Untyped, Data.Word
 
Field Summary
protected  Expression contents
           
protected  int index
           
 
Constructor Summary
Data.Union(Type t, Expression d, Data.Word idx)
           
Data.Union(Type t, Expression d, int idx)
           
Data.Union(Type t, Expression d, String idx)
           
 
Method Summary
 Value apply(Unifier u)
          Apply a unifier to this value to get a new value.
 Data cast(Type t)
          Return a new data value that has the given type.
 boolean equals(Data d)
          Standardised equality defined over data values with equal types.
 Expression getContents()
           
 Data.Word getIndex()
           
 int hashCode()
          Hash-code generator.
 boolean hasVariable()
           
 boolean occurs(Substitution s, Variable v)
          Check whether the variable occurs in this value under the given substitution.
protected  void setType(Type t)
           
 Value subst(Substitution s)
          Apply a substitution to this value to get a new value.
 String toString()
          Print the data value.
 Substitution unify(Substitution s, Value ex)
          Get the substitution which unifies this value with the given value, after applying the given substitution.
 
Methods inherited from class uk.ac.man.cs.rainbow.datamodel.Data
equals, equals, getResultType, getType, main, parse, parse, typedString
 
Methods inherited from class uk.ac.man.cs.rainbow.rapa.data.Expression
compatableWith, evaluate, getNodeType, subst
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

contents

protected Expression contents

index

protected int index
Constructor Detail

Data.Union

public Data.Union(Type t,
                  Expression d,
                  int idx)
           throws TypeException

Data.Union

public Data.Union(Type t,
                  Expression d,
                  String idx)
           throws TypeException

Data.Union

public Data.Union(Type t,
                  Expression d,
                  Data.Word idx)
           throws TypeException
Method Detail

cast

public Data cast(Type t)
          throws TypeException
Description copied from class: Data
Return a new data value that has the given type.
Overrides:
cast in class Data
Following copied from class: uk.ac.man.cs.rainbow.datamodel.Data
Throws:
TypeException - Thrown if the data value being cast from (or some part of it) disgrees with the type (or type component) that is being specified for it.

toString

public String toString()
Description copied from class: Data
Print the data value.
Overrides:
toString in class Data

getContents

public Expression getContents()

getIndex

public Data.Word getIndex()

setType

protected void setType(Type t)
                throws TypeException

equals

public boolean equals(Data d)
Description copied from class: Data
Standardised equality defined over data values with equal types. Implemented by concrete subclasses.
Overrides:
equals in class Data

hashCode

public int hashCode()
Description copied from class: Data
Hash-code generator. Implemented so that data values that print the same way have the same hashCode (and ought to satisfy equals() too...)
Overrides:
hashCode in class Data

apply

public Value apply(Unifier u)
Description copied from interface: Value
Apply a unifier to this value to get a new value.
Overrides:
apply in class Data

subst

public Value subst(Substitution s)
Description copied from interface: Value
Apply a substitution to this value to get a new value.
Overrides:
subst in class Data

hasVariable

public boolean hasVariable()
Overrides:
hasVariable in class Data

occurs

public boolean occurs(Substitution s,
                      Variable v)
Description copied from interface: Value
Check whether the variable occurs in this value under the given substitution.
Overrides:
occurs in class Data

unify

public Substitution unify(Substitution s,
                          Value ex)
                   throws NotUnifiable
Description copied from interface: Value
Get the substitution which unifies this value with the given value, after applying the given substitution.
Overrides:
unify in class Data
Following copied from interface: uk.ac.man.cs.rainbow.rapa.data.Value
Parameters:
subst - The substitution to apply first.
val - The value to unify with this value.
Returns:
The substitution that is the combination of the given substitution and whatever extra substitutions are necessary to unify the two values.
Throws:
NotUnifiable - If the two values cannot be unified.