Package mars

Class ErrorMessage

java.lang.Object
mars.ErrorMessage

public class ErrorMessage extends Object
Represents occurrence of an error detected during tokenizing, assembly or simulation.
Version:
August 2003
Author:
Pete Sanderson
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static boolean
    Constant to indicate this message is error not warning
    static boolean
    Constant to indicate this message is warning not error
  • Constructor Summary

    Constructors
    Constructor
    Description
    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​(boolean isWarning, MIPSprogram sourceMIPSprogram, int line, int position, String message)
    Constructor for ErrorMessage.
    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.
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    Produce name of file containing error.
    int
    Produce line number of error.
    Returns string describing macro expansion.
    Produce error message.
    int
    Produce position within erroneous line.
    boolean
    Determine whether this message represents error or warning.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • 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 Details

    • 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 Details

    • 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