Package edu.iu.jrsalata
Class DirectiveStatement
java.lang.Object
edu.iu.jrsalata.Statement
edu.iu.jrsalata.DirectiveStatement
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 Summary
Modifier and TypeFieldDescriptionprotected String
name of the directive this statement representsprotected String
the object code this statement generates, if anyFields inherited from class edu.iu.jrsalata.Statement
block, controlSection, line, size
-
Constructor Summary
ConstructorDescriptionConstructs a new DirectiveStatement with default values.DirectiveStatement
(HexNum size, String directive) Constructs a DirectiveStatement with the specified size and directive.DirectiveStatement
(String directive) Constructs a new DirectiveStatement with the specified directive. -
Method Summary
Modifier and TypeMethodDescriptionvoid
accept
(VisitorInterface visitor) Accepts a visitor object and allows it to visit this directive statement.assemble()
Returns the object code belonging to this directive, if anyRetrieves the directive associated with this statement.void
setDirective
(String directive) Sets the directive for this DirectiveStatement.void
setObjCode
(String code) Sets the object code for this directive statement.void
Sets the size of the directive statement.Methods inherited from class edu.iu.jrsalata.Statement
getBlock, getControlSection, getLine, getSize, setBlock, setControlSection, setLine
-
Field Details
-
directive
name of the directive this statement represents -
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
Constructs a new DirectiveStatement with the specified directive.- Parameters:
directive
- the directive to be used for this statement
-
DirectiveStatement
Constructs a DirectiveStatement with the specified size and directive.- Parameters:
size
- the size of the directive statement as a HexNumdirective
- the directive as a String
-
-
Method Details
-
getDirective
Retrieves the directive associated with this statement.- Returns:
- the directive as a String.
-
setDirective
Sets the directive for this DirectiveStatement.- Parameters:
directive
- the directive to set
-
setSize
Sets the size of the directive statement.- Parameters:
size
- the size to set, represented as a HexNum object
-
setObjCode
Sets the object code for this directive statement.- Parameters:
code
- the object code to set
-
assemble
Returns the object code belonging to this directive, if any -
accept
Accepts a visitor object and allows it to visit this directive statement. This method is part of the Visitor design pattern.
-