com.veromodo.tempo.sem.type
Class TypeSum

java.lang.Object
  extended by com.veromodo.tempo.sem.type.Type
      extended by com.veromodo.tempo.sem.type.TypeSum
All Implemented Interfaces:
java.lang.Comparable<Type>

public class TypeSum
extends Type

This is used to represent sum or union of two types.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.veromodo.tempo.sem.type.Type
Type.Order, Type.TypeKind
 
Field Summary
 
Fields inherited from class com.veromodo.tempo.sem.type.Type
_name, DEFAULT_NAME
 
Constructor Summary
TypeSum(java.lang.String name)
           
 
Method Summary
 void add(Type t, java.lang.String tag)
           
 Type.Order compare(Type t)
          Determines how Type t is realted to this.
 TypeSum downCastSum()
           
 int getArity()
           
 java.util.Vector<Type> getFields()
           
 int hashCode()
           
 boolean is(Type.TypeKind kind)
          Determines if the currently instance is of given TypeKind.
 void makeConstructors(Environment env)
          Manufactures the constructors for the values of the sum type.
 TypeEnum makeTags(Environment env)
          Manufactures a enumerated types for the values of the tags in a sum type.
 Type resolve()
          Replaces any bound type parameters with thier bound types.
 Type select(java.lang.String with)
          Create a function type -> FT which correspond to the application of the dereference operator 'with'.
 java.lang.String toString()
           
 void visit(TypeVisitor v)
           
 
Methods inherited from class com.veromodo.tempo.sem.type.Type
accept, acceptable, compareTo, constructedWith, downCastArray, downCastAugmentedReal, downCastAutomaton, downCastBasicAutomaton, downCastBool, downCastChar, downCastCompositeAutomaton, downCastConstructor, downCastDiscreteReal, downCastEnum, downCastEnumValue, downCastFloat, downCastFunction, downCastFunctional, downCastFunctionalGeneric, downCastGeneric, downCastInstance, downCastInt, downCastInt32, downCastList, downCastMap, downCastMeta, downCastNat, downCastNumeric, downCastParameter, downCastReal, downCastTuple, downCastVoid, equals, equals, getName, isArray, isAugmentedReal, isAutomaton, isBasicAutomaton, isBool, isChar, isCompositeAutomaton, isConstructor, isDiscreteReal, isEnum, isEnumValue, isEqualTo, isError, isFloat, isFun, isFunctional, isFunctionalGeneric, isGeneric, isId, isIndexed, isInstance, isInt, isInt32, isList, isMap, isMeta, isNat, isNumeric, isParameter, isReal, isSum, isTuple, isVariable, isVoid, lub
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TypeSum

public TypeSum(java.lang.String name)
Method Detail

is

public boolean is(Type.TypeKind kind)
Description copied from class: Type
Determines if the currently instance is of given TypeKind.

Overrides:
is in class Type
Parameters:
kind - the type of class to compare to
Returns:
true if this is of given TypeKind

add

public void add(Type t,
                java.lang.String tag)

select

public Type select(java.lang.String with)
Create a function type -> FT which correspond to the application of the dereference operator 'with'. 'with' must be a field of the tuple and the dereference operator is seen as a curried function from the tuple type to the field type. returns If no field named 'with' exist, no function type is returned (i.e., return null)

Overrides:
select in class Type
Parameters:
with - the parameter to select
Returns:
a TypeFunction this ? TypeOf(with)

getArity

public int getArity()

getFields

public java.util.Vector<Type> getFields()

toString

public java.lang.String toString()
Overrides:
toString in class Type

downCastSum

public TypeSum downCastSum()
Overrides:
downCastSum in class Type

resolve

public Type resolve()
Description copied from class: Type
Replaces any bound type parameters with thier bound types. If all parameters are bound, the resulting type is not generic. If no parameters are bounf, the resulting type is this.

Overrides:
resolve in class Type
Returns:
a resolved type

compare

public Type.Order compare(Type t)
Description copied from class: Type
Determines how Type t is realted to this.

Specified by:
compare in class Type
Parameters:
t - to compare to this
Returns:

visit

public void visit(TypeVisitor v)
Specified by:
visit in class Type

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

makeTags

public TypeEnum makeTags(Environment env)
Manufactures a enumerated types for the values of the tags in a sum type. For example, the type myTy union [x:Nat, y:Bool, z:Int] yields, myTy_tag enumeration [x,y,z] succ : myTy_tag -> myTy

Parameters:
env -
Returns:

makeConstructors

public void makeConstructors(Environment env)
Manufactures the constructors for the values of the sum type. For example, the type myTy union [x:Nat, y:Bool, z:Int] yields, x : Nat -> myTy y : Bool -> myTy z : Int -> myTy

Parameters:
env -