minijava.typecheck
Class Type

java.lang.Object
  extended by minijava.typecheck.Type
All Implemented Interfaces:
Binding
Direct Known Subclasses:
Bool, Class, Int, IntArray

public abstract class Type
extends java.lang.Object
implements Binding

This is an abstract class that represents a type. In MiniJava, this can either be integer (int), integer array (int[]), boolean, or custom class type.

Author:
Santoso Wijaya
See Also:
Int, IntArray, Bool, Class

Constructor Summary
protected Type(java.lang.String name)
           
 
Method Summary
abstract  boolean agrees(Type rhs)
          Checks whether this Type "agrees" with the given argument.
 boolean equals(java.lang.Object t)
           
 java.lang.String getTypeName()
           
 int hashCode()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Type

protected Type(java.lang.String name)
Method Detail

getTypeName

public java.lang.String getTypeName()

toString

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

equals

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

hashCode

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

agrees

public abstract boolean agrees(Type rhs)
Checks whether this Type "agrees" with the given argument. Two types are agreeable if they are equal primitives or, if they are class types, rhs is a subclass/subtype of this type.

Parameters:
rhs - the right hand side in the equivalence test
Returns:
true if type(this) == type(rhs), or ig type(this) == supertype(rhs), and false otherwise