edu.princeton.toy.lang
Class TExceptionType

java.lang.Object
  extended by edu.princeton.toy.lang.TExceptionType

public class TExceptionType
extends Object

TExceptionType describes the types of TException that can be thrown. Like TWords, instances of TExceptionType are immutable and are to be reused.


Field Summary
static TExceptionType COMMAND_UNINITIALIZED
          The type of exception that occurs when the fetch-execute loop attempts to execute the command in an uninitialized memory sector.
static String[] FAMILIES
          A string array containing the names of the families.
static TExceptionType MEM_OUT_OF_BOUNDS
          The type of exception that occurs when an operator attempts to access a memory sector that is not between 0000 and 00FF.
static TExceptionType MEMORY_UNINITIALIZED
          The type of exception that occurs when the value of an uninitialized memory sector is accessed by an operation.
static int OUT_OF_BOUNDS_FAMILY
          The identifier of the the family of overflow TExceptionTypes.
static TExceptionType OVERFLOW
          The type of exception that occurs when the result of the operation is not representable as a 16-bit two's complement signed integers.
static int OVERFLOW_FAMILY
          The identifier of the the family of overflow TExceptionTypes.
static TExceptionType PC_OUT_OF_BOUNDS
          The type of exception that occurs when the program counter exceeds FF.
static TExceptionType REGISTER_OUT_OF_BOUNDS
          The type of exception that occurs when an operator attempts to access a register that is not valid (attempting to assign a value to R[0]).
static TExceptionType REGISTER_UNINITIALIZED
          The type of exception that occurs when the value of an uninitialized register is accessed by an operation.
static TExceptionType SHIFT_OUT_OF_BOUNDS
          The type of exception that occurs when a shift operation is commanded to shift further than 000F positions.
static TExceptionType[] TYPES
          An array of all the TExceptionTypes, in order of hash-code.
static int UNINITIALIZED_FAMILY
          The identifier of the the family of uninitialized TExceptionTypes.
 
Method Summary
 String getDescription()
          Returns the description of this TExceptionType.
 int getFamily()
          Returns the family of this TExceptionType.
 String getName()
          Returns the name of this TExceptionType.
 int hashCode()
          Returns the hash-code of this TExceptionType.
 String toString()
          Returns the name of this TExceptionType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

FAMILIES

public static final String[] FAMILIES
A string array containing the names of the families.


UNINITIALIZED_FAMILY

public static final int UNINITIALIZED_FAMILY
The identifier of the the family of uninitialized TExceptionTypes. This includes REGISTER_UNINITIALIZED, MEMORY_UNINITIALIZED, and COMMAND_UNINITIALIZED.

See Also:
REGISTER_UNINITIALIZED, MEMORY_UNINITIALIZED, COMMAND_UNINITIALIZED, Constant Field Values

OVERFLOW_FAMILY

public static final int OVERFLOW_FAMILY
The identifier of the the family of overflow TExceptionTypes. This includes only OVERFLOW.

See Also:
OVERFLOW, Constant Field Values

OUT_OF_BOUNDS_FAMILY

public static final int OUT_OF_BOUNDS_FAMILY
The identifier of the the family of overflow TExceptionTypes. This includes SHIFT_OUT_OF_BOUNDS, PC_OUT_OF_BOUNDS, REGISTER_OUT_OF_BOUNDS, and MEM_OUT_OF_BOUNDS.

See Also:
SHIFT_OUT_OF_BOUNDS, PC_OUT_OF_BOUNDS, REGISTER_OUT_OF_BOUNDS, MEM_OUT_OF_BOUNDS, Constant Field Values

REGISTER_UNINITIALIZED

public static final TExceptionType REGISTER_UNINITIALIZED
The type of exception that occurs when the value of an uninitialized register is accessed by an operation.


MEMORY_UNINITIALIZED

public static final TExceptionType MEMORY_UNINITIALIZED
The type of exception that occurs when the value of an uninitialized memory sector is accessed by an operation.


COMMAND_UNINITIALIZED

public static final TExceptionType COMMAND_UNINITIALIZED
The type of exception that occurs when the fetch-execute loop attempts to execute the command in an uninitialized memory sector.


OVERFLOW

public static final TExceptionType OVERFLOW
The type of exception that occurs when the result of the operation is not representable as a 16-bit two's complement signed integers.


SHIFT_OUT_OF_BOUNDS

public static final TExceptionType SHIFT_OUT_OF_BOUNDS
The type of exception that occurs when a shift operation is commanded to shift further than 000F positions.


PC_OUT_OF_BOUNDS

public static final TExceptionType PC_OUT_OF_BOUNDS
The type of exception that occurs when the program counter exceeds FF.


REGISTER_OUT_OF_BOUNDS

public static final TExceptionType REGISTER_OUT_OF_BOUNDS
The type of exception that occurs when an operator attempts to access a register that is not valid (attempting to assign a value to R[0]).


MEM_OUT_OF_BOUNDS

public static final TExceptionType MEM_OUT_OF_BOUNDS
The type of exception that occurs when an operator attempts to access a memory sector that is not between 0000 and 00FF.


TYPES

public static final TExceptionType[] TYPES
An array of all the TExceptionTypes, in order of hash-code.

Method Detail

hashCode

public int hashCode()
Returns the hash-code of this TExceptionType.

Overrides:
hashCode in class Object
Returns:
The hash-code of this TExceptionType. Hash codes are guaranteed to be different for different TExceptionTypes. Moreover, the hash codes are gauranteed to have the property that TYPES[n].hashCode() == n.

getName

public String getName()
Returns the name of this TExceptionType.

Returns:
The name of this TExceptionType.

getFamily

public int getFamily()
Returns the family of this TExceptionType.

Returns:
The family of this TExceptionType. This should be one of UNINITIALIZED_FAMILY, OVERFLOW_FAMILY, and OUT_OF_BOUNDS_FAMILY.

getDescription

public String getDescription()
Returns the description of this TExceptionType.

Returns:
The description of this TExceptionType.

toString

public String toString()
Returns the name of this TExceptionType.

Overrides:
toString in class Object
Returns:
The name of this TExceptionType.