public abstract class TACInst
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
BINADD
Binary (integer) addition opcode
|
static int |
BINAND
Binary (boolean) AND opcode
|
static int |
BINDIV
Binary (integer) division opcode
|
static int |
BINMOD
Binary (integer) modulus opcode
|
static int |
BINMUL
Binary (integer) multiplication opcode
|
static int |
BINOR
Binary (boolean) OR opcode
|
static int |
BINSUB
Binary (integer) subtraction opcode
|
protected java.lang.String |
comments
Comments for instruction
|
static int |
DIRCALL
Call opcode -- used with non-dispatches (e.g., calls to error subroutines)
|
static int |
ERRPARAM
Error handling parameter opcode
|
static int |
IF
If opcode
|
static int |
INDIRCALL
Call opcode -- used with dispatches
|
static int |
LDADDR
Load address (i.e., label) opcode
|
static int |
LDCONST
Load constant opcode
|
static int |
LDENTRY
Load entry (i.e., read an entry in an object) opcode
|
static int |
LDVAR
Load variable (move) opcode
|
static int |
NUM_INSN_TYPES
Number of instruction types
|
protected int |
opcode
Instruction operation
|
static int |
PHI
Binary (boolean) OR opcode
|
static int |
REFPARAM
Reference parameter opcode
|
static int |
RETN
Return opcode
|
static int |
STDPARAM
Parameter opcode
|
static int |
STENTRY
Store entry (i.e., write an entry in an object) opcode
|
static int |
UNNEG
Unary (integer) negation opcode
|
static int |
UNNOT
Unary (boolean) not opcode
|
Constructor and Description |
---|
TACInst(int opcode)
TACInst constructor
|
Modifier and Type | Method and Description |
---|---|
abstract <ReturnType,ArgumentType> |
accept(TACInstVisitor<ReturnType,ArgumentType> visitor,
ArgumentType o)
Abstract visitor method.
|
void |
addComment(java.lang.String comment)
Add a comment to instruction (for debugging)
(this can be called multiple times for multi-line comments)
|
static boolean |
checkBoolConst(java.lang.String str)
Check that string is boolean constant
|
static boolean |
checkConst(java.lang.String str)
Check that string is a constant (int, boolean, String, or null)
|
static boolean |
checkIntConst(java.lang.String str)
Check that string is int constant
|
static boolean |
checkLabel(java.lang.String label)
Check that a label is legal
|
static boolean |
checkStrConst(java.lang.String str)
Check that string is String constant
|
static boolean |
checkVar(java.lang.String var)
Check that a variable name is legal
|
abstract boolean |
equals(java.lang.Object o)
Compares this object with the parameter object
|
static int |
getBinaryOpcode(java.lang.String op)
Convert string representation of binary operator to an opcode
(doesn't work for other operators)
|
java.lang.String |
getComments()
Get comments for instruction
|
java.lang.String |
getOp()
Get the instruction operator as a string
Only works for unary and binary operators
(no control flow or load operators)
|
int |
getOpcode()
Get opcode of instruction
|
abstract java.lang.String |
getString()
Get string representation of instruction (without comments)
(note: in general, you want to use toString() to get instruction string)
|
static int |
getUnaryOpcode(java.lang.String op)
Convert string representation of unary operator to an opcode
(doesn't work for other operators)
|
boolean |
isBinary()
Is this a binary instruction?
|
boolean |
isCall()
Is this a call instruction?
|
boolean |
isIf()
Is this an if instruction?
|
boolean |
isLoad()
Is this a load instruction?
|
boolean |
isParam()
Is this a parameter instruction?
|
boolean |
isPhi()
Is this a phi instruction?
|
boolean |
isReturn()
Is this a return instruction?
|
boolean |
isStore()
Is this a store instruction?
|
boolean |
isUnary()
Is this an unary instruction?
|
static boolean |
isValidID(java.lang.String s)
Is this string a legal Bantam Java identifier?
|
void |
removeComments()
Remove comments from an instruction
|
java.lang.String |
toString()
Convert to a string
|
public static final int IF
public static final int INDIRCALL
public static final int DIRCALL
public static final int RETN
public static final int STDPARAM
public static final int REFPARAM
public static final int ERRPARAM
public static final int LDVAR
public static final int LDCONST
public static final int LDADDR
public static final int LDENTRY
public static final int STENTRY
public static final int UNNEG
public static final int UNNOT
public static final int BINADD
public static final int BINSUB
public static final int BINMUL
public static final int BINDIV
public static final int BINMOD
public static final int BINAND
public static final int BINOR
public static final int PHI
public static final int NUM_INSN_TYPES
protected int opcode
protected java.lang.String comments
public TACInst(int opcode)
opcode
- opcode of instructionpublic abstract <ReturnType,ArgumentType> ReturnType accept(TACInstVisitor<ReturnType,ArgumentType> visitor, ArgumentType o)
visitor
- TACInstVisitor.o
- Data to pass down.public boolean isIf()
public boolean isCall()
public boolean isReturn()
public boolean isParam()
public boolean isLoad()
public boolean isStore()
public boolean isPhi()
public boolean isUnary()
public boolean isBinary()
public int getOpcode()
public java.lang.String getOp()
public static int getUnaryOpcode(java.lang.String op)
public static int getBinaryOpcode(java.lang.String op)
public java.lang.String getComments()
public void addComment(java.lang.String comment)
comment
- comment to addpublic void removeComments()
public static boolean checkLabel(java.lang.String label)
label
- label to checkpublic static boolean checkVar(java.lang.String var)
var
- variable to checkpublic static boolean checkIntConst(java.lang.String str)
str
- string to checkpublic static boolean checkBoolConst(java.lang.String str)
str
- string to checkpublic static boolean checkStrConst(java.lang.String str)
str
- string to checkpublic static boolean checkConst(java.lang.String str)
str
- string to checkpublic static boolean isValidID(java.lang.String s)
s
- string to checkpublic abstract boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- object to compare the reference object withpublic abstract java.lang.String getString()
public java.lang.String toString()
toString
in class java.lang.Object