mars
Class ErrorMessage

java.lang.Object
  extended by mars.ErrorMessage

public class ErrorMessage
extends Object

Represents occurrance of an error detected during tokenizing, assembly or simulation.

Author:
Pete Sanderson

Field Summary
static boolean ERROR
          Constant to indicate this message is error not warning
static boolean WARNING
          Constant to indicate this message is warning not error
 
Constructor Summary
ErrorMessage(boolean isWarning, MIPSprogram sourceMIPSprogram, int line, int position, String message)
          Constructor for ErrorMessage.
ErrorMessage(boolean isWarning, String filename, int line, int position, String message, String macroExpansionHistory)
          Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
ErrorMessage(MIPSprogram sourceMIPSprogram, int line, int position, String message)
          Constructor for ErrorMessage.
ErrorMessage(ProgramStatement statement, String message)
          Constructor for ErrorMessage, to be used for runtime exceptions.
ErrorMessage(String filename, int line, int position, String message)
          Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
ErrorMessage(String filename, int line, int position, String message, String macroExpansionHistory)
          Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.
 
Method Summary
 String getFilename()
          Produce name of file containing error.
 int getLine()
          Produce line number of error.
 String getMacroExpansionHistory()
          Returns string describing macro expansion.
 String getMessage()
          Produce error message.
 int getPosition()
          Produce position within erroneous line.
 boolean isWarning()
          Determine whether this message represents error or warning.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WARNING

public static final boolean WARNING
Constant to indicate this message is warning not error

See Also:
Constant Field Values

ERROR

public static final boolean ERROR
Constant to indicate this message is error not warning

See Also:
Constant Field Values
Constructor Detail

ErrorMessage

@Deprecated
public ErrorMessage(String filename,
                               int line,
                               int position,
                               String message)
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.

Constructor for ErrorMessage.

Parameters:
filename - String containing name of source file in which this error appears.
line - Line number in source program being processed when error occurred.
position - Position within line being processed when error occurred. Normally is starting position of source token.
message - String containing appropriate error message.

ErrorMessage

@Deprecated
public ErrorMessage(String filename,
                               int line,
                               int position,
                               String message,
                               String macroExpansionHistory)
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.

Constructor for ErrorMessage.

Parameters:
filename - String containing name of source file in which this error appears.
line - Line number in source program being processed when error occurred.
position - Position within line being processed when error occurred. Normally is starting position of source token.
message - String containing appropriate error message.
macroExpansionHistory -

ErrorMessage

@Deprecated
public ErrorMessage(boolean isWarning,
                               String filename,
                               int line,
                               int position,
                               String message,
                               String macroExpansionHistory)
Deprecated. Newer constructors replace the String filename parameter with a MIPSprogram parameter to provide more information.

Constructor for ErrorMessage.

Parameters:
isWarning - set to WARNING if message is a warning not error, else set to ERROR or omit.
filename - String containing name of source file in which this error appears.
line - Line number in source program being processed when error occurred.
position - Position within line being processed when error occurred. Normally is starting position of source token.
message - String containing appropriate error message.
macroExpansionHistory - provided so message for macro can include both definition and usage line numbers

ErrorMessage

public ErrorMessage(MIPSprogram sourceMIPSprogram,
                    int line,
                    int position,
                    String message)
Constructor for ErrorMessage. Assumes line number is calculated after any .include files expanded, and if there were, it will adjust filename and line number so message reflects original file and line number.

Parameters:
sourceMIPSprogram - MIPSprogram object of source file in which this error appears.
line - Line number in source program being processed when error occurred.
position - Position within line being processed when error occurred. Normally is starting position of source token.
message - String containing appropriate error message.

ErrorMessage

public ErrorMessage(boolean isWarning,
                    MIPSprogram sourceMIPSprogram,
                    int line,
                    int position,
                    String message)
Constructor for ErrorMessage. Assumes line number is calculated after any .include files expanded, and if there were, it will adjust filename and line number so message reflects original file and line number.

Parameters:
isWarning - set to WARNING if message is a warning not error, else set to ERROR or omit.
sourceMIPSprogram - MIPSprogram object of source file in which this error appears.
line - Line number in source program being processed when error occurred.
position - Position within line being processed when error occurred. Normally is starting position of source token.
message - String containing appropriate error message.

ErrorMessage

public ErrorMessage(ProgramStatement statement,
                    String message)
Constructor for ErrorMessage, to be used for runtime exceptions.

Parameters:
statement - The ProgramStatement object for the instruction causing the runtime error
message - String containing appropriate error message.
Method Detail

getFilename

public String getFilename()
Produce name of file containing error.

Returns:
Returns String containing name of source file containing the error.

getLine

public int getLine()
Produce line number of error.

Returns:
Returns line number in source program where error occurred.

getPosition

public int getPosition()
Produce position within erroneous line.

Returns:
Returns position within line of source program where error occurred.

getMessage

public String getMessage()
Produce error message.

Returns:
Returns String containing textual error message.

isWarning

public boolean isWarning()
Determine whether this message represents error or warning.

Returns:
Returns true if this message reflects warning, false if error.

getMacroExpansionHistory

public String getMacroExpansionHistory()
Returns string describing macro expansion. Empty string if none.

Returns:
string describing macro expansion