Semant
Class Type

java.lang.Object
  extended by Semant.Type
Direct Known Subclasses:
Type.ARRAY, Type.CLASS, Type.FUN, Type.INSTANCE, Type.RECORD

public abstract class Type
extends java.lang.Object

Type descriptors for MiniJava.


Nested Class Summary
static class Type.ARRAY
          An array has an element type.
static class Type.CLASS
          A class encapsulates static (class) fields and methods, may extend a parent class, and describes the structure of its instances.
static class Type.FUN
          A function has formal parameters (represented as a record) and a result type.
static class Type.INSTANCE
          A class instance is an instance of some class, encapsulating instance fields and instance methods.
static class Type.Print
          A visitor to print types.
static class Type.RECORD<T extends Type>
          A record encapsulates state as fields
static interface Type.Visitor
          The Type Visitor.
 
Field Summary
static Semant.Type.Primitive BOOLEAN
          Predefined primitive types
static Semant.Type.Primitive INT
           
static Semant.Type.Primitive NIL
           
static Type.CLASS STRING
          Predefined final classes String and System.
static Type.CLASS SYSTEM
           
static Semant.Type.Primitive VOID
           
 
Constructor Summary
Type()
           
 
Method Summary
abstract  void accept(Type.Visitor v)
          A type must accept a visitor
abstract  boolean coerceTo(Type t)
          A type's values may be coerced to those of another type.
abstract  boolean equals(Type t)
          Type equality
 Type field(java.lang.String n)
          A type may encapsulate state as fields.
 Type.FUN method(java.lang.String n)
          A type may encapsulate behavior as methods.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BOOLEAN

public static final Semant.Type.Primitive BOOLEAN
Predefined primitive types


INT

public static final Semant.Type.Primitive INT

NIL

public static final Semant.Type.Primitive NIL

VOID

public static final Semant.Type.Primitive VOID

STRING

public static final Type.CLASS STRING
Predefined final classes String and System.


SYSTEM

public static final Type.CLASS SYSTEM
Constructor Detail

Type

public Type()
Method Detail

field

public Type field(java.lang.String n)
A type may encapsulate state as fields.

Parameters:
n - name of the field
Returns:
type of the field

method

public Type.FUN method(java.lang.String n)
A type may encapsulate behavior as methods.

Parameters:
n - name of the method
Returns:
type of the method

coerceTo

public abstract boolean coerceTo(Type t)
A type's values may be coerced to those of another type.

Parameters:
t - target type
Returns:
true if this coerces to t, false otherwise

equals

public abstract boolean equals(Type t)
Type equality

Parameters:
t - target type
Returns:
true if types are equivalent, false otherwise

accept

public abstract void accept(Type.Visitor v)
A type must accept a visitor

Parameters:
v - the visitor