Class Statement

java.lang.Object
edu.iu.jrsalata.Statement
Direct Known Subclasses:
BaseStatement, DirectiveStatement

public abstract class Statement extends Object
The Statement class represents an abstract base class for different types of statements in an assembler.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
    block represents the current program block the statement is in
    protected String
    controlSection represents the current controlSection of the statement
    protected String
    line represents the line of assembly this statement represents
    protected HexNum
    size represents how many bytes long the statement is
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    Protected constructor for the Statement class.
    protected
    Constructs a new Statement with the specified size.
    protected
    Statement(HexNum size, String block)
    Constructs a new Statement with the specified size and block.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract void
    Accepts a visitor object that implements the VisitorInterface.
    abstract String
    Assembles the statement into its corresponding representation
    Retrieves the block associated with this statement.
    Retrieves the control section of the statement.
    Retrieves the line of the statement
    Returns the size of the statement as a HexNum.
    void
    Sets the block for this statement.
    void
    setControlSection(String controlSection)
    Sets the control section for this statement.
    void
    Sets the line of the statement.

    Methods inherited from class java.lang.Object

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

    • size

      protected HexNum size
      size represents how many bytes long the statement is
    • block

      protected String block
      block represents the current program block the statement is in
    • controlSection

      protected String controlSection
      controlSection represents the current controlSection of the statement
    • line

      protected String line
      line represents the line of assembly this statement represents
  • Constructor Details

    • Statement

      protected Statement()
      Protected constructor for the Statement class. Initializes a new Statement object with default values. Sets the size to a new HexNum object with a value of 0. Sets the block to an empty string.
    • Statement

      protected Statement(HexNum size)
      Constructs a new Statement with the specified size.
      Parameters:
      size - the size of the statement as a HexNum object
    • Statement

      protected Statement(HexNum size, String block)
      Constructs a new Statement with the specified size and block.
      Parameters:
      size - the size of the statement as a HexNum
      block - the block of the statement as a String
  • Method Details

    • getSize

      public HexNum getSize()
      Returns the size of the statement as a HexNum.
      Returns:
      the size of the statement
    • getBlock

      public String getBlock()
      Retrieves the block associated with this statement.
      Returns:
      the block as a String
    • getControlSection

      public String getControlSection()
      Retrieves the control section of the statement.
      Returns:
      the control section as a String.
    • getLine

      public String getLine()
      Retrieves the line of the statement
      Returns:
      the human-readable line
    • setLine

      public void setLine(String line)
      Sets the line of the statement.
      Parameters:
      line - the line to set
    • setControlSection

      public void setControlSection(String controlSection)
      Sets the control section for this statement.
      Parameters:
      controlSection - the control section to set
    • setBlock

      public void setBlock(String block)
      Sets the block for this statement.
      Parameters:
      block - the block to set
    • accept

      public abstract void accept(VisitorInterface visitor)
      Accepts a visitor object that implements the VisitorInterface. This method allows the visitor to perform some operation on the current statement.
      Parameters:
      visitor - the visitor object that will operate on the statement
    • assemble

      public abstract String assemble() throws InvalidAssemblyFileException
      Assembles the statement into its corresponding representation
      Returns:
      A string representing the assembled statement.
      Throws:
      InvalidAssemblyFileException - if the assembly file is invalid or contains errors.