com.veromodo.tempo.sem.type
Class Type

java.lang.Object
  extended by com.veromodo.tempo.sem.type.Type
All Implemented Interfaces:
java.lang.Comparable<Type>
Direct Known Subclasses:
TypeAugmentedReal, TypeBool, TypeChar, TypeConstructor, TypeDiscreteReal, TypeEnum, TypeEnumValue, TypeError, TypeFloat, TypeFunctional, TypeGeneric, TypeId, TypeInstance, TypeInt, TypeInt32, TypeList, TypeMeta, TypeNat, TypeNumeric, TypeParameter, TypeReal, TypeSum, TypeTuple, TypeVariable, TypeVoid

public abstract class Type
extends java.lang.Object
implements java.lang.Comparable<Type>

The abstract class for the root of the type system hierarchy.

Author:
L. Michel

Nested Class Summary
static class Type.Order
          Defines how two types can be realted.
static class Type.TypeKind
          Defines a set of all the type classes.
 
Field Summary
 java.lang.String _name
          Defines the name of a specific instance of a type ie in Status tuple [bo: Bool, item: T], the name is "Status"
static java.lang.String DEFAULT_NAME
           
 
Constructor Summary
Type()
           
Type(Type t2)
           
 
Method Summary
 boolean accept(Type t)
          Determines if Type t is a subtype of this.
 SetOfType acceptable(Environment env)
           
abstract  Type.Order compare(Type t)
          Determines how Type t is realted to this.
 int compareTo(Type o)
           
 boolean constructedWith(Type[] at)
           
 TypeArray downCastArray()
           
 TypeAugmentedReal downCastAugmentedReal()
           
 TypeAutomaton downCastAutomaton()
           
 TypeBasicAutomaton downCastBasicAutomaton()
           
 TypeBool downCastBool()
           
 TypeChar downCastChar()
           
 TypeCompositeAutomaton downCastCompositeAutomaton()
           
 TypeConstructor downCastConstructor()
           
 TypeDiscreteReal downCastDiscreteReal()
           
 TypeEnum downCastEnum()
           
 TypeEnumValue downCastEnumValue()
           
 TypeFloat downCastFloat()
           
 TypeFunction downCastFunction()
           
 TypeFunctional downCastFunctional()
           
 TypeFunctionalGeneric downCastFunctionalGeneric()
           
 TypeGeneric downCastGeneric()
           
 TypeInstance downCastInstance()
           
 TypeInt downCastInt()
           
 TypeInt32 downCastInt32()
           
 TypeList downCastList()
           
 TypeMap downCastMap()
           
 TypeMeta downCastMeta()
           
 TypeNat downCastNat()
           
 TypeNumeric downCastNumeric()
           
 TypeParameter downCastParameter()
           
 TypeReal downCastReal()
           
 TypeSum downCastSum()
           
 TypeTuple downCastTuple()
           
 TypeVoid downCastVoid()
           
 boolean equals(java.lang.Object o)
           
 boolean equals(Type t)
           
 java.lang.String getName()
           
 boolean is(Type.TypeKind kind)
          Determines if the currently instance is of given TypeKind.
 boolean isArray()
           
 boolean isAugmentedReal()
           
 boolean isAutomaton()
           
 boolean isBasicAutomaton()
           
 boolean isBool()
           
 boolean isChar()
           
 boolean isCompositeAutomaton()
           
 boolean isConstructor()
           
 boolean isDiscreteReal()
           
 boolean isEnum()
           
 boolean isEnumValue()
           
 boolean isEqualTo(Type t)
           
 boolean isError()
           
 boolean isFloat()
           
 boolean isFun()
           
 boolean isFunctional()
           
 boolean isFunctionalGeneric()
           
 boolean isGeneric()
           
 boolean isId()
           
 boolean isIndexed()
           
 boolean isInstance()
           
 boolean isInt()
           
 boolean isInt32()
           
 boolean isList()
           
 boolean isMap()
           
 boolean isMeta()
           
 boolean isNat()
           
 boolean isNumeric()
           
 boolean isParameter()
           
 boolean isReal()
           
 boolean isSum()
           
 boolean isTuple()
           
 boolean isVariable()
           
 boolean isVoid()
           
static Type lub(Type t1, Type t2)
          calculates the least upper bound of two types.
 Type resolve()
          Replaces any bound type parameters with thier bound types.
 Type select(java.lang.String with)
          Returns the type of the given parameter with wrapped in a TypeFunction this ? FT, where FT is the type of the parameter being dereferenced.
 java.lang.String toString()
           
abstract  void visit(TypeVisitor v)
           
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_NAME

public static java.lang.String DEFAULT_NAME

_name

public java.lang.String _name
Defines the name of a specific instance of a type ie in Status tuple [bo: Bool, item: T], the name is "Status"

Constructor Detail

Type

public Type()

Type

public Type(Type t2)
Method Detail

is

public boolean is(Type.TypeKind kind)
Determines if the currently instance is of given TypeKind.

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

isNumeric

public boolean isNumeric()

isAugmentedReal

public boolean isAugmentedReal()

isReal

public boolean isReal()

isDiscreteReal

public boolean isDiscreteReal()

isFloat

public boolean isFloat()

isInt

public boolean isInt()

isInt32

public boolean isInt32()

isNat

public boolean isNat()

isBool

public boolean isBool()

isIndexed

public boolean isIndexed()

isArray

public boolean isArray()

isMap

public boolean isMap()

isSum

public boolean isSum()

isFun

public boolean isFun()

isGeneric

public boolean isGeneric()

isParameter

public boolean isParameter()

isTuple

public boolean isTuple()

isError

public boolean isError()

isId

public boolean isId()

isVoid

public boolean isVoid()

isConstructor

public boolean isConstructor()

isFunctional

public boolean isFunctional()

isChar

public boolean isChar()

isEnum

public boolean isEnum()

isEnumValue

public boolean isEnumValue()

isVariable

public boolean isVariable()

isAutomaton

public boolean isAutomaton()

isBasicAutomaton

public boolean isBasicAutomaton()

isCompositeAutomaton

public boolean isCompositeAutomaton()

isInstance

public boolean isInstance()

isFunctionalGeneric

public boolean isFunctionalGeneric()

isList

public boolean isList()

isMeta

public boolean isMeta()

downCastChar

public TypeChar downCastChar()

downCastFunction

public TypeFunction downCastFunction()

downCastAugmentedReal

public TypeAugmentedReal downCastAugmentedReal()

downCastReal

public TypeReal downCastReal()

downCastBool

public TypeBool downCastBool()

downCastNumeric

public TypeNumeric downCastNumeric()

downCastFloat

public TypeFloat downCastFloat()

downCastDiscreteReal

public TypeDiscreteReal downCastDiscreteReal()

downCastInt

public TypeInt downCastInt()

downCastInt32

public TypeInt32 downCastInt32()

downCastNat

public TypeNat downCastNat()

downCastMap

public TypeMap downCastMap()

downCastArray

public TypeArray downCastArray()

downCastConstructor

public TypeConstructor downCastConstructor()

downCastGeneric

public TypeGeneric downCastGeneric()

downCastParameter

public TypeParameter downCastParameter()

downCastSum

public TypeSum downCastSum()

downCastTuple

public TypeTuple downCastTuple()

downCastVoid

public TypeVoid downCastVoid()

downCastFunctional

public TypeFunctional downCastFunctional()

downCastEnum

public TypeEnum downCastEnum()

downCastEnumValue

public TypeEnumValue downCastEnumValue()

downCastAutomaton

public TypeAutomaton downCastAutomaton()

downCastBasicAutomaton

public TypeBasicAutomaton downCastBasicAutomaton()

downCastCompositeAutomaton

public TypeCompositeAutomaton downCastCompositeAutomaton()

downCastInstance

public TypeInstance downCastInstance()

downCastFunctionalGeneric

public TypeFunctionalGeneric downCastFunctionalGeneric()

downCastList

public TypeList downCastList()

downCastMeta

public TypeMeta downCastMeta()

resolve

public Type resolve()
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.

Returns:
a resolved type

getName

public java.lang.String getName()

toString

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

compare

public abstract Type.Order compare(Type t)
Determines how Type t is realted to this.

Parameters:
t - to compare to this
Returns:

acceptable

public SetOfType acceptable(Environment env)

accept

public boolean accept(Type t)
Determines if Type t is a subtype of this. a.k.a. can t be assigned into this

Parameters:
t - to compare to this
Returns:
true if t is a subtype of this

constructedWith

public boolean constructedWith(Type[] at)

isEqualTo

public boolean isEqualTo(Type t)

compareTo

public int compareTo(Type o)
Specified by:
compareTo in interface java.lang.Comparable<Type>

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

equals

public boolean equals(Type t)

visit

public abstract void visit(TypeVisitor v)

lub

public static Type lub(Type t1,
                       Type t2)
calculates the least upper bound of two types.

Parameters:
t1 - first type
t2 - second type
Returns:
the least upper bound between given types

select

public Type select(java.lang.String with)
Returns the type of the given parameter with wrapped in a TypeFunction this ? FT, where FT is the type of the parameter being dereferenced. If the parameter is not found, null it returned.

select returns a function instead of simply returning the type FT because it can more seamlessly integrate with the type checker.

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