uk.ac.man.cs.rainbow.simulator
Class RASMList

java.lang.Object
  |
  +--uk.ac.man.cs.rainbow.simulator.RASMList
All Implemented Interfaces:
Cloneable, Serializable

public final class RASMList
extends Object
implements Serializable, Cloneable

A list of RASM instructions. This is designed for use as an output format for a compiler so that blocks of code do not need to be generated in order.

See Also:
Instruction, RASMCode, Serialized Form

Constructor Summary
RASMList()
           
 
Method Summary
 RASMList append(Instruction instr)
          Append an instruction to the list.
 RASMList append(RASMList list)
          Append another list to the list.
 Object clone()
          Clone the list.
 RASMCode makeAndLinkCode(String name, Hashtable library)
          Create a code block from this list of instructions.
 RASMList placeLabelHere(String label)
          Place a label at this point.
 RASMList pushLabelReference(String label)
          Push a reference to the given label.
 void spoolToCode(RASMCode code)
          Write the list into a block of code.
 String toString()
          Produce a displayable version.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RASMList

public RASMList()
Method Detail

append

public RASMList append(Instruction instr)
Append an instruction to the list.
Parameters:
instr - The instruction to append.
Returns:
The list (for convenience.)

append

public RASMList append(RASMList list)
Append another list to the list.
Parameters:
list - The list of instructions to append to this list.
Returns:
The list (for convenience.)

placeLabelHere

public RASMList placeLabelHere(String label)
Place a label at this point.
Parameters:
label - The label to place at this point. The label should be a local label.
Returns:
The list (for convenience.)
See Also:
RASMCode.Label, RASMCode.MODULE_SEPARATOR

pushLabelReference

public RASMList pushLabelReference(String label)
Push a reference to the given label.
Parameters:
label - The label to place at this point. The label can be a local or a global label.
Returns:
The list (for convenience.)
See Also:
RASMCode.Label, RASMCode.MODULE_SEPARATOR, RASM.Push

spoolToCode

public void spoolToCode(RASMCode code)
Write the list into a block of code. This approximates to assembly in a more traditional compiler architecture.
Parameters:
code - The block of code to write into.

clone

public Object clone()
Clone the list.
Overrides:
clone in class Object

makeAndLinkCode

public RASMCode makeAndLinkCode(String name,
                                Hashtable library)
                         throws RASMCode.Exception
Create a code block from this list of instructions. Also links the block of code for convenience.
Parameters:
name - The name of the block of code to create.
library - The library context (for linking external references in the code.)
Returns:
A linked block of code.
Throws:
RASMCode.Exception - If linking fails for some reason.

toString

public String toString()
Produce a displayable version.
Overrides:
toString in class Object
Returns:
A list of instructions in a form that looks reasonable when printed.