Package edu.iu.jrsalata
Class Statement
java.lang.Object
edu.iu.jrsalata.Statement
- Direct Known Subclasses:
BaseStatement
,DirectiveStatement
The Statement class represents an abstract base class for different types of statements
in an assembler.
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
block represents the current program block the statement is inprotected String
controlSection represents the current controlSection of the statementprotected String
line represents the line of assembly this statement representsprotected HexNum
size represents how many bytes long the statement is -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
accept
(VisitorInterface visitor) Accepts a visitor object that implements the VisitorInterface.abstract String
assemble()
Assembles the statement into its corresponding representationgetBlock()
Retrieves the block associated with this statement.Retrieves the control section of the statement.getLine()
Retrieves the line of the statementgetSize()
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.
-
Field Details
-
size
size represents how many bytes long the statement is -
block
block represents the current program block the statement is in -
controlSection
controlSection represents the current controlSection of the statement -
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
Constructs a new Statement with the specified size.- Parameters:
size
- the size of the statement as a HexNum object
-
Statement
Constructs a new Statement with the specified size and block.- Parameters:
size
- the size of the statement as a HexNumblock
- the block of the statement as a String
-
-
Method Details
-
getSize
Returns the size of the statement as a HexNum.- Returns:
- the size of the statement
-
getBlock
Retrieves the block associated with this statement.- Returns:
- the block as a String
-
getControlSection
Retrieves the control section of the statement.- Returns:
- the control section as a String.
-
getLine
Retrieves the line of the statement- Returns:
- the human-readable line
-
setLine
Sets the line of the statement.- Parameters:
line
- the line to set
-
setControlSection
Sets the control section for this statement.- Parameters:
controlSection
- the control section to set
-
setBlock
Sets the block for this statement.- Parameters:
block
- the block to set
-
accept
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
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.
-