|
CS 536 Fall 2007, Project 5 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
ObjectCG
public class CG
Static methods for generating code to a file.
| Field Summary | |
|---|---|
protected static int |
labelCounter
Counter for generating unique assembly language labels. |
static int |
MAX_S_REG
Max S register number. |
| Constructor Summary | |
|---|---|
CG()
|
|
| Method Summary | |
|---|---|
static void |
close()
Closes the output stream. |
static void |
comment(String text,
Object... args)
Generates a comment. |
static void |
inst(String opcode,
Object... args)
Outputs a machine instruction. |
static void |
label(String lab)
Outputs a label. |
static String |
newLabel()
Generates a new label. |
static void |
open(String fname)
Opens the output stream. |
static String |
S(int reg)
Returns the name of an S register. |
| Methods inherited from class Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static int labelCounter
public static final int MAX_S_REG
| Constructor Detail |
|---|
public CG()
| Method Detail |
|---|
public static void open(String fname)
throws IOException
fname - the name of the output file.
IOException - if the output file cannot be opened for writing.
public static void close()
throws IOException
IOException - if the stream cannot be closed.
public static void inst(String opcode,
Object... args)
opcode - the operation code.args - the arguments (may be empty).public static String newLabel()
public static void label(String lab)
lab - the text of the label, not including the colon.
public static void comment(String text,
Object... args)
text - the comment text, possibly containing printf-style escapes
such as '%s'.args - arguments corresonding to the % escapes.public static String S(int reg)
reg - the register number, in the range 0 .. MAX_S_REG.
IllegalArgumentException - if reg is out of range.
|
CS 536 Fall 2007, Project 5 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||