orc.type
Class Type

java.lang.Object
  extended by orc.type.Type
Direct Known Subclasses:
ArrowType, BooleanType, Bot, DotType, EllipsisArrowType, LetType, Message, MultiType, NumberType, StringType, Top, TupleType, Tycon, TypeApplication, TypeInstance, TypeVariable

public abstract class Type
extends java.lang.Object

Abstract superclass of all types for the Orc typechecker. This typechecker is based on the local type inference algorithms described by Benjamin Pierce and David Turner in their paper entitled "Local Type Inference". It extends that inference strategy with tuples, library-defined type constructors, user-defined datatypes, variance annotations, and other small changes.

Author:
dkitchin

Field Summary
static Type BLANK
          Placeholder for an unspecified type.
static Type BOOLEAN
           
static Type BOT
           
static Type INTEGER
           
static Type LET
           
static Type NUMBER
           
static Type STRING
           
static Type TOP
           
 
Constructor Summary
Type()
           
 
Method Summary
 void addConstraints(Env<java.lang.Boolean> VX, Type T, Constraint[] C)
           
 void assertSubtype(Type that)
           
 Tycon asTycon()
           
 Type call(Env<Type> ctx, Env<Type> typectx, java.util.List<Arg> args, java.util.List<Type> typeActuals)
           
 Type call(java.util.List<Type> args)
           
 boolean closed()
           
 Type demote(Env<java.lang.Boolean> V)
           
 boolean equal(Type that)
           
 Variance findVariance(java.lang.Integer var)
           
 java.util.Set<java.lang.Integer> freeVars()
           
 boolean isBot()
           
 boolean isTop()
           
 Type join(Type that)
           
 Type meet(Type that)
           
 Type promote(Env<java.lang.Boolean> V)
           
 Type subst(Env<Type> ctx)
           
static java.util.List<Type> substAll(java.util.List<Type> ts, Env<Type> ctx)
           
 boolean subtype(Type that)
           
 boolean supertype(Type that)
           
 java.lang.String toString()
           
 Type unwrapAs(Type T)
           
 java.util.List<Variance> variances()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TOP

public static final Type TOP

BOT

public static final Type BOT

NUMBER

public static final Type NUMBER

STRING

public static final Type STRING

BOOLEAN

public static final Type BOOLEAN

INTEGER

public static final Type INTEGER

LET

public static final Type LET

BLANK

public static final Type BLANK
Placeholder for an unspecified type. FIXME: should use a null type.

Constructor Detail

Type

public Type()
Method Detail

isTop

public boolean isTop()

isBot

public boolean isBot()

subtype

public boolean subtype(Type that)
                throws TypeException
Throws:
TypeException

assertSubtype

public void assertSubtype(Type that)
                   throws TypeException
Throws:
TypeException

supertype

public boolean supertype(Type that)
                  throws TypeException
Throws:
TypeException

equal

public boolean equal(Type that)
              throws TypeException
Throws:
TypeException

join

public Type join(Type that)
          throws TypeException
Throws:
TypeException

meet

public Type meet(Type that)
          throws TypeException
Throws:
TypeException

call

public Type call(Env<Type> ctx,
                 Env<Type> typectx,
                 java.util.List<Arg> args,
                 java.util.List<Type> typeActuals)
          throws TypeException
Throws:
TypeException

call

public Type call(java.util.List<Type> args)
          throws TypeException
Throws:
TypeException

toString

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

subst

public Type subst(Env<Type> ctx)
           throws TypeException
Throws:
TypeException

substAll

public static java.util.List<Type> substAll(java.util.List<Type> ts,
                                            Env<Type> ctx)
                                     throws TypeException
Throws:
TypeException

variances

public java.util.List<Variance> variances()
                                   throws TypeException
Throws:
TypeException

unwrapAs

public Type unwrapAs(Type T)
              throws TypeException
Throws:
TypeException

asTycon

public Tycon asTycon()
              throws TypeException
Throws:
TypeException

freeVars

public java.util.Set<java.lang.Integer> freeVars()

closed

public boolean closed()

findVariance

public Variance findVariance(java.lang.Integer var)
                      throws TypeException
Throws:
TypeException

promote

public Type promote(Env<java.lang.Boolean> V)
             throws TypeException
Throws:
TypeException

demote

public Type demote(Env<java.lang.Boolean> V)
            throws TypeException
Throws:
TypeException

addConstraints

public void addConstraints(Env<java.lang.Boolean> VX,
                           Type T,
                           Constraint[] C)
                    throws TypeException
Throws:
TypeException