Class DirectiveStatement

java.lang.Object
edu.iu.jrsalata.Statement
edu.iu.jrsalata.DirectiveStatement

public class DirectiveStatement extends Statement
The DirectiveStatement class represents a directive statement in an assembler. It extends the Statement class and includes additional fields for the directive and the object code. This class provides constructors for creating directive statements with different initial values, as well as getters and setters for accessing and modifying the directive, size, and object code. It also includes methods for assembling the directive statement and accepting a visitor.
See Also:
  • Field Details

    • directive

      protected String directive
      name of the directive this statement represents
    • objectCode

      protected String objectCode
      the object code this statement generates, if any
  • Constructor Details

    • DirectiveStatement

      public DirectiveStatement()
      Constructs a new DirectiveStatement with default values. Initializes the directive and objectCode fields to empty strings.
    • DirectiveStatement

      public DirectiveStatement(String directive)
      Constructs a new DirectiveStatement with the specified directive.
      Parameters:
      directive - the directive to be used for this statement
    • DirectiveStatement

      public DirectiveStatement(HexNum size, String directive)
      Constructs a DirectiveStatement with the specified size and directive.
      Parameters:
      size - the size of the directive statement as a HexNum
      directive - the directive as a String
  • Method Details

    • getDirective

      public String getDirective()
      Retrieves the directive associated with this statement.
      Returns:
      the directive as a String.
    • setDirective

      public void setDirective(String directive)
      Sets the directive for this DirectiveStatement.
      Parameters:
      directive - the directive to set
    • setSize

      public void setSize(HexNum size)
      Sets the size of the directive statement.
      Parameters:
      size - the size to set, represented as a HexNum object
    • setObjCode

      public void setObjCode(String code)
      Sets the object code for this directive statement.
      Parameters:
      code - the object code to set
    • assemble

      public String assemble()
      Returns the object code belonging to this directive, if any
      Specified by:
      assemble in class Statement
      Returns:
      the assembled object code as a String.
    • accept

      public void accept(VisitorInterface visitor)
      Accepts a visitor object and allows it to visit this directive statement. This method is part of the Visitor design pattern.
      Specified by:
      accept in class Statement
      Parameters:
      visitor - the visitor object that will visit this directive statement