miSim

misim.asm
Class AsmLine

java.lang.Object
  |
  +--misim.editor.Line
        |
        +--misim.asm.AsmLine
All Implemented Interfaces:
LineIterator, TokenIterator, UndoIF

public class AsmLine
extends Line
implements LineIterator

The AsmLine class extends the editor line class to store and retrieve information generated during assembly of files.


Field Summary
static int ASM_ITERATOR
           
 
Fields inherited from class misim.editor.Line
tokenIndex, tokens
 
Constructor Summary
AsmLine()
           
AsmLine(java.util.Vector tokens)
           
 
Method Summary
 void addChildLine(Line childLine)
          Add the given line as a child of this.
 void addData(int value)
          Add a word of data to this line.
 void addError(EditorException editorException)
          Add an error to this line, that can be displayed by the editor
 EditorException addError(Token aToken, int errNo)
          Add an error to this line, that can be displayed by the editor
 void addInstruction(Instruction instruction)
          Add an instruction to this line
 void addWarning(Token aToken, int errNo)
          Add an warning to this line, that can be displayed by the editor
 int dataSize()
          Return the number of words of data on this line
 void draw(java.awt.Graphics g, int x, int y, int lineHeight, int lineWidth, int leftMargin, boolean showErrors)
          Draw this line
 int getAddress()
          Get the address for the data or instructions that occur on this line
 Token getAssignment()
          If this line assigns a new value to a label, return the token for the label, otherwise return null.
 int getAssignmentValue()
          Returns the value assigned to a label on this line (if any)
 boolean getBreakpoint()
          Indicate if this line has a breakpoint set
 int getData(int index)
          Return the specified data word generated on this line
 Instruction getInstruction(int index)
          Return the given instruction defined on this line
 Token getLastToken()
          Return the last token before this one, or null if at the start of the line.
 int getLineIndex()
          Return the current line index being read in this file
 int getLineNumber()
           
 boolean getList()
          Return the list flag for this line
 Line getNextLine()
          Return the next line, and advance the index to the next line in the file.
 Token getNextToken()
          Return this token, and advance the pointer to the next token.
 boolean getSkip()
          Return the skip flag for this line.
 Line getSourceLine()
           
 int getType()
          Return the type of this iterator
 boolean hasChildren()
          Indicate whether this line contains child lines
 void insertLine(Line aLine)
          Insert a new line at the current line index.
 int instructionCount()
          Return the number of instructions defined by this line
 Context newContext()
          If there is a new context assigned to this line, return it, otherwise return null.
 void previousToken()
          move to the previous token.
 void resetLineIndex()
          Reset the current line index to the beginning of the source
 void setAddress(int address)
          Set the address for the data or instructions that occur on this line
 void setAssignment(Token labelToken, int newValue)
          Set an assignment for this line.
 void setBreakpoint(boolean breakpoint)
          Set whether this line has a breakpoint or not
 void setContext(Context context)
          Set a new context for this and subsequent lines
 void setLineNumber(int lineNumber)
           
 void setList(boolean list)
          Set the list flag for this line.
 void setPreprocessed(java.util.Vector preprocessed)
          Setting a preprocessed vector of tokens replaces this line's token iterator list with the new preprocessed version.
 void setSkip(boolean skip)
          Set the skip flag for this line.
 void setSourceLine(Line sourceLine)
           
 
Methods inherited from class misim.editor.Line
clearErrors, countTokens, delete, errorCount, getColumn, getError, getLength, getPixelPos, getToken, getTokenVector, getValue, getWarning, getWidth, insert, insert, redo, resetTokenIndex, undo, warningCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASM_ITERATOR

public static final int ASM_ITERATOR
Constructor Detail

AsmLine

public AsmLine()

AsmLine

public AsmLine(java.util.Vector tokens)
Method Detail

draw

public void draw(java.awt.Graphics g,
                 int x,
                 int y,
                 int lineHeight,
                 int lineWidth,
                 int leftMargin,
                 boolean showErrors)
Draw this line
Overrides:
draw in class Line
Parameters:
g - The graphics context to draw to
x - The x co-ordinate of the line
y - The y co-ordinate of the line
lineHeight - The height of a displayed line
lineWidth - The width of a displayed line
leftMargin - The left margin for the line
showErrors - If true, indicate errors for this line

setContext

public void setContext(Context context)
Set a new context for this and subsequent lines
Parameters:
context - The new context to use

newContext

public Context newContext()
If there is a new context assigned to this line, return it, otherwise return null.
Returns:
The new context for this and subsequent lines, or null

setAssignment

public void setAssignment(Token labelToken,
                          int newValue)
                   throws EditorException
Set an assignment for this line.
Parameters:
labelToken - The token for the label that is being assigned
int - The value of the label

getAssignment

public Token getAssignment()
If this line assigns a new value to a label, return the token for the label, otherwise return null.
Returns:
The assignment token, or null

getAssignmentValue

public int getAssignmentValue()
Returns the value assigned to a label on this line (if any)
Returns:
The new value for the label

addChildLine

public void addChildLine(Line childLine)
Add the given line as a child of this. Child lines are not displayed, but are read by the assembler, through the file.getNextLine method
Parameters:
childLine - The line to add as a child of this

hasChildren

public boolean hasChildren()
Indicate whether this line contains child lines
Returns:
True if this line contains child lines

resetLineIndex

public void resetLineIndex()
Reset the current line index to the beginning of the source
Specified by:
resetLineIndex in interface LineIterator

getNextLine

public Line getNextLine()
Return the next line, and advance the index to the next line in the file.
Specified by:
getNextLine in interface LineIterator
Returns:
The next line in the file, or null if there are no more

getLineIndex

public int getLineIndex()
Return the current line index being read in this file
Specified by:
getLineIndex in interface LineIterator
Returns:
The current line index

insertLine

public void insertLine(Line aLine)
Insert a new line at the current line index. Note that the next call to getNextLine will return the line after the line just inserted.
Specified by:
insertLine in interface LineIterator
Parameters:
aLine - The line to insert

getType

public int getType()
Return the type of this iterator
Specified by:
getType in interface LineIterator
Returns:
The type of this iterator

setSourceLine

public void setSourceLine(Line sourceLine)

getSourceLine

public Line getSourceLine()

setLineNumber

public void setLineNumber(int lineNumber)

getLineNumber

public int getLineNumber()

setAddress

public void setAddress(int address)
Set the address for the data or instructions that occur on this line
Parameters:
address - The address for this line

getAddress

public int getAddress()
Get the address for the data or instructions that occur on this line
Returns:
The address for this line

addInstruction

public void addInstruction(Instruction instruction)
Add an instruction to this line
Parameters:
instruction - The instruction to add

instructionCount

public int instructionCount()
Return the number of instructions defined by this line
Returns:
The number of instructions

getInstruction

public Instruction getInstruction(int index)
Return the given instruction defined on this line
Parameters:
index - The index of the required instruction
Returns:
The required instruction

dataSize

public int dataSize()
Return the number of words of data on this line

getData

public int getData(int index)
Return the specified data word generated on this line
Parameters:
index - The index of the required word
Returns:
The value of the word at the given index

addData

public void addData(int value)
Add a word of data to this line.
Parameters:
value - The value of the data to add

setBreakpoint

public void setBreakpoint(boolean breakpoint)
Set whether this line has a breakpoint or not
Parameters:
break - If true, then thisline has a breakpoint

getBreakpoint

public boolean getBreakpoint()
Indicate if this line has a breakpoint set
Returns:
True if a breakpoint is set for this line

setList

public void setList(boolean list)
Set the list flag for this line. This is used by the assembler to indicate if this line should be shown in assembly listings
Parameters:
list - True if this line should be listed

getList

public boolean getList()
Return the list flag for this line
Returns:
True if the lines should be shown in the assembly listing

setSkip

public void setSkip(boolean skip)
Set the skip flag for this line. This is used by the assembler to flag lines that should not be assembled - for instance due to conditional assembly, or because they are part of a macro definition
Parameters:
skip - True if the assembler should skip this line

getSkip

public boolean getSkip()
Return the skip flag for this line.
Returns:
True if the assembler should skip this line
See Also:
setSkip( boolean skip )

addError

public EditorException addError(Token aToken,
                                int errNo)
Add an error to this line, that can be displayed by the editor
Overrides:
addError in class Line
Parameters:
aToken - The token that caused the error, or null
errNo - The message error identifier
Returns:
The editor exception added to this line

addError

public void addError(EditorException editorException)
Add an error to this line, that can be displayed by the editor
Overrides:
addError in class Line
Parameters:
editorException - The exception that caused the error
errNo - The message error identifier

addWarning

public void addWarning(Token aToken,
                       int errNo)
Add an warning to this line, that can be displayed by the editor
Overrides:
addWarning in class Line
Parameters:
aToken - The token that caused the error, or null
errNo - The message error identifier

setPreprocessed

public void setPreprocessed(java.util.Vector preprocessed)
Setting a preprocessed vector of tokens replaces this line's token iterator list with the new preprocessed version. This allows us to display the un-processed tokens, whilst the assembler sees the processed line

getNextToken

public Token getNextToken()
Return this token, and advance the pointer to the next token. If the pointer is beyond the end of the list of tokens, return null.
Overrides:
getNextToken in class Line
Returns:
The next token, or null if there are no more tokens

getLastToken

public Token getLastToken()
Return the last token before this one, or null if at the start of the line.
Overrides:
getLastToken in class Line
Returns:
The last token returned by getNextToken()

previousToken

public void previousToken()
                   throws EditorException
move to the previous token. If the pointer is at the start of the file, throw an exception.
Overrides:
previousToken in class Line

miSim