orc.ast.simple.type
Class Type

java.lang.Object
  extended by orc.ast.simple.type.Type
Direct Known Subclasses:
ArrowType, Bot, ClassnameType, Datatype, FreeTypeVariable, PolymorphicTypeAlias, SiteType, Top, TupleType, TypeApplication, TypeVariable

public abstract class Type
extends java.lang.Object

Abstract superclass of syntactic types in the simple AST. Within the simple AST, bound type variables are represented by objects (TypeVariable), rather than strings (NamedType). Free type variables may still occur (FreeTypeVariable), but they must be eliminated before conversion to the next AST stage. Syntactic types occur in all of the AST forms. The typechecker converts them to a different form (subclasses of orc.type.Type) for its own internal use. Syntactic types do not have methods like meet, join, and subtype; only their typechecker counterparts do. Thus, syntactic types permit only the simplest analyses; more complex analyses must wait until the syntactic type is converted within the typechecker. All syntactic types can be written explicitly in a program, whereas many of the typechecker's internal types are not representable in programs.

Author:
dkitchin

Field Summary
static Type BOT
           
static Type TOP
           
 
Constructor Summary
Type()
           
 
Method Summary
abstract  Type convert(Env<TypeVariable> env)
          Convert this syntactic type into an actual type, given an appropriate type context
static java.util.List<Type> convertAll(java.util.List<Type> ts, Env<TypeVariable> env)
          Convenience method, to apply convert to a list of types.
 Type subMap(java.util.Map<FreeTypeVariable,Type> m)
          Perform a set of substitutions defined by a map.
abstract  Type subst(Type T, FreeTypeVariable X)
          Performs the substitution [T/X], replacing occurrences of the free type variable X with the type T (which could be any type, including another variable).
static java.util.List<Type> substAll(java.util.List<Type> ts, Type T, FreeTypeVariable X)
          Convenience method, to apply a substitution to a list of types.
static Type substMaybe(Type target, Type T, FreeTypeVariable X)
           
 Type subvar(TypeVariable U, FreeTypeVariable X)
          Performs the substitution [U/X], replacing occurrences of the free type variable X with the nameless type variable U.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TOP

public static final Type TOP

BOT

public static final Type BOT
Constructor Detail

Type

public Type()
Method Detail

convert

public abstract Type convert(Env<TypeVariable> env)
                      throws TypeException
Convert this syntactic type into an actual type, given an appropriate type context

Parameters:
env - The type environment, used in content addressable mode to find the appropriate deBruijn index of a type variable.
Returns:
A new node.
Throws:
TypeException

convertAll

public static java.util.List<Type> convertAll(java.util.List<Type> ts,
                                              Env<TypeVariable> env)
                                       throws TypeException
Convenience method, to apply convert to a list of types.

Parameters:
ts - A list of types
env - Environment for conversion
Returns:
The list of types, converted
Throws:
TypeException

subst

public abstract Type subst(Type T,
                           FreeTypeVariable X)
Performs the substitution [T/X], replacing occurrences of the free type variable X with the type T (which could be any type, including another variable).

Parameters:
T - The replacing type
X - The free type variable whose occurrences will be replaced
Returns:
A new copy of the type with the substitution performed

substAll

public static java.util.List<Type> substAll(java.util.List<Type> ts,
                                            Type T,
                                            FreeTypeVariable X)
Convenience method, to apply a substitution to a list of types.


substMaybe

public static Type substMaybe(Type target,
                              Type T,
                              FreeTypeVariable X)

subvar

public Type subvar(TypeVariable U,
                   FreeTypeVariable X)
Performs the substitution [U/X], replacing occurrences of the free type variable X with the nameless type variable U. Additionally, attach the name of X as documentation on U so that it can be used later for debugging or other purposes. This method delegates to the subst method after attaching the name.

Parameters:
U - The replacing type variable
X - The free type variable whose occurrences will be replaced
Returns:
A new copy of the type with the substitution performed

subMap

public Type subMap(java.util.Map<FreeTypeVariable,Type> m)
Perform a set of substitutions defined by a map. For each X |-> T in the map, the substitution [T/X] occurs. If T is a nameless variable U, the name of the corresponding X will be attached to it.

Parameters:
m -