|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--uk.ac.man.cs.rainbow.simulator.RASMCode
A block of RASM code. This is the primary mechanism for definining the behaviour of a thread for simulation in the Rainbow simulator.
RASMThread
,
Instruction
, Serialized FormInner Class Summary | |
static class |
RASMCode.Exception
Exceptions thrown due to bad assembly code. |
static class |
RASMCode.Label
A label/location in a block of code. |
Field Summary | |
static String |
ARG_PREFIX
Argument references are preceded by this string. |
static char |
COMMENT_STARTER
Indicates that this line of RASM text is a comment. |
static String |
CONSTANT_COMMAND
A constant command starts with this opcode. |
static String |
LABEL_PREFIX
Label references are preceded by this string. |
static char |
LABEL_STARTER
Indicates that this line of RASM text is a label definition. |
static String |
MODULE_COMMAND
A module command starts with this opcode. |
static String |
MODULE_SEPARATOR
The module/label string separator. |
static String |
PUSH_COMMAND
A push command starts with this opcode. |
static String |
RASM_EXTENSION
The extension for a RASM file. |
static String |
STDLIB_PROPERTY_NAME
The name of the property to read the standard library from. |
static String |
STRING_PREFIX
String references are preceded by this string. |
static String |
TYPE_COMMAND
A type command starts with this opcode. |
static String |
TYPE_PREFIX
Type references are preceded by this string. |
Constructor Summary | |
RASMCode(Hashtable library,
BufferedReader contents)
Create a new block of code. |
|
RASMCode(Hashtable library,
BufferedReader contents,
boolean resolve)
Create a new block of code. |
|
RASMCode(String name,
Hashtable library)
Create a new block of code. |
|
RASMCode(String name,
Hashtable library,
boolean resolve)
Create a new block of code. |
|
RASMCode(String name,
Hashtable library,
BufferedReader contents)
Create a new block of code. |
|
RASMCode(String name,
Hashtable library,
BufferedReader contents,
boolean resolve)
Create a new block of code. |
Method Summary | |
void |
addInstruction(Instruction instr)
Add an instruction to the block of code. |
RASMCode.Label |
defineLabel(String label)
Define a new label with the given name. |
Instruction |
getInstr(int location)
Get the instruction at the given location. |
RASMCode.Label |
getLabel(String label)
Get the label whose name is that given. |
static Hashtable |
getStandardLibrary()
Get a reference to the standard library. |
void |
loadContents(BufferedReader reader)
Assemble from a character stream. |
Type |
parseType(String s)
Convert a string to a type in the context of this code block. |
String |
print(int locn)
Print the instruction at the given location. |
String |
print(int from,
int to)
Print the instructions in the given range. |
protected RASMCode.Label |
resolveLabel(String label)
Resolve a string to a label. |
void |
resolveLabels()
Link the block of code. |
String |
toString()
Get the name of the block of code. |
void |
useLabel(RASMCode.Label label)
Add a reference to the given label. |
void |
useLabel(String label)
Add a reference to the label with the given name. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String MODULE_SEPARATOR
useLabel(String)
,
resolveLabels()
public static final char COMMENT_STARTER
public static final char LABEL_STARTER
public static final String MODULE_COMMAND
public static final String CONSTANT_COMMAND
public static final String TYPE_COMMAND
public static final String PUSH_COMMAND
public static final String LABEL_PREFIX
public static final String STRING_PREFIX
public static final String TYPE_PREFIX
public static final String ARG_PREFIX
public static final String STDLIB_PROPERTY_NAME
public static final String RASM_EXTENSION
Constructor Detail |
public RASMCode(String name, Hashtable library)
name
- The name of the block of code.library
- The group of other blocks that labels in this block of code
can refer to.public RASMCode(String name, Hashtable library, boolean resolve)
name
- The name of the block of code.library
- The group of other blocks that labels in this block of code
can refer to.resolve
- Indicate whether to resolve all library references automatically
on completion of the loading of code.public RASMCode(String name, Hashtable library, BufferedReader contents) throws RASMCode.Exception, IOException, TypeException, TclFormatException
name
- The name of the block of code.library
- The group of other blocks that labels in this block of code
can refer to.contents
- The stream of RASM text that defines the instructions and labels
in this block of code.loadContents(BufferedReader)
public RASMCode(String name, Hashtable library, BufferedReader contents, boolean resolve) throws RASMCode.Exception, IOException, TypeException, TclFormatException
name
- The name of the block of code.library
- The group of other blocks that labels in this block of code
can refer to.contents
- The stream of RASM text that defines the instructions and labels
in this block of code.resolve
- Indicate whether to resolve all library references automatically
on completion of the loading of code.loadContents(BufferedReader)
public RASMCode(Hashtable library, BufferedReader contents) throws RASMCode.Exception, IOException, TypeException, TclFormatException
library
- The group of other blocks that labels in this block of code
can refer to.contents
- The stream of RASM text that defines the instructions and labels
in this block of code.loadContents(BufferedReader)
public RASMCode(Hashtable library, BufferedReader contents, boolean resolve) throws RASMCode.Exception, IOException, TypeException, TclFormatException
library
- The group of other blocks that labels in this block of code
can refer to.contents
- The stream of RASM text that defines the instructions and labels
in this block of code.resolve
- Indicate whether to resolve all library references automatically
on completion of the loading of code.loadContents(BufferedReader)
Method Detail |
public static Hashtable getStandardLibrary()
public String toString()
toString
in class Object
public Instruction getInstr(int location)
location
- The address in this block of code to get the instruction from.RainbowError
- If the code has not yet been linked.public RASMCode.Label getLabel(String label)
label
- The name of the label to return.RuntimeException
- If the label is unknown at this point.public RASMCode.Label defineLabel(String label)
label
- The name of the label to return.RainbowError
- If the code has already been linked.public void addInstruction(Instruction instr)
instr
- The instruction to add.RainbowError
- If the code has already been linked.public void useLabel(RASMCode.Label label)
label
- The label to refer to.addInstruction(Instruction)
public void useLabel(String label)
label
- The name of label to refer to. May also be the name of a
label in another block of code.addInstruction(Instruction)
public void resolveLabels() throws RASMCode.Exception
RASMCode.Exception
- If there is an unresolvable label.RainbowError
- If the block of code has already been linked.resolveLabel(String)
protected RASMCode.Label resolveLabel(String label) throws RASMCode.Exception
label
- The name of the label to look up.RASMCode.Exception
- If the label cannot be resolved.MODULE_SEPARATOR
public String print(int from, int to)
from
- The location of the first instruction to print. Will be set
to 0 internally if less than 0.to
- One greater than the location of the last instruction to
print. Will be set to one past the last instruction in the
block of code if past that point.public String print(int locn)
locn
- The location of the instruction to print.print(int,int)
public final Type parseType(String s) throws TypeException
s
- The string to parse.TypeException
- If the string is not a valid type.public void loadContents(BufferedReader reader) throws RASMCode.Exception, IOException, TypeException, TclFormatException
reader
- The character stream to read from.RASMCode.Exception
- If there is a malformatted instruction.TypeException
- If the parsing of a data value or type fails.TclFormatException
- If the input stream doesn't meet standard Tcl-style formatting rules.IOException
- If the input stream ends unexpectedly.RainbowError
- If the code block has already been linked.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |