|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmars.MIPSprogram
public class MIPSprogram
Internal representations of MIPS program. Connects source, tokens and machine code. Having all these structures available facilitates construction of good messages, debugging, and easy simulation.
Constructor Summary | |
---|---|
MIPSprogram()
|
Method Summary | |
---|---|
ErrorList |
assemble(ArrayList MIPSprogramsToAssemble,
boolean extendedAssemblerEnabled)
Assembles the MIPS source program. |
ErrorList |
assemble(ArrayList MIPSprogramsToAssemble,
boolean extendedAssemblerEnabled,
boolean warningsAreErrors)
Assembles the MIPS source program. |
boolean |
backSteppingEnabled()
Returns status of BackStepper associated with this program. |
MacroPool |
createMacroPool()
Instantiates a new MacroPool and sends reference of this
MIPSprogram to it |
ArrayList |
createParsedList()
Produces new empty list to hold parsed source code statements. |
BackStepper |
getBackStepper()
Returns BackStepper associated with this program. |
String |
getFilename()
Produces name of associated source code file. |
MacroPool |
getLocalMacroPool()
Gets local macro pool MacroPool for this program |
SymbolTable |
getLocalSymbolTable()
Returns SymbolTable associated with this program. |
ArrayList |
getMachineList()
Produces list of machine statements that are assembled from the program. |
ArrayList |
getParsedList()
Produces existing list of parsed source code statements. |
String |
getSourceLine(int i)
Produces specified line of MIPS source program. |
ArrayList<SourceLine> |
getSourceLineList()
Retrieve list of source statements that comprise the program. |
ArrayList |
getSourceList()
Produces list of source statements that comprise the program. |
Tokenizer |
getTokenizer()
Retrieves Tokenizer for this program |
ArrayList |
getTokenList()
Produces list of tokens that comprise the program. |
boolean |
inSteppedExecution()
Will be true only while in process of simulating a program statement in step mode (e.g. |
ArrayList |
prepareFilesForAssembly(ArrayList filenames,
String leadFilename,
String exceptionHandler)
Prepares the given list of files for assembly. |
void |
readSource(String file)
Reads MIPS source code from file into structure. |
void |
setLocalMacroPool(MacroPool macroPool)
Sets local macro pool MacroPool for this program |
void |
setSourceLineList(ArrayList<SourceLine> sourceLineList)
Set list of source statements that comprise the program. |
boolean |
simulate(int maxSteps)
Simulates execution of the MIPS program. |
boolean |
simulate(int[] breakPoints)
Simulates execution of the MIPS program. |
boolean |
simulateFromPC(int[] breakPoints,
int maxSteps,
AbstractAction a)
Simulates execution of the MIPS program. |
boolean |
simulateStepAtPC(AbstractAction a)
Simulates execution of the MIPS program. |
void |
tokenize()
Tokenizes the MIPS source program. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MIPSprogram()
Method Detail |
---|
public ArrayList getSourceList()
public void setSourceLineList(ArrayList<SourceLine> sourceLineList)
sourceLineList
- ArrayList of SourceLine.
Each SourceLine represents one line of MIPS source code.public ArrayList<SourceLine> getSourceLineList()
public String getFilename()
public ArrayList getTokenList()
TokenList
public Tokenizer getTokenizer()
public ArrayList createParsedList()
ProgramStatement
public ArrayList getParsedList()
ProgramStatement
public ArrayList getMachineList()
ProgramStatement
public BackStepper getBackStepper()
public SymbolTable getLocalSymbolTable()
public boolean backSteppingEnabled()
public String getSourceLine(int i)
i
- Line number of MIPS source program to get. Line 1 is first line.
public void readSource(String file) throws ProcessingException
file
- String containing name of MIPS source code file.
ProcessingException
- Will throw exception if there is any problem reading the file.public void tokenize() throws ProcessingException
ProcessingException
- Will throw exception if errors occured while tokenizing.public ArrayList prepareFilesForAssembly(ArrayList filenames, String leadFilename, String exceptionHandler) throws ProcessingException
filenames
- ArrayList containing the source file name(s) in no particular orderleadFilename
- String containing name of source file that needs to go first and
will be represented by "this" MIPSprogram object.exceptionHandler
- String containing name of source file containing exception
handler. This will be assembled first, even ahead of leadFilename, to allow it to
include "startup" instructions loaded beginning at 0x00400000. Specify null or
empty String to indicate there is no such designated exception handler.
ProcessingException
- Will throw exception if errors occured while reading or tokenizing.public ErrorList assemble(ArrayList MIPSprogramsToAssemble, boolean extendedAssemblerEnabled) throws ProcessingException
MIPSprogramsToAssemble
- ArrayList of MIPSprogram objects, each representing a tokenized source file.extendedAssemblerEnabled
- A boolean value - true means extended (pseudo) instructions
are permitted in source code and false means they are to be flagged as errors.
ProcessingException
- Will throw exception if errors occured while assembling.public ErrorList assemble(ArrayList MIPSprogramsToAssemble, boolean extendedAssemblerEnabled, boolean warningsAreErrors) throws ProcessingException
MIPSprogramsToAssemble
- ArrayList of MIPSprogram objects, each representing a tokenized source file.extendedAssemblerEnabled
- A boolean value - true means extended (pseudo) instructions
are permitted in source code and false means they are to be flagged as errorswarningsAreErrors
- A boolean value - true means assembler warnings will be considered errors and terminate
the assemble; false means the assembler will produce warning message but otherwise ignore warnings.
ProcessingException
- Will throw exception if errors occured while assembling.public boolean simulate(int[] breakPoints) throws ProcessingException
breakPoints
- int array of breakpoints (PC addresses). Can be null.
ProcessingException
- Will throw exception if errors occured while simulating.public boolean simulate(int maxSteps) throws ProcessingException
maxSteps
- maximum number of steps to simulate.
ProcessingException
- Will throw exception if errors occured while simulating.public boolean simulateFromPC(int[] breakPoints, int maxSteps, AbstractAction a) throws ProcessingException
breakPoints
- int array of breakpoints (PC addresses). Can be null.maxSteps
- maximum number of instruction executions. Default -1 means no maximum.a
- the GUI component responsible for this call (GO normally). set to null if none.
ProcessingException
- Will throw exception if errors occured while simulating.public boolean simulateStepAtPC(AbstractAction a) throws ProcessingException
a
- the GUI component responsible for this call (STEP normally). Set to null if none.
ProcessingException
- Will throw exception if errors occured while simulating.public boolean inSteppedExecution()
public MacroPool createMacroPool()
MacroPool
and sends reference of this
MIPSprogram
to it
public MacroPool getLocalMacroPool()
MacroPool
for this program
public void setLocalMacroPool(MacroPool macroPool)
MacroPool
for this program
macroPool
- reference to MacroPool
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |